Page Object Template

Learn how to set up the page object class that contains the page URL, title, and locators.

All interactions with the site pages happen in page object classes.

For each web page that is used in the test, a page object class is needed.

We will use a HomePage class for the Home Page and a ResultsPage class for the Results Page.

Both page object classes follow the same template.

Press + to interact
public class PageObjectClass
{
private WebDriver driver;
//element locator variables
//page url variable
//page title variable
public PageObjectClass(WebDriver driver)
{
this.driver = driver;
}
//methods that interact with the page
//methods that provide information from the page
}

Page class constructor

Both classes will have a constructor for creating the class’s objects. The constructor gets a driver parameter that is saved in a class ...