Our Engineers can Write as well

Testing Redefined: Try Out Data-driven Automation Framework

Many of you might think following guidelines is an “old book” method. I also don’t deny. However, I’d say you may reconsider your thought if that same old-fashioned process will yield you a number of benefits including reusing your testing codes. Yes, none of us wants to spend some coffee and brain over the same trouble over and over. Let me introduce the champ of this article: Data-driven Automation Framework.

Don’t get baffled by the term framework. As I said before, simply these are a set of guidelines and we collectively call them as a framework. In data-driven automated testing, you create the Test Data set in a separate Excel sheet. Sounds interesting, right? Then you can easily import the data into your automation testing tools and feed to the software application under test.

So What’s Unique Here?

The Test Scripts retain the test case logic, while the Test Data is disparate and present outside. External files save this Test Data (for example: Excel files, CSV files, Text files, DAO objects, ODBC sources, ADO objects), and these can be loaded into the variables inside the Test Script.

Let’s take an example to see how we can make use of data-driven framework in automated web testing or automated mobile testing. The client informed you that Test Data is the login credentials of users registering in their website. Let me tell you how to develop your script by just following 3 simple steps, leveraging the data-driven testing framework.

Before we dive into the recipe, let’s ensure we’re all set with our major ingredients. Yes, you guessed right My hobbies include cooking as well… Back to the point, here is the list you should keep ready before starting automation scripting:

  • Apache POI
  • Jar file (standalone)
  • Eclipse
  • Excel file (csv, xml, etc.) with Test Data

1.Click http://poi.apache.org/download.html and download the yellow-highlighted artifact.

dynamic framework apache poi

2.Extract the zip file and add the below JAR files together.

dynamic framework jar files

3.In the Eclipse, right-click the Project Name -> Build Path -> Configure Build Path -> Select the Libraries tab, click Add External JARs…, and add all the above files.

dynamic framework build path

4.Create a class with a main function; inspect the form Web elements; and start preparing the scripts with the help of locators.

Step 2:

Prepare the Test Data file with client-provided login credentials.

dynamic test data file
Step 3:
  • Initialize the Excel File Path

FileInputStream file = new FileInputStream(“E:\\sheets\\portal1.xls”);

It represents the path of the Excel file in Local.

  • Workbook

HSSFWorkbook work = new HSSFWorkbook(file);

It represents the workbook in the Excel file.

  • Sheet

HSSFSheet sheet = new HSSFSheet(work);

Sample Code:

FileInputStream file = new FileInputStream(“E:\\sheets\\portal1.xls”);
HSSFWorkbook work = new HSSFWorkbook(file);
HSSFSheet sheet = work.getSheet(“Sheet”);
int rownum = sheet.getLastRowNum()+1;
int columnum = work.getRow(0).getLastCellNum();
String[][] data = new String[(rownum-1)][columnum];
int k = 0;
for (int i=1; i<rownum; i++)
HSSFRow row = work.getRow(i);
for (int j=0; j<columnum; j++)
HSSFCell cell = row.getCell(j);
String value = cellToString(cell);
data[k][j] = value;
System.out.println(“the value is ” + value);
return data;

private String cellToString(HSSFCell cell) {
Object result;
long i=(long)cell.getNumericCellValue();
return (String) result;

In the above code, the HSSFRow and HSSFCell will fetch the respective rows and columns accordingly.


  • Re-use of Code, leading to increased efficiency and faster execution
  • Test Data remains unaltered, in spite of changes in Test Scripts
  • Possibility to test a variety of test scenarios, by just varying the Test Data in external file


  • Long Prep time to plan both Test Scripts and Test Data

Contributed by:

Technical Lead

Your email address will not be published. Required fields are marked *