Created
August 8, 2012 05:29
-
-
Save synth/3292441 to your computer and use it in GitHub Desktop.
Sometimes you need to slow down Capybara until certain things have loaded(like javascript assets loaded with RequireJS), here's a solution I came up with:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/spec/support/asynchronous_helper.rb | |
module AsynchronousHelper | |
def wait_until_remote_events_are_bound | |
page.wait_until do | |
page.evaluate_script("typeof($assetsloaded) === 'object'") | |
end | |
end | |
def wait_until_overlay_has_popped_up | |
page.wait_until do | |
page.evaluate_script("$('div.overlay').is(':visible')") | |
end | |
end | |
def wait_until_overlay_disappears | |
page.wait_until do | |
!page.evaluate_script("$('div.overlay').is(':visible')") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wait_until has been removed now though, have you a workaround?