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.
Create a Ruby test by importing the following modules:
from selenium import webdriver import csv, sys
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 = 0 test_failed = 0 test_status = True
Add the following code, which will iterate through the CSV data by reading each combination and then performing the operations and verifications:
try: #Create an instance of WebDriver for Firefox driver...