What is Data Driven Testing? Example of Selenium Framework

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated May 9, 2025

In this tutorial, we will discuss Data Driven Testing in an extensive manner.  We include what it is, how it works, pros & cons, etc. Let’s get started. 

Often, there are a number of data sets that we have to run the same tests on. Also, creating a different test for each data set value is time-consuming and inefficient.

Data Driven Testing helps to overcome this issue by keeping the data external to functional tests and loading them when there is a need to extend the automation tests.

How does Data Driven Testing Work

what is Data driven testing

What Is Data-Driven Testing

Data Driven Testing is a test design and execution strategy where the test scripts read test data from data sources (files or databases) such as ADO objects, ODBC sources, CSV files, etc. rather than using hard-coded values.

The setup and control of the test environment in this process is not hard coded.

what is DDT

Also read => Most Popular Test Automation Frameworks

Data Driven Script

Data-Driven Scripts can be defined as those application-specific scripts (like JavaScript) coded and modified to accommodate variable datasets.

Some of the features of Data-Driven Scripts are:

  1. Identification of Variable Data and Hard Coded Components: When Test scripts contain hard coded components, they break with the application’s changes. Therefore, find ways to incorporate variable data. However, not everything can be variable, so a data-driven script often consists of both variable and hard coded areas. Ability for automation testers to design scripts with the right balance of both.
  2. Duplicate Test Design: In Data Driven Scripts, all application designs are developed using scripting language. This is duplicated in both manual and automated test scripts for synced up references for both automation and manual testers.

Keyword Driven Test Automation

Keyword Driven Test Automation is often known as Table Driven Test Automation. This is an application independent automation framework where tests are developed in the form of a data table using keywords.

Some features of Keyword Driven Test Automation are:

  1. Reusable Code, Error Correction, and Synchronization: Application Independent Components constructed accept application specific data. These components can be reused for all applications to be tested.
  2. All in One Record: All in One Record refers to actions to be performed, the expected results and actual results.

Hybrid Test Automation

Hybrid Test Automation Framework is a combination of Data Driven and Keyword Driven Automation Frameworks.

Hybrid Test Automation

An Example of DDT

Let us see an example for Data Driven Testing. Consider the Login Page of the Flight Reservation website.

1) A test data file is created as TestData.csv (Comma Separated Values)

2) This file contains inputs given to the driver script and expected results shown in the table below;

data file

3) The driver script for the above data file will be,

data = open(‘TestData.csv’).read()
lines = data.splitlines()

4) Steps performed for the above driver scripts are as follows;

  • Read Value1
  • Read Value2
  • Read Operator

5) Calculate the results using an operator on Value1 and value2

6) Finally, compare the expected result with the actual result

Data Driven Framework In QTP

To create a Data Driven Framework in QTP, the following components are required:

  • Test Script and Object Repository: For reading data and applying it to the AUT from external sources
  • External Data Source: Contains test data required for test scripts to run.

QTP supports the following data sources

  • Excel Files
  • Text Files
  • XML Files
  • Databases

These are 3 methods to create Data Driven Framework in QTP:

  • Method 1 uses QTP and Data table where all data in QTP is saved and retrieved from data tables.
  • Method 2 uses QTP, Data table and Excel files where QTP copies data from Excel files to the data table and uses built-in method to access data in the data table.
  • Method 3 uses QTP and Excel files where all data is saved in Excel files and QTP reads data directly from Excel files using built-in methods.

=> Learn more about Data Driven framework in QTP with examples


Selenium Webdriver Data Driven Framework

1) Selenium Webdriver Data Driven Framework takes test input and output from ODBC sources, CVS files and Excel files.

2) The framework includes navigation through a program, reading the data files and logging test status.

3) The framework should have the following features:

  • Less time to test large data sets
  • Easier, rapid and efficient analysis
  • Easy debugging
  • Well defined architectural design
  • Robust, stable and reliable
  • Easy Script Maintenance
  • Script execution in multiple test environments

=> Read this article to learn more about the Data Driven Framework in Selenium with examples.

Creating Data Driven Tests using TestNG

1) TestNG is a framework that makes Data Driven Automation Testing possible in Selenium.

2) Created with Junit with added features to perform regression automation testing

3) TestNG is a popular and widely used framework with Selenium Webdriver

4) It has some additional key features such as parameterization, parallel test execution etc and requires JDK 7 or higher

5) Some of the cool features of TestNG that make it easier and efficient are:

  • Annotations
  • Flexible Test Configuration
  • Default JDK functions
  • Supported by a variety of tools and plug-ins
  • Support for parameters
  • Support for Data-Driven testing using DataProviders
  • Powerful and safe Execution Model
  • Used to perform all categories of testing

6) DataProviders is a data feeder method which is defined in a class that provides test methods and test data

Advantages of Data-Driven Testing

  1. Possibility of creating Test scripts at the development stage of an application
  2. Redundancy and unnecessary duplication of test scripts are reduced
  3. Generate test scripts with less code amount
  4. All information like inputs, outputs, and the expected results are stored in the form of appropriately managed text records
  5. Provides flexibility in application maintenance

Disadvantages of Data Driven Testing

  1. Requires great expertise in scripting language
  2. Requires a large no. of data files for each test case with many inputs
  3. In order to create a new test case it requires a new driver script with different data such that the changes made to the test case should reflect in the driver script or vice versa

Also read => How to Perform Data Driven Testing using SoapUI

Conclusion

Data Driven Testing helps automated tests to run rapidly over an application with different input data and also provides a lot of coverage to ensure the performance of an application. Data Driven Testing also enhances business intelligence by reducing risks, increasing ease of accessing and sharing information with real-time analysis.

It speeds up the decision-making process and in turn rapid automation testing. Quick navigation through data sets is also an important feature offered by Data Driven Testing reduces testing timelines for an AUT.

About the Author: Sanjay Zalavadia – as the VP of Client Service for Zephyr, Sanjay brings over 15 years of leadership experience in IT and Technical Support Services. Throughout his career, he has successfully established and grown premier IT and Support Services teams across multiple geographies for both large and small companies.

We hope you liked reading this article. Let us know in the comments section below if you have any queries or feedback about the Data Driven testing strategy. We would love to hear from you. 

Was this helpful?

Thanks for your feedback!

Recommended Reading

  • Data Driven Framework in Selenium using Apache POI

    How to work on Data Driven Framework in Selenium Using Apache POI? Data Driven Framework is one of the most popular Automation Testing Frameworks in the current market. Data Driven automated testing is a method in which the test data set is created in the excel sheet, and is then…

  • PARAMETERIZED TESTING

    Explore the Ways of Writing Data-driven or Parameterized Tests with the Spock Framework: In this Free Spock Training Tutorial Series, we explored all about Unit Testing in Spock and Test fixtures, Assertions and Reporting in our previous tutorial. In this tutorial, we will try to understand what parameterized tests are…

  • Using SoapUI Pro for Data Driven Testing

    In this article, we will learn in detail how to perform data driven testing in SoapUI Pro. Let's get started. In this SoapUI Pro tutorial, we are going to see Data Driven Testing using SoapUI Pro. Performing load testing and performance testing with huge amounts of data is often time-to-consumer.…

  • Keyword Driven Framework In Selenium

    This Comprehensive Tutorial on Keyword Driven Framework Explains Various Components of the Framework & How to Create One in Selenium: In general, Framework is a set of guidelines, which when followed will give beneficial results. The Keyword-Driven framework is a technique to externalize keywords/actions that are used in the script…


READ MORE FROM THIS SERIES:



5 thoughts on “What is Data Driven Testing? Example of Selenium Framework”

  1. Thanks for this. It explains nicely how keyword driven framework works.

    It’s better if you can link this post with example of selenium/QTP where you might have implemented this (in your selenium tutorial series)

    Reply

Leave a Comment