Using Capybara, Cucumber, and Selenium WebDriver in Ruby
Capybara is an acceptance test framework for web applications in Ruby. It integrates with Ruby-based BDD frameworks such as Cucumber and RSpec along with Selenium WebDriver for web testing capabilities. Capybara is widely used in testing Rails applications.
In this recipe, we will see how to use Capybara, Cucumber, and Selenium to test BMI Calculator application.
Getting ready
You need to install Capybara Gem by using the following command:
gem install capybara
Additionally, you also need to install Cucumber and RSpec Gem on a fresh Ruby installation, as follows:
gem install cucumber gem install rspec
How to do it...
In Capybara, we need to create a features file for the stories under test. These stories are written in Gherkin language with the Given
, When
, and Then
structures in Cucumber format. Perform the following steps to create a feature and step definition file with Capybara:
Create a plain text file named
BmiCalculate.feature
, as...