Hello, Geb 0.13.1 here. I have read over the docs and am having difficulty getting the
waitFor method to work for me:
class LaunchGeb {
static void main(String[] args) {
FirefoxDriver firefoxDriver = new FirefoxDriver()
Browser browser = new Browser(driver: firefoxDriver)
Browser.drive(browser) {
to(GoogleHomepage)
at(GoogleHomepage)
search().value('gmail')
waitFor {
searchButton.click()
}
at(GoogleSearchResultsPage)
quit()
}
}
}
class GoogleHomepage extends Page {
static at = {
title == 'Google'
}
static content = {
search {
$('input', name: 'q')
}
searchButton {
$('button', name: 'btnG')
}
}
}
class GoogleSearchResultsPage extends Page {
static at = {
title == 'gmail - Google Search'
}
}
When I run this I get the following exception:
Exception in thread "main" Assertion failed:
title == 'gmail - Google Search'
| |
| false
Google
at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:402)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:650)
at sandbox.geb.GoogleSearchResultsPage$__clinit__closure1.doCall(GoogleSearchResultsPage.groovy:10)
at sandbox.geb.GoogleSearchResultsPage$__clinit__closure1.doCall(GoogleSearchResultsPage.groovy)
So Geb is:
- Launching Firefox (yaaay)
- Going to Google's homepage
- Entering "gmail" in the search bar and clicking enter (to perform the search)
- But it is not properly waiting for that click to finish, as the "at checker" for GoogleSearchResultsPage is failing because Geb still thinks the browser is at the Google homepage
Interestingly enough, when I replace:
search().value('gmail')
waitFor {
searchButton.click()
}
at(GoogleSearchResultsPage)
For:
search().value('gmail')
searchButton.click()
Thread.sleep(5000)
at(GoogleSearchResultsPage)
The code runs just fine. However, I don't want to use thread sleeps, and would prefer to use waitFor (or any other Geb-endorsed solution) instead. Any ideas as to what is going on here?