Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Capybara/Cucumber and waiting for Javascripty stuff to happen

A little ditty that makes it really easy to wait for something Javascripty to happen…like a Javascript dialog to appear that gets populated from an AJAX call.

The has_css? method call will wait until the element shows up and if it doesn’t show up before the Capybara timeout expires then it will return false.

  1. You can also just use the built in web step: Then I should see “something loaded by JS”

    That will wait for javascripty thing to happen

  2. Mike Gehard says:

    Thanks Brandon for the clarification!

    The key for us in this step is the :visible => true option. The out of the box “Then I should see” web step passes even if the text isn’t visible but does appear in the DOM, I believe.

    We were waiting for a dialog to be visible so we could do something with it.

    Sorry I wasn’t more clear in the original post.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *