Created
March 21, 2013 21:21
-
-
Save chuckg/5216894 to your computer and use it in GitHub Desktop.
Capybara `sleep()` is sinful. Instead, block until your element appears!!
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
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