Capybara/selenium: wait for element to become hidden
I need to wait for loading b开发者_开发问答ar (div#loading) to disappear (become display: none) in a cucumber step. I'd expect the following to do the trick
find('#loading').should_not be_visible
But it doesn't seem to be waiting. Any ideas how to achieve that?
You will want to use the wait_until
to wait for your condition to be met.
wait_until { !page.evaluate_script(%{$('#loading').is(':visible')}) }
There might be a better wait to check for visibility, but last time I checked page.has_no_css
does not work with things like :visible
.
(Update) Though has_css
does not see selectors like :visible
, Capybara::Node::Element
does have some methods to make the above a bit prettier.
wait_until { !find("#loading").visible? }
精彩评论