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.
Table of Contents:
How does Data Driven Testing Work

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.

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:
- 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.
- 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:
- 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.
- 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.

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;

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
- Possibility of creating Test scripts at the development stage of an application
- Redundancy and unnecessary duplication of test scripts are reduced
- Generate test scripts with less code amount
- All information like inputs, outputs, and the expected results are stored in the form of appropriately managed text records
- Provides flexibility in application maintenance
Disadvantages of Data Driven Testing
- Requires great expertise in scripting language
- Requires a large no. of data files for each test case with many inputs
- 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.







Can i do Data Driven Testing using selenium ide ?
Selenium-based web automation that is driven by data is very powerful, but can be a hassle to design.
Sahi Pro also provides a strong way to run data driven suites. Feel free to read about it here: http://sahipro.com/docs/using-sahi/data-driven-suites.html
Or download Sahi Pro (www.sahipro.com) and try it for yourself!
Thank u sir for providing this information………plsss provide the card testing information also.
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)