Skip to content

Instantly share code, notes, and snippets.

@AndersDJohnson
Last active June 5, 2019 13:32
Show Gist options
  • Save AndersDJohnson/0d86c0d0c9ae5e1ca451 to your computer and use it in GitHub Desktop.
Save AndersDJohnson/0d86c0d0c9ae5e1ca451 to your computer and use it in GitHub Desktop.
Geb conditional flow
class ConditionalSpec extends GebReportingSpec {
/**
* This should get us to SomePage, handling any interim pages.
*/
def getToSomePage () {
waitFor {
if (isAt(SomePage)) {
println "at some page"
return true
} else if (isAt(InterimPage)) {
println "nope, at interim page"
// do something else from InterimPage to get to SomePage...
clickInterimPageLinkToSomePage()
return true
}
// ...
}
}
}
class UseSpec extends ConditionalSpec {
def "Testing conditionals" () {
given: "I am at a start page"
to StartPage
then: "We have successfully loaded the page."
at StartPage
then: "We have successfully loaded the page."
// this might trigger an interim page
clickStartLinkToSomePage()
then: "We want to be at other page, but may be at some page"
// get me to SomePage no matter what
getToSomePage()
// wait until at SomePage
waitFor { at SomePage }
and: "We are done!"
println "ok!"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment