how to use waitFor with conditionals?

17 views
Skip to first unread message

Yaroslav Nakonechnikov

unread,
Nov 13, 2019, 12:53:10 PM11/13/19
to Geb User Mailing List
Hello, 

i'm trying to build auto test with geb, and in one place web application can redirect to one or another page. 

so, is it possible to use waitFor for detecting redirect? 
or, if not possible... how to check expected results? 

i mean, how to use it in something like this:


waitFor (15) { $("#ghx-board-name").text().contains("SLTP board")  $("#title").text().contains("SLTP board") } ?

Martin de laat

unread,
Nov 13, 2019, 1:10:49 PM11/13/19
to Geb User Mailing List
Never triedbit, but does this work?

If ( $("#selector", text: "something", wait: 5, required: false).visible ) {
Foo
} Else {
Bar
}

Something like that? Sorry on the road and on mobile.
I don't see why you would want to use waitFor because that throws an exception if it doesn't return true.
You could also write two tests, one for each type of behaviour.

Martin de laat

unread,
Nov 13, 2019, 5:27:55 PM11/13/19
to Geb User Mailing List
You can also create geb page objects of both pages. Then you can do something like:

Given:
At page1

When:
$( selector ).click

Then:
At page2

Reply all
Reply to author
Forward
0 new messages