O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a data-driven test in Python

Python is also a widely used language for building Selenium WebDriver tests. It offers various ways to parameterize tests.

In this recipe, we will parameterize a Selenium WebDriver test written in Python, using a CSV file.

How to do it...

Let's create a simple Python test for parameterization, using the following steps. This test will read test data from the CSV file used in the Reading test data from a CSV file using JUnit recipe earlier.

  1. Create a Ruby test by importing the following modules:
    from selenium import webdriver
    import csv, sys
  2. Declare the following variables to print a summary of the test combinations executed from the test data source:
    #Variables for Printing Test Summary test_executed = 0 test_passed ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required