In this post, we are going to perform “Data Driven Test Using CSV File In Selenium WebDriver”. well, It’s a major requirement for any organization to use some sort of data driven approach. Reading test data from CSV file is one most common way in hybrid testing frameworks.
So in this example, let’s read data from CSV file to perform data driven software testing In selenium WebDriver.

In this tutorial, we are going to cover below points:

 

Let’s begin:

1. How to Setup OpenCSV library in a Project

In order to start the implementation of Data driven testing using CSV as your data source, we need to set up the environment first. For this reason, this tutorial will explain and help to set up the prerequisite and required dependencies in Eclipse.

Maven based Project:

If you are using Maven as the build tool for you project, use below mentioned dependency and add it into the POM file:

OR

If you are using standalone project then download the OpenCSV jar from this location and add it into your project’s class-path.

 

2. Prepare Test Data CSV

Create a CSV format Test data file that you are going to use in your test. Download TestDataCSV  as this we are using in this example.

 

3. How to implement Data Driven testing using CSV

Now, as you’ve added the dependency into the project and Test data CSV file is ready too, now, use the below code to perform data read through CSV.

 

Check below video to see the execution in progress:

 

That’s it. So easy to implement it.

Happy Learning!!!

4. Resources

Data Driven Approach – Elemental Selenium

Read Data From CSV In Selenium Webdriver...!!! Click To Tweet

Checkout other useful tutorials, take a look:

Rest Assured Tutorial

Apache HttpClient Tutorial