Skip to content

Instantly share code, notes, and snippets.

import static pages.Pages.*
scenario("search by specific query") {
search.submit("search this")
search.numberOfResults.waitToBe > 1
}
import static pages.Pages.*
scenario("search by specific query") {
search.submit("search this")
search.numberOfResults.shouldBe > 1
}
package pages
class Pages {
static final def search = new SearchPage()
static final def calculation = new CalculationPage()
static final def form = new FormPage()
}
package pages
import static org.testingisdocumenting.webtau.WebTauDsl.*
class SearchPage {
def searchBox = $('#search-box')
def numberOfResults = $('#results .result').count
def submit(query) {
browser.open("/search")
def searchBox = $('#search-box')
def numberOfResults = searchBox.count
scenario('search by specific query') {
submit('search this')
numberOfResults.shouldBe > 1
}
def submit(query) {
browser.open("/search")
def searchBox = $('#search-box')
def numberOfResults = searchBox.count
scenario('search by specific query') {
browser.open('/search')
searchBox.setValue('search this')
searchBox.sendKeys("\n")
numberOfResults.shouldBe > 1
scenario('search by specific query') {
browser.open('/search')
$('#search-box').setValue('search this')
$('#search-box').sendKeys("\n")
$('#results .result').count.shouldBe > 1
}
class Customer {
Number id
String url // store url of the created entity
}
def customerPayload = [firstName: "FN", lastName: "LN"]
def customer = createLazyResource("customer") { // lazy resource to be created on the first access
def id = http.post("/customers", customerPayload) {
return id
}
return new Customer(id: id, url: "/customers/${id}") // definition is below
}
scenario("CRUD operations for customer") {
def customerPayload = [firstName: "FN", lastName: "LN"]
def id = http.post("/customers", customerPayload) {
return id // return id value from response body
}
http.get("/customers/${id}") {
body.should == customerPayload // only specified properties will be asserted against
}