Skip to end of metadata
Go to start of metadata

Page Objects pattern is very well described here.

Graphene comes with support for this pattern. The main additions are:

  • Better support for initialization of the Page Objects. Graphene automatically enrich the Page Object's injection points (e.g. @FindBy).
  • Page Objects can contain Page Fragments and they are also properly initialized.
  • Page Objects can contain any injection point which Arquillian supports - e.g. @Drone WebDriver for injecting browser instance
  • Page Objects can encapsulate their location

You have already saw the default way of initializing Page Objects in the parent Page Abstractions page. Let's showcase Graphene way of doing this!

  1. Implement a Page Object.
  2. Declare it in the test.
  3. Annotate it with org.jboss.arquillian.graphene.spi.annotations.Page annotation.
  4. And that's all! No need to initialize Page Object via any factory method.

To see it in action, consider please code snippets below, which demonstrates testing of a simple web page with progress bar and two buttons.

Implement Page Object


TestingPage.java
Page Objects can be declared also as nested classes. However, to better decouple test logic from the structure of the tested page, it is recommended to declare Page Objects as standalone classes.
Your are not limited just with injecting WebElement instances. You can in the same way inject your Page Fragments, or even java.util.List of Page Fragments/WebElements.
Note that you have to use private fields for all Graphene initialized WebElement/Page Fragments etc. Use their getters from tests.
Page Objects in Multiple Browsers scenario
If you use page abstractions together with parallel browsers feature, be sure to check Using Page Abstractions with Multiple Browsers.

Declare it in the test and annotate it with @Page annotation.


Test.java

Deployment and browser determination

The deployment according to which the @Location value will be resolved, and the browser into which the page will be loaded can be determined in the following way:

You can read more about multiple deployments Arquillian feature here. Graphene support for parallel browsers for more information about this subject.
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.