The abstract class

Here is an example of a simple abstract base class, explained in sections:

/**
* Sample Base Class Page Object for Browser App
*
* @author Name
*
*/
public abstract class BrowserBasePO <M extends WebElement> {
public int elementWait = Global_VARS.TIMEOUT_ELEMENT;
public String pageTitle = "";
WebDriver driver = CreateDriver.getInstance().getDriver();

// constructor
public BrowserBasePO() throws Exception {
PageFactory.initElements(driver, this);
}
}
/**
* Sample Base Class Page Object for Mobile App
*
* @author Name
*
*/
public abstract class Mobile</span>BasePO <M extends MobileElement> {
public int elementWait = Global_VARS.TIMEOUT_ELEMENT;
public String pageTitle = "";
AppiumDriver<MobileElement> driver =
CreateDriver.getInstance().getDriver(true);

// constructor
public MobileBasePO () throws Exception {
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
}
The WebDriver documentation on the page factory class is located at https://github.com/SeleniumHQ/selenium/wiki/PageFactory.

Notice that in the class signature, there is a generic user that passes in WebElement; this is included now to allow future modification of the default behavior of the WebElement class. Again, the PageFactory.initElements method is called in the constructor that will automatically initialize all the subclass page objects when it is instantiated.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.196.217