In this post, we are going to see how to “Read CSV Files In Selenium WebDriver”. well, It’s a common requirement for any organization to use some sort of data driven approach as part of Automation Testing Framework. Most often, Excel files are used for this purpose because of their extensibility but there could be a situation where Test Data is required to maintain in CSV formatted files instead of Excel sheets. 
So in this example, let’s read test data from a CSV file to perform data driven software testing in selenium WebDriver.

Read CSV Files In Selenium...!!! Click To Tweet

Check out: How to send GET, POST, PUT, PATCH and DELETE Requests using REST-assured

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

Let’s begin:

What is a CSV File

CSV stands for Comma Separated File. It is a tabular representation of data in a plain text format. Each data value is separated by a comma sign.

If you look at the below image, Each line depicts a row and each comma separate data value is a column. 

CSV File

Pre-requisites: How to Configure/Setup OpenCSV library in a Project & Prepare Test Data CSV file

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:



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

Now, as a second pre-requisite, Create a CSV format Test data file that you are going to use in our test. Download TestDataCSV  as we are using this in below example.

Read CSV Files in Selenium

Check below video to see the execution in progress:

That’s it. So easy to implement.

Happy Learning!!!


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