Page Object Template
Explore how to structure page object classes for Selenium Java tests, including constructors, locator constants, and public and private methods. Discover best practices for organizing page components to keep tests maintainable and clear.
We'll cover the following...
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.
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 variable so the class methods can use it.
Page class variables
Both classes have a driver variable that gets a value in the ...