Definition

To create representation of the page extend class Page. Then populate it variables the same way as you would in traditional Selenium PageOject.

@PageConfig(uri = "/")
public class HomePage extends Page {

    @FindBy(id = "header")
    protected SebElement header;

    @FindBy(tagName = "a")
    protected List<SebElement> links;

}

Instantiation

You get instance of page usually by calling .initPage(HomePage.class), if you were redirected to a new page by interacting with the previous one, or by navigating directly with seb.goTo(HomePage.class). On the background Seb will create an instance for you and configure it from annotation @PageConfig and config retrieved from Seb instance.

@PageConfig annotation

Use this annotation on PageObject to provide additional setup. Usually you will use attribute uri, which will be combined with seb.baseUrl from properties to get URL of the page. Alternatively for dynamic creation of the address you can override method getUrl()

Managing instantiation

Convenient methods for managing instantiation are provided:

  • beforeInit()
  • beforeInitElements()
  • afterInitElements() - before here any attempt to work with Page elements will result in NullPointerException
  • beforeSetup()
  • setup() - use this method to setup other than SebElement values. For example to have prepared page title in form of String rather than retrieve it from SebElement everytime its needed.
  • afterSetup()
  • beforeVerify()
  • verify()
  • afterVerify()