DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Showing A Use To DELEGATE_FIRST Closure Resolve Strategy: Selenium Navigation
// Show how to use groovy closures to write more clear selenium code
// More details here: http://snippets.dzone.com/posts/show/5922
// first, add a method to Selenium class
Selenium.metaClass.execute = { closure ->
closure.delegate = delegate
closure.resolveStrategy = Closure.DELEGATE_FIRST
closure()
}
// making selenium stuff more clear
def selenium = getSelenium()
selenium.execute {
type "field", "value"
click "submitButton"
waitForPageToLoad "5000"
// do some more stuff
}





