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

Marcos has posted 4 posts at DZone. View Full User Profile

Showing A Use To DELEGATE_FIRST Closure Resolve Strategy: Selenium Navigation

  • submit to reddit
        // Show how to use groovy closures to write more clear selenium code

// More details here:
// first, add a method to Selenium class
Selenium.metaClass.execute = { closure ->
    closure.delegate = delegate
    closure.resolveStrategy = Closure.DELEGATE_FIRST

// making selenium stuff more clear

def selenium = getSelenium()
selenium.execute {
    type "field", "value"
    click "submitButton"
    waitForPageToLoad "5000"
    // do some more stuff