Created
December 3, 2017 19:29
-
-
Save raditotev/4897821b19f25210c48291c82e7f32cb to your computer and use it in GitHub Desktop.
Capybara waiting methods
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
# If you want to make sure there's exactly one | |
find(".active").click | |
# If you just want the first element | |
find(".active", match: :first).click | |
# All matching elements | |
find(".active", match: :first) # Wait for the first element | |
all(".active").each(&:click) | |
# JavaScript interaction | |
find(".active") # Wait for the element | |
execute_script("$('.active').focus()") | |
# Checking field's value | |
expect(page).to have_field("Username", with: "Joe") | |
# Checking element's attribute | |
expect(page).to have_css(".user[data-name='Joe']") | |
# Looking for matching CSS | |
expect(page).not_to have_active_class | |
def have_active_class | |
have_css(".active") | |
end | |
# Source: https://robots.thoughtbot.com/write-reliable-asynchronous-integration-tests-with-capybara |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment