Very first example on Geb manual not executing Very first example on Geb manual not executing selenium selenium

Very first example on Geb manual not executing


The script is entering wikipedia into the Search box, but it's not hitting the Google Search button to kick off the search.

If you add:

// hit the "Google Search" button$("input", name: "btnG").click()

right after

// enter wikipedia into the search field$("input", name: "q").value("wikipedia")

you'll get a little farther.


The example makes use of the auto load feature in Google whereby search results are displayed as you type in the search, hence you don't need to click on the search button. When you run the test, you should see that the search results are displayed and the Wikipedia link is the first.

The WaitTimeoutException you are getting is most probably because the browser closes too quickly after arriving at the Wikipedia page. To fix that, just update the waitFor call to make it wait longer before closing the browser i.e.

waitFor(10) (at WikipediaPage)

Alternatively, if you run gradle in debug mode, the process is much slower and hence allows the test to check for the title before the browser is terminated

gradlew firefoxTest --debug --stacktrace


I had the same problem you are experiencing.

The first WaitFor issue:

The first wait for can be fixed by J. Levine's answer. Adding:

$("input", name: "btnG").click()

after:

$("input", name: "q").value("wikipedia").

The second WaitFor issue:

The title of the page that Wikipedia opens to from google is different from the Wikipedia Homepage. On the homepage it is <title>Wikipedia<title> on the main page(which google opens to is <title>Wikipedia, the free encyclopedia<title>.

So change:

waitFor { title == "Wikipedia" } }
To:
waitFor { title == "Wikipedia, the free encyclopedia" }
}

And that should fix the second wait issue