Skip to content

Instantly share code, notes, and snippets.

@toddsiegel
Last active January 11, 2022 16:08
Show Gist options
  • Save toddsiegel/f80f2c6d6884aeec143cca6b7ffab4b5 to your computer and use it in GitHub Desktop.
Save toddsiegel/f80f2c6d6884aeec143cca6b7ffab4b5 to your computer and use it in GitHub Desktop.
Capybara Cheatsheet

Forms

Fill in inputs by name

# e.g.
# <table>
#   <tbody>
#     <tr>
#      <td><input name="foo" type="text" /></td>
#      <td><input name="bar" type="text" /></td>
#     </tr>
#   </tbody>
# </table>
row = first('table tbody tr')
row.fill_in "foo", with: 'A value'
row.fill_in "bar", with: 'Another value'

Debugging

Print an element's HTML

  el = find(...)
  puts el['innerHTML']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment