Skip to content

Instantly share code, notes, and snippets.

@chuckg
Created March 21, 2013 21:21
Show Gist options
  • Save chuckg/5216894 to your computer and use it in GitHub Desktop.
Save chuckg/5216894 to your computer and use it in GitHub Desktop.
Capybara `sleep()` is sinful. Instead, block until your element appears!!
def wait_until_element_exists(element)
wait_until { page.find(element).visible? }
return unless block_given?
within element do
yield
end
rescue Capybara::TimeoutError
flunk "Expected '#{element}' to be present."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment