O'Reilly logo

Mastering Selenium WebDriver by Mark Collin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Turning your page objects into a readable domain-specific language

Well, it's actually not that hard to make things better. Earlier in this chapter, we moved the page object's initialization into the constructor and had a look at a way of initializing page objects without passing any parameters. Let's use this simplicity to start turning page objects into a fluent, readable DSL (domain-specific language).

We will start off by taking the index page object and creating a reference to the header, the footer, and the page objects inside it, as follows:

package com.masteringselenium.page_factory_objects; import com.masteringselenium.DriverFactory; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.How; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required