Created
November 27, 2018 16:45
-
-
Save titusfortner/251db29e52cdcaa82be405777c2147fb to your computer and use it in GitHub Desktop.
Capybara vs Watir Element Location examples
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
# Capybara | |
find('.inventory_item:first-child').click_button('ADD TO CART') | |
click_button('ADD TO CART', match: :first) | |
click_button(class: 'add-to-cart-button', match: :first) | |
first(:button, 'ADD TO CART').click | |
first(:button, class: ['add-to-cart-button']).click | |
first('.add-to-cart-button').click | |
# Watir | |
browser.div(class: 'inventory_item').button('ADD TO CART').click | |
browser.button(text: 'ADD TO CART').click | |
browser.button(class: 'add-to-cart-button).click | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment