- It offers tester friendly DSL
- Installation as simple as it is.
- Capybara helps you test web applications by simulating how a real user would interact with your app
- gem install capybara
- gem install #{web_driver_on_which_capybara_runs}
- Capybara : No wait & No sleep
- Support xpath, css, jQuery.
- Can use headless browsers without changing your code
Capybara - Web app Testing
- Easy to switch between drivers.
capybara's ease of use
Why Capybara
Manual => Automated
Capybara
Presented By
:Navigates to a particular path
Capybara DSL
:will click an anchor tag, button or input with type submit
- click_button('Save')
- click_link('id-of-link')
- click('Link Text')
:returns a boolean value reporting whether specific content is presentin the page
- page.has_content?('Sign in')
:fills in fields for you.
- fill_in 'Title', with: 'I love Rails!'
- fill_in('First Name', :with => 'vino')
:checks a checkbox
:unchecks a checkbox
:selects an option from a select tag
- select 'MA', from: 'State'
:can execute jQuery scripts in your web page
- page.evaluate_script("$('.firstname').text();")
- e.g: firstname=page.evaluate_script("$('.firstname').text();")
expect(firstname).to eq("vino")