Selenium Automation Testing: The Complete Guide!

Selenium Automation Testing

Data Driven Testing also called table-driven testing or selenium automation testing is parameterized software testing method. Data Driven testing allows the insertion of a single test script that can execute multiple tests on varied test data. In this case, we can feed data from external sources either excel sheets, database tables, XML, or even CSV files.

The image below explains the difference between the Normal framework and the Data Driven Automation Testing framework. When the data set is separated from the test scripts, the modifications to the functionality can be performed easily without interrupting the code and vice versa, reducing augmented time and confusion.

Why Selenium is a preferred tool for Automation testing?

Using QA Automation for Scale and cost effectiveness - Agile Soft Systems,  Inc
  1. Selenium Automation Testing enables testers to separate logic in test scripts from test data. So, modifications in test scripts do not affect the test data.
  2. Thereby ending up in the creation of unique data sets with parameters for different scenarios. Testers can save time and also reduce the cost of supplementing new test data every time.
  3. That said, for repeated scenarios, testers can keep the same data set while just altering the functionality-specific code.
  4. Data Driven Testing thus allows the reusing of actions and functions in different tests.
  5. Selenium Automation Testing allows testing with multiple sets of data using regression testing.
  6. The overall testing process results in the generation of extensive code. This code is flexible and easy to maintain and therefore adds value when large volumes of random test data are necessary.

In this article, we would like to write one of the most common scenarios which we encounter while working with Selenium. We also face this issue during framework development, which is getting data from external sources (data-driven testing). So let us understand the Data-driven testing In Selenium.

However, in this post, we are specifically going to discuss getting data from the excel sheet. Note that all these operations are going to be done with Selenium Core (JAR). And not with Selenium IDE. This is because Selenium IDE itself has a lot of limitations as shown below.

What are the limitations of Selenium IDE 

  • Using Conditional Statements
  • Using External Data
  • Logging
  • Exception handling
  • Reporting, etc.

But wait, what if we just need to store some of the application properties like Object Name, Application Window name, global properties, etc. Do we still need to use the data sources you are talking about?

Well, the answer is both Yes and No! Depending upon the complexity of your application, if your application has very few objects and their properties to be identified are very minimal, you can use “Property file” instead.

Sample code to read data from Sample file in JAVA

public void ReadProperty() throws IOException {
	  System.out.println("In Read Property....");
	  //Create Property Object
	  Properties p = new Properties();
            //Load the Property file available in same package
            //Give the propery name to access
	  String propName = p.getProperty("name");
            //Output the property value

When to do data driven testing in Selenium from Excel Sheet?

Now if your application becomes very complex and you rely on each and every data to be driven from external data sources, then you SHOULD use data sources like Excel, Database table, etc.

Here we are going to talk about driving data from Excel sheets using JXL (JAVA EXCEL API). You can read more about JXL from the site. However, for now, let’s consider JXL as an API to read and write data from Excel Sheets. We are going to use JXL’s Excel as our Data provider to read data from external data sources. There are some other APIs available to read and write data from excel sheets like POI-HSSF and POI-XSSF, but we are going to deal only with JXL here.

Before getting started with JXL coding, let’s get to know some basic steps of how to read data from an Excel sheet, below is the diagrammatic representation.


Selenium Automation Testing using JXL- explained!

Well, here is how the code started working with JXL.

Let’s go with the diagrammatic representation.

Step 1

import java.util.Date;
import jxl.*; 

Workbook workbook = Workbook.getWorkbook(new File("C:\data.xls"));

Step 2

Open worksheet

Sheet sheet = workbook.getSheet("sheet1");

We can also give the index of the sheet as

Sheet sheet = workbook.getSheet(0);

Step 3

Read the data from Excel Cell

String value = sheets.getCell(Column, Row).getContents();

Here Column is the column number and the row is the row number from the cell which you are interested to read data.

Step 4

Now close the worksheet


So, we hope that is pretty clear. There is more coming up in this blog post series where we will explain how to use JXL for data driven testing? We will walk you through the steps which have to be taken care of to make the framework a data driven framework?

If you are really curious about Selenium Automation Testing and wish to take your interest to the next level then we have a specially curated Selenium Automation Testing Course that any beginner can take up. Why not give it a try?

Get into professional, quality Product & Process development with hands-on software automation training. Master the in-demand skills like Selenium, Python, Java, Jenkins, Jmeter, API Testing, and more in this Certification Course and procure a 360-degree view of automation technology.

Have a query? Feel free to post them in the comments below!

Why don’t you leave us your contact and our experts will get back to you at the earliest.

Contact Form

By clicking 'Submit' you Agree to Guvi Terms & Conditions.

Our Learners Work at

Our Popular Course

Share this post

Author Bio


Our Live Classes

Learn Javascript, HTML, CSS, Java, Data Structure, MongoDB & more
Learn Python, Machine Learning, NLP, Tableau, PowerBI & more
Learn Selenium, Python, Java, Jenkins, Jmeter, API Testing & more
Learn Networking, Security Testing, IAM, Access Management & more

Hey wait, Don’t miss New Updates from GUVI!

Get Your Course Now

Related Articles