Using Capybara with Cucumber

Using Capybara with Cucumber

Using Capybara with Cucumber

The cucumber-rails gem comes with Capybara support built-in. If you are not using Rails, manually load the capybara/cucumber module:

require ‘capybara/cucumber’

Capybara.app = MyRackApp

You can use the Capybara DSL in your steps, like so:

When /I sign in/ do

within(“#session”) do

fill_in ‘Email’, :with => ‘[email protected]

fill_in ‘Password’, :with => ‘password’

end

click_button ‘Sign in’

end

You can switch to the Capybara.javascript_driver (:selenium by default) by tagging scenarios (or features) with @javascript:

@javascript

Scenario: do something Ajaxy

When I click the Ajax link

There are also explicit @selenium and @rack_test tags set up for you.

 

Make your resume stand out and become a Certified Capybara Testing Professional. Try free practice tests here!

A great career is just a certification away. So, practice and validate your skills to become Certified Capybara Testing Professional

Using Capybara with RSpec
Using Capybara with Test::Unit

Get industry recognized certification – Contact us

keyboard_arrow_up