Code Monkey home page Code Monkey logo

guitest's Introduction

Polopoly GUITest

web test framework for the Polopoly GUI based on TestNJ

few examples

just logging in ...

package com.polopoly.guitest.framework;

import com.google.inject.Inject;
import com.polopoly.guitest.agent.GuiBaseAgent;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(TestNJRunner.class)
public class GuiLoginIT {

    @Inject
    private GuiBaseAgent gui;


    @Test
    public void loginAgain() {
        gui.login("emma", "emma");
    }

}

now create some content:

package com.polopoly.guitest.framework;

import com.google.inject.Inject;
import com.polopoly.guitest.agent.ContentTreeAgent;
import com.polopoly.guitest.agent.GuiBaseAgent;
import com.polopoly.guitest.agent.InputAgent;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

@RunWith(TestNJRunenr.class)
public class AMoreContrievedExampleIT {

    @Inject
    GuiBaseAgent gui;

    @Inject
    WebDriver webDriver;

    @Inject
    ContentTreeAgent contentTree;

    @Inject
    InputAgent input;

    @Test
    public void createArticle() throws Exception {
        gui.loginAsSysadmin().navFrame();
        contentTree.open("Greenfield Times");
        gui.workFrame().selectTab("Articles & Resources");
        webDriver.findElement(By.xpath("//button[contains(text(), 'Create')]")).click();
        input.typeInTextfield("Title *", "my foolish article.");
        gui.toolbar.clickOnSaveAndInsert();
    }

}

Provided Agents

For an up-to-date list refer to the package com.polopoly.guitest.agent

Write your own Agents

Project defined agents can be injected in exactly the same way provided agents are.

Check the Agent007 and Agent007IT in the test source folder for an example of how to write/inject own agents.

WebDriver configuration and lifecycle

Configuration

The abstract class WebDriverProvider is responsible of both initiating and tearing down WebDriver. Unless you provide a custom implementation through java.util.ServiceLoader a FirefoxDriver will be instantiated by default.

If you want to override this behaviour implement in your project the WebDriverProvider class and create a pointer to it in META-INF/services

For instance:

package example;

public class MyWebDriverProvider extends WebDriverProvider {

    @Override
    public WebDriver initDriver() {
        return new MyCustomWebDriver();
    }

}
echo "example.MyWebDriverProvider" > META-INF/services/com.polopoly.guitest.webdriver.WebDriverProvider

Lifecycle

The default behaviour is to create a new instance of the driver for each test run.

You can change this by overriding the method WebDriverProvider.shutDownDriver in you project provider class.

Note about installing

When you run "mvn install" you must have access to a Polopoly runtime for the integration tests phase to complete without errors.

Use 'polopoly.guitest.properties' if you don't have Polopoy running on localhost. For instance:

mvn -Dpolopoly.guitest.properties=src/test/resources/webtests.integration.properties 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.