Geb (pronounced “jeb”)

very groovy browser automation… web testing, screen scraping and more


Modern web pages are full of asynchronous operations like AJAX requests and animations. Geb provides built in support for this fact of life.

Any content lookup, or operation can be wrapped in a waitFor clause.

    waitFor { 
        $("p.status").text() == "Asynchronous operation complete!" 

This will keep testing the condition for a certain amount of time (which is configurable) until it passes. The same technique can be used to just wait for the content, not necessarily for the content to have some characteristic.

    def dynamicParagraph = waitFor { $("p.dynamically-added") }
    dynamicParagraph.text() == "Added dynamically!" 

You can also define that content should be implicitly waited for in the Content DSL for page objects

import geb.Page
class DynamicPage extends Page {
    static content = {
        dynamicParagraph(wait: true) { $("p.dynamically-added") }

With this definition, when dynamicParagraph is requested Geb will implictly wait for a certain amount of time for it to appear.

See the manual section on waiting for more information.