Imagine that you have a site that has a number of different pages that you need to test. This is quite common for a number of sites. We can create an object that represents the page and then pass the Selenium object in the programming language. So let us now create our first Page Object against the Home page.
Create a new Java class in IDEA called
HomePage
.Import the relevant packages for the tests to run.
We will now need a constructor to handle Selenium. You may want to make it go to the home page when it is instantiated too. An example of this can be as follows:
HomePage.java
import com.thoughtworks.selenium.Selenium; public class HomePage{ Selenium selenium; public HomePage(Selenium selenium){ this.selenium = selenium; } public Chapter2 clickChapter2(){ clickChapter("2"); selenium.waitForPageToLoad("30000"); return new Chapter2(selenium); } private void clickChapter(String number)...