What is the PageObject pattern?

Whenever we are designing an automation framework for testing web applications, we have to accept the fact that the target application and its elements are bound to change. An efficient framework is one that needs minimal refactoring to adapt to new changes in the target application. Let us try to build the preceding test scenarios into the PageObject design pattern model. Let us first start building a PageObject for the login page. This should look as shown in the following code:

public class AdminLoginPage {
    WebDriver driver;
    WebElement email;
   WebElement password;
    WebElement submit; public AdminLoginPage(WebDriver driver){ this.driver = driver; driver.get("http://pageobjectpattern.wordpress.com/wp-admin"); email ...

Get Selenium WebDriver Practical Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.