Tom Carver

automating chaos just leads to faster chaos


The Journey pattern - the successor to PageObject

“The Journey pattern” supplants PageObject as the go-to UI automation pattern. This post explains why you should care and how you can start upgrading your PageObjects tomorrow.

 The home favourite: the PageObject pattern

The Page Object pattern has become the de-facto UI automation pattern - even the official Selenium docs include a description. The idea is to separate your test code into classes corresponding to each different screen (i.e. ‘Page’), with one method for each interaction with the page. To simplify the example from the docs, the following code

driver.findElement(By.cssSelector("#username")).sendKeys("myUsername");
driver.findElement(By.cssSelector("#password")).sendKeys("myPassword");
driver.findElement(By.cssSelector("#loginButton")).click();

becomes

new LoginPage(driver).loginAs("myUsername", "myPassword");


// PageObject
public class LoginPage {
    private
...

Continue reading →