Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Capybara wait times?

Tags:

capybara

I want to have different Capybara wait times in my code depending on how much time they usually take to load completely? Do I have to repetitively keep changing the Capybara.default_wait_time or is there a better way?

like image 968
Ava Avatar asked Jan 15 '13 20:01

Ava


People also ask

Does Capybara find wait?

Thankfully, the Capybara developers have provided us with tools to get around this. Capybara's find method waits by default for an element to appear for a certain amount of time.

Why was wait<UNK>until removed from capybara?

wait_until was removed for several reasons: It simply isn't necessary for most applications and test suites. Its existence confuses people into thinking that it is necessary, when in fact it isn't. It was added at a point where Capybara's auto-waiting was much more primitive than it is now.


1 Answers

You can use using_wait_time(seconds) method like:

using_wait_time 3 do   expect(page).to have_text 'Lorem ipsum' end 

or :wait option (that appeared in Capybara 2.1).

Note that :wait option was supported only by find method in Capybara 2.1.

Support for :wait option in matchers (i.e. has_x? and have_x methods) has been added in Capybara 2.2:

expect(page).to have_text('Lorem ipsum', wait: 3) 
like image 80
Andrei Botalov Avatar answered Sep 25 '22 04:09

Andrei Botalov