Book Image

Selenium Testing Tools Cookbook

By : UNMESH GUNDECHA
5 (1)
Book Image

Selenium Testing Tools Cookbook

5 (1)
By: UNMESH GUNDECHA

Overview of this book

This book is an incremental guide that will help you learn and use the advanced features of the Selenium toolset including the WebDriver API in various situations to build a reliable test automation. You start off by setting up the test development environment and gain tips on the advanced locater strategy and the effective use of the Selenium WebDriver API. After that, the use of design patterns such as data - driven tests and PageFactory are demonstrated. You will then be familiarised with extending Selenium WebDriver API by implementing custom tasks and setting up your own distributed environment to run tests in parallel for cross-browser testing. Finally, we give you some tips on integrating Selenium WebDriver with other popular tools and testing mobile applications. By the end of this book, you will have learned enough to solve complex testing issues on your own.
Table of Contents (21 chapters)
Selenium Testing Tools Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 the BMI Calculator application.

Getting ready

  1. You need to install Capybara Gem by using the following command:

    gem install capybara
    
  2. 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 the Gherkin language with the Given, When, and Then structures in the Cucumber format. Perform the following steps to create a feature and step definition file with Capybara:

  1. Create a plain text file named BmiCalculate...