-
Book Overview & Buying
-
Table Of Contents
Selenium Testing Tools Cookbook
By :
We saw a simple data-driven test using JUnit and TestNG. The test data was hardcoded in test script code. This could become difficult to maintain. It is recommended that we store the test data separately from the test scripts.
Often we use data from the production environment for testing. This data can be exported in CSV format. We can read CSV files using Java IO and utility classes and can pass the data from these files to the test code.

In this recipe, we will read data from a CSV file and use this data to execute the test script.
Set up a new project and add JUnit4 to the project's build path. You can set up the project in an IDE of your choice.
Create the CSV file with the required data.
Let's implement a parameterized test with CSV, using the following steps:
Create a test class with the name CsvTestData. Make it a parameterized class by adding the @RunWith attribute.
import org.openqa.selenium.firefox.FirefoxDriver...
Change the font size
Change margin width
Change background colour