Question

I have found very strange behaviour of Geb library.

Below is example of my test:

Then(~'I should see that I\'m logged in') { ->
    assert browser.find('div#loggedInBlock').isDisplayed()
}

It works OK, but I'm concerned about timeouts since it needs sometime to execute js and load etc, so I modified my code like here:

Then(~'I should see that I\'m logged in') { ->
    browser.waitFor() {
        assert browser.find('div#loggedInBlock').isDisplayed()
    }
}

So I expect it will work if there will be some unexpected delays. But I got error here - this condition unexpectedly doesn't pass. If I return my code back and delete 'waitFor' it works good again.

So I'm confused, why is this happening?

Était-ce utile?

La solution

Since Geb 0.7.0 contents of waitFor blocks are implicitly asserted meaning that you don't need/shouldn't use assert keyword inside of them. Have a look at implicit assertions section of the Book of Geb to understand what this means.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top