June 2018
Beginner to intermediate
376 pages
8h 58m
English
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