How to set up Capybara and Selenium in ruby on rails application?
First of all add gems into gemfile:
gem 'capybara' gem "selenium-webdriver" gem 'chromedriver-helper'
After Adding new gem, its time to bundle install
Now, We need to tell application that we are using capybara with Rspec testing, to do so we need to add following code into rails_helper.rb file
require 'capybara/rspec' require 'capybara/rails'
In order to run test cases in particular browser, need to set default browser.To Set default browser for test suits, Add below code into rails_helper.rb
Capybara.register_driver :selenium do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome) end
Now we are ready to write test suits for our application but before that if any Error raised like driver not found , to resolve that we would need to install Chromedriver.exe
http://chromedriver.storage.googleapis.com/index.html?path=2.15/ Move downloaded file Chromedriver.exe to C:\ruby\bin folder
This is all about how to set up capybara with selenium, If you are looking for Example, Here is github link Cucumber, capybara, selenium testing
Please log an issue here.