JBoss Community Archive (Read Only)

Graphene 2

Graphene Utility Class

Graphene is an entry point for the common one-line operations:

Static Import of Graphene Utility Class

The main advantage of the Graphene utility class is, that it includes set of static methods, which can be used directly from your test:

Graphene.guardAjax(button).click();

This concept is much stronger when using possibilities of your IDE for code completion.

You can use Eclipse Favorites feature and include Graphene into list of utility classes - you will get suggestions for code-completion out of the box.

Waitings

Shortcut for fluent waiting API.

waitAjax();
waitGui();
waitModel();

//e.g.
button.click();
waitGui().withMessage("Popup should be opened after clicking on that button!").until().element(popupPanel).is().visible();

See the Waiting API documentation page for more information.

Request Guards

It is a shortcut for the Graphene request guards, which are powerful tools to assert that an AJAX/HTTP or no request was done.

guardAjax(Object);
guardHttp(Object);
guardNoRequest(Object);
waitForHttp(Object);

//e.g.
guardAjax(button).click();

waitForHttp() is a guard as well, even when its name does not tell it. The difference between the waitForHttp() and the guardHttp() is that the first one does ignore AJAX requests during its waiting period and the second one does not.

See the Request Guards documentation page for more information.

Creating Page Fragments dynamically

Sometimes you need a way to create a Page Fragment instance not by injecting it via @FindBy, but dynamically.

createPageFragment(Class<T> clazz, WebElement root);

Consider a Tab Panel widget, for which you want to create a Page Fragment. You do not know in advance how many tabs it will have; and you wanna to return an initialized Page Fragment with tabs content each time an user switch to a particular tab. This method is suitable for this.

Page Object location encapsulation

You can find more information about Page Object location encapsulation in this documentation page.

Basically, you can use Graphene.goTo() method like this:

@Location("register.html")
public class RegistrationPage {
  //all the Page Objects FindBy, etc. goes here
}

public class TestSuite {

  public void test() {
    Graphene.goTo(RegistrationPage.class);
    //testing of the page goes here;
  }

}

Graphene will load http://locahost:8080/register.html into your default browser.

You can specify the browser into which the page should be loaded by passing a browser qualifier as a Graphene.goTo(Class<?> pageObject, Class<?> browserQualifier) parameter.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-10 12:14:27 UTC, last content change 2013-09-11 09:41:34 UTC.