Skip to content

Instantly share code, notes, and snippets.

@synth
Created August 8, 2012 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save synth/3292441 to your computer and use it in GitHub Desktop.
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:
#/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
@adamwaite
Copy link

wait_until has been removed now though, have you a workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment