smeeb
smeeb

Reputation: 29507

Geb EmptyNavigator is not present

Using Geb 0.13.1 here. I'm not trying to integrate it with any kind of testing framework (yet), just trying to get a feel for its DSL. I just want Geb to launch a Firefox browser, point it to Google's homepage and type in 'gmail' in the search address (HTML <input/> with an id of 'q'):

class GoogleHomepage extends Page {
    static url = 'http://google.com'

    static at = {
        title == 'Google'
    }

    static content = {
        search {
            $('input#q')
        }
    }
}

class MyGebDriver {
    static void main(String[] args) {
        FirefoxDriver firefoxDriver = new FirefoxDriver()
        Browser browser = new Browser(driver: firefoxDriver)

        Browser.drive(browser) {
            to(GoogleHomepage)

            search.value('gmail')

            quit()
        }
    }
}

When I run this, Firefox opens up and goes to Google, but seems to choke when finding the search ('q' element) bar to set a value for:

Exception in thread "main" geb.error.RequiredPageContentNotPresent: The required page
    content 'sandbox.geb.GoogleHomepage -> search: geb.navigator.EmptyNavigator' is not
    present

Any ideas as to what's going on here?

Upvotes: 1

Views: 2998

Answers (2)

zypherman
zypherman

Reputation: 657

Your GoogleHomepage looks a bit goofy to me. What if you made it look more like this which follows the geb dsl better.

class GoogleHomepage extends Page {

    url = 'http://google.com'

    static at = {
        waitFor() {
            title == 'Google'
            content
        }
    }

   static content = {
       search(required: true) { $('input#lst-ib') }
   }
}

Upvotes: 1

Deon
Deon

Reputation: 98

You're getting an EmptyNavigator because you're looking for an input with an id of q $('input#q') try $('input[name=q]') instead.

Upvotes: 2

Related Questions