Skip to content

Instantly share code, notes, and snippets.

@drewB
Created July 9, 2012 21:35
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 drewB/3079141 to your computer and use it in GitHub Desktop.
Save drewB/3079141 to your computer and use it in GitHub Desktop.
helper for waiting that all dom manipulation had completed
#will wait until all dom elements are rendered
def wait_for_dom(timeout = Capybara.default_wait_time)
uuid = SecureRandom.uuid
page.find(:xpath, "//body")
page.evaluate_script <<-EOS
_.defer(function() {
$('body').append("<div id='#{uuid}'></div>");
});
EOS
wait_until(timeout) {page.find(:xpath, "//div[@id='#{uuid}']")}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment