Creating a data-driven test in Ruby using Roo
In the previous recipes, we saw parameterization with Java and .NET; Ruby also has been used widely to create Selenium WebDriver tests.
Again, Ruby does not have its own way to parameterize the script. However, we can use the Roo (http://roo.rubyforge.org/) gem in Ruby to read spreadsheets. Roo supports multiple formats as follows:
A locally stored Excel (
.xls
) fileA locally stored OpenOffice (
.ods
) fileAn Excel file (
.xls
) stored in a Confluence wiki page with Confluence Office ConnectorA Google Docs spreadsheet
Roo is a great alternative to the Ruby Excel COM WIN32 API, as it does not need Excel or OpenOffice installed on the machine. It reads both these files natively.
In this recipe, we will parameterize the Selenium WebDriver test created in Ruby bindings, using an Excel spreadsheet as a test data source.
Getting ready
You need to install the Roo gem by using the following command:
gem install roo
This command will download and install all the...