XZen
XZen

Reputation: 445

Geb, waitfor unexpected affect the behavior

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?

Upvotes: 0

Views: 570

Answers (1)

erdi
erdi

Reputation: 6954

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.

Upvotes: 3

Related Questions