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's try to build the preceding test scenarios into the PageObject design pattern model. Let's first start building a PageObject for the login page. This should look like the following:

public class AdminLoginPage {        WebDriver driver;    WebElement email;    WebElement password;    WebElement submit;    public AdminLoginPage(WebDriver driver) {        this.driver = driver;        driver.get("http://demo-blog.seleniumacademy.com/wp/wp-admin");        email = driver.findElement(By. ...

Get Selenium WebDriver 3 Practical Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.