Skip to Main Content
Mastering Selenium WebDriver 3.0 - Second Edition
book

Mastering Selenium WebDriver 3.0 - Second Edition

by Mark Collin
June 2018
Beginner to intermediate content levelBeginner to intermediate
376 pages
8h 58m
English
Packt Publishing
Content preview from Mastering Selenium WebDriver 3.0 - Second Edition

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 
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Selenium WebDriver 3 Practical Guide - Second Edition

Selenium WebDriver 3 Practical Guide - Second Edition

Pallavi Sharma, UNMESH GUNDECHA, Satya Avasarala

Publisher Resources

ISBN: 9781788299671Supplemental Content