Last active
June 5, 2019 13:32
-
-
Save AndersDJohnson/0d86c0d0c9ae5e1ca451 to your computer and use it in GitHub Desktop.
Geb conditional flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
// ... | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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