Skip to content

Instantly share code, notes, and snippets.

@titusfortner
Created November 27, 2018 16:45
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 titusfortner/251db29e52cdcaa82be405777c2147fb to your computer and use it in GitHub Desktop.
Save titusfortner/251db29e52cdcaa82be405777c2147fb to your computer and use it in GitHub Desktop.
Capybara vs Watir Element Location examples
# 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