Turning your page objects into a readable DSL
Well it's actually not that hard to make things better. Earlier in this chapter, we moved our page object initialization into the constructor and had a look at a way of initializing page objects without passing in any parameters. Let's use this simplicity to start turning our page objects into a fluent, readable DSL.
We will start off by taking our index page object and creating a reference to the header and footer page objects inside it:
package com.masteringselenium.query_page_objects; import com.lazerycode.selenium.util.Query; import org.openqa.selenium.By; public class IndexPage extends BasePage { private Query heading = new Query(By.cssSelector("h1"), driver); private Query mainText = new Query(By.cssSelector(".col-md-4 > p"), driver); private Query button = new Query(By.cssSelector(".btn"), driver); public PageHeader header = new PageHeader(); public PageFooter footer = new PageFooter(); public boolean...