Skip to content

Instantly share code, notes, and snippets.

@celine-m-s
Last active February 12, 2017 21:52
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 celine-m-s/d624ed9ab5388cbfad713c8f1d8a251a to your computer and use it in GitHub Desktop.
Save celine-m-s/d624ed9ab5388cbfad713c8f1d8a251a to your computer and use it in GitHub Desktop.
Capybara Cheat sheet

#Matchers

expect(page).to have_content 'Success'
expect(page).to have_xpath("//a",:href => "google.com")
expect(page).to have_selector(:xpath, "//p/h1")
expect(page).to have_selector(:css, "p a#post_edit_path")
expect(page).to have_selector("input", :value =>"Post Title")    

#Actions

visit page_path
click_link_or_button "Save"
attach_file('Image', 'path/to/file')
check('A Checkbox')
choose('A Radio Button')
click_link('Link Text')
click_button('Save')
click_on('Link text') # a link or a button
fill_in('Name', with: 'Value')
select('Option', from: 'Sélect Box')
uncheck('A checkbox')  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment