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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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)