Book Image

Selenium Testing Tools Cookbook Second Edition

By : UNMESH GUNDECHA
5 (1)
Book Image

Selenium Testing Tools Cookbook Second Edition

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 (16 chapters)
15
Index

Creating a data-driven test in Ruby using Roo


In the previous recipes, we saw parameterization with Java and .NET. Ruby has also 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) file

  • A locally stored OpenOffice (.ods) file

  • An Excel file (.xls) stored in a Confluence wiki page with Confluence Office Connector

  • A 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 using the following command:

gem install roo

This command will download and install all the dependencies...