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?
Add a comment
|
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)
-
-
Maybe I am missing something here, but is this not just a fancy way of using sleep(x) ? – Dono Aug 22 '14 at 14:30
-
5@Dono
sleep
will always pause forx
.have_text
will pause for time up tox
(until text will appear). – Andrei Botalov Aug 22 '14 at 17:42 -
1@Dono github.com/jnicklas/capybara/blob/2.4.1/lib/capybara/node/… – Andrei Botalov Sep 13 '14 at 6:00
-
2@Dono its fanciness grants specific advantages; per the docs and Andrey. "up to" is a critical term, here. – New Alexandria Feb 9 '15 at 20:22