Test Encapsulation

Robust tests should not depend on implementation details. UI has plenty of those:UI Elements placement Actions UI test should not depend on any of them. Move elements placement and available actions outside of UI test. Multiple tests can then reuse that information. And more importantly you will have only one place to change if UI changes.

Definition

To define PageObject create a class. package pages import static org.testingisdocumenting.webtau.WebTauDsl.* class SearchPage { def welcomeMessage = $("#welcome") def searchMessage = $("#message") def box = $("#search-box") def results = $("#results .result") def numberOfResults = results.count def submit(query) { browser.open("/search") box.setValue(query) box.sendKeys(browser.keys.enter) } }

Grouping

To make it easier to refer PageObjects from different tests combine them in one file package pages class Pages { static final def search = new SearchPage() static final def calculation = new CalculationPage() static final def form = new FormPage() static final def payments = new PaymentsPage() } Use static import to have seamless access to all of them package scenarios.ui import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* import static pages.Pages.* scenario("search by specific query") { search.submit("search this") search.numberOfResults.should == 2 }