4

I need to wait for loading bar (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?

1 Answer 1

9

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? }
1
  • @MikeAski might be useful to add the new proposed way for those coming here in the future. God I hate cucumber
    – adaam
    Jun 15, 2018 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.