• What is Automation Testing - Advantages & Types of Tools
  • What is Selenium IDE, Selenium RC, Selenium WebDriver, Selenium Grid?
  • Selenium IDE, Firebug & Firepath Installation


  • Selenium WebDriver Architecture
  • Selenium Installation
  • Challenges and Limitations of Selenium
  • First Selenium WebDriver Script
  • Working with Firefox Browser
  • Solution - Failed To Launch Browser Using Selenium WebDriver
  • Working with Chrome Browser
  • Working with IE Browser
  • Difference Between FindElement & FindElements
  • Install Firebug, Fire path and other add on for Selenium
  • Locators in Selenium
  • Dynamic Xpath
  • Dynamic CSS
  • Handle drop-downs
  • How to work with file upload
  • Handle Alerts & Popups
  • Handle Multiple Windows
  • Mouse Hover event in Selenium
  • Right Click
  • Double Click
  • Drag and Drop
  • Capture Screenshots in Selenium
  • Parameterization
  • Synchronization
  • Implicit Wait, Explicit Wait and Fluent Wait in Selenium
  • Implicit Waits
  • Explicit WebDriver Waits
  • Fluent Wait In Selenium
  • Apache POI
  • How To Read Data From Excel File
  • How To Write Data In Excel File
  • Database Testing Using MSSQL
  • Database Testing Using MySQL
  • Database Testing Using DB2
  • Handle Ajax Call in Selenium
  • Listeners in Selenium
  • Handling JavaScript in Selenium
  • Stale Element Reference Exception in Selenium
  • Integrate Sikuli with Selenium
  • Headless Browser Testing 
  • Headless Browser Testing using HtmlUnitDriver
  • Headless Browser Testing using PhanthomJSDriver


  • TestNG Installation
  • TestNG Complete Tutorial


  • Extent Reports Introduction
  • Extent Reports Generation
  • Capturing Screenshots & Including In Extent Reports
  • Extent Reports Version 4


  • ANT Build Tool - How To Download & Install
  • Maven Build Tool - How To Download & Install
  • Creating Maven Selenium Project
  • GIT Integration with Selenium
  • Jenkins - How To Download & Install
  • Jenkins - Executing TestNG Scripts
  • Jenkins - Generating Reports After Test Execution
  • Jenkins - Executing Maven Project
  • Create build and Execute build for nightly execution
  • Send Email report based on build Status
  • Selenium Continuous Integration with Jenkins [Selenium – Maven – Git – Jenkins] – Step By Step Guide


  • Running Selenium Tests On BrowserStack
  • Kobiton - Mobile Testing Platform with Real Devices


  • Mobile Testing Platform with Real Devices


  • What is Framework & Types of Framework
  • Page Object Model Design Pattern
  • Data Driven Framework
  • How to explain Test Automation Framework or Selenium Automation Framework Architecture In Interview

  • API Testing:

  • Learn API Testing
  • Postman Tutorial (API Testing with Postman)


  • Test Automation Framework Interview Questions
  • Selenium Interview Questions
  • TestNG Interview Questions
  • Java Interview Questions
  • Python Interview Questions
  • API Testing Interview Questions


  • Automation Tester Resume
  • Data Driven Framework in Selenium WebDriver | Software Testing Material

    Data Driven Testing Framework in Selenium WebDriver

    In this post, I will show you how to implement Data Driven Framework in Selenium WebDriver using Apache POI and TestNG data provider. There are different types of test automation frameworks in the market such as Modular, Data Driven, Keyword Driven, Page Object Model (actually it’s a design pattern), Hybrid Framework. Each type of framework has its own features.

    Data Driven Testing Framework Architecture

    What is Data Driven Framework

    Data Driven framework is focused on separating the test scripts logic and the test data from each other. Allows us to create test automation scripts by passing different sets of test data. The test data set is kept in the external files or resources such as MS Excel Sheets, MS Access Tables, SQL Database, XML files etc., The test scripts connect to the external resources to get the test data. By using this framework we could easily make the test scripts work properly for different sets of test data. This framework significantly reduces the number of test scripts compared to a modular based framework.

    Why Data Driven Framework

    Usually, we place all our test data in excel sheets which we use in our test runs. Assume, we need to run a test script (Say, login test) with multiple test data. If we run the same test with multiple test data sets manually is time-consuming, and error-prone. In the next section, we see a practical example.

    In simple words, we adopt Data Driven Framework when we have to execute the same script with multiple sets of test data.

    Advantages of using Data Driven Test Framework

    • Re-usability of code
    • Improves test coverage
    • Faster Execution
    • Less maintenance
    • Permits better error handling

    What is Apache POI

    Apache POI is an open source library developed and distributed by Apache Software Foundation to design or modify Microsoft Office files using Java program. It is a popular API that allows working around excel files using Java Programs. In short, you can read and write MS Excel files using Java. Apache POI is your Java Excel solution.
    You’d use HSSF if you needed to read or write an Excel file using Java (XLS). You’d use XSSF if you need to read or write an OOXML Excel file using Java (XLSX). It has many predefined methods, classes, and interfaces.

    Learn more on Apache POI

    How to work on Data Driven Framework in Selenium Using Apache POI

    Selenium automates browsers. It’s a popular tool to automate web-based applications. To handle excel sheets to read and write data using Selenium we do use Apache POI.

    Assume, you need to test login form with 50 different sets of test data

    1. As a manual tester, you do log in with all the 50 different sets of test data for 50 times
    2. As an automation tester, you create a test script and run 50 times by changing the test data on each run or you create 50 test scripts to execute the scenario

    One of the reasons we take automation is to overcome the time consumption issue. By following the above two ways we don’t achieve anything with automation.

    Data Driven testing helps here and save a lot of time of us.

    How To Create Data Driven Framework in Selenium Using Apache POI

    Here I will take Facebook Application to showcase implementation of Data Driven Framework in Selenium with Java using Apache POI.

    Scenario: Open facebook page and do log in and log out.

    Must Read: Complete Selenium WebDriver Tutorial

    Follow below steps to Implement Data Driven framework.

    First, we see how to read test data from excel sheet and then we see how to write the result in the excel sheet.

    How To Read Data From Excel Sheet Using Apache POI

    Prerequisites to implement Data Driven Framework:

    1. Eclipse IDE
    2. TestNG
    3. Selenium jars
    4. Apache POI jars
    5. Microsoft Excel

    The structure of my project (Data Driven Project with Maven) is as follows:

    Data Driven Framework Project Structure

    Step 1: Open Eclipse and configure Apache POI jar files – Download Apache Jars

    Note: If you are using Maven Project then you could include the dependencies in the pom.xml

    Must Read: How to create Maven Project

    Step 2: Open Excel Sheet and create some test data. Here I have saved my excel sheet on my D Drive.

    Step 3: Create a Java Class under your Project

    Here I have created a Java Class “DataDrivenTest” under my Project “DataDrivenProject”

    Step 4: Here is a sample code to login to by getting the user credentials from excel sheet. Copy the below code and paste it in your Java Class.

    Step 5: Run your test script

    How To Write Data From Excel Sheet Using Apache POI

    Step 1: Follow step 1 as mentioned above

    Step 2: Here I have created another column as “Result” on my excel sheet which is on my D Drive.

    Step 3: Here is a sample code to login to by getting the user credentials from excel sheet and write the result in the excel sheet. Copy the below code and paste it in your Java Class.

    Step 4: Once it finished open the Excel file and check for the result.

    Data Driven Framework in Selenium WebDriver using TestNG Data Provider

    Scenario: Open Facebook and type username and password and login

    Below test script runs 2 times with different sets of test data.

    If you have any queries please comment below in the comments section.

    Page Object Model with Page Factory in Selenium – Complete Guide

    Here I have hand-picked few posts which will help you to learn some interesting stuff:

    Data Driven Framework Selenium WebDriver

    Get our latest blog posts delivered to your inbox

    Subscribe and get popular blog posts about software testing industry.


    8 thoughts on “Data Driven Framework in Selenium WebDriver | Software Testing Material”

    1. Sir do you have any video on Appium testing

    2. what is exactly difference between keydriven framework and data driven framework.

      • Hi Ramnaidu, refer this link

    3. I am not getting dependency for this XSSFWorkbook anywhere.Can you please help.I have added latest apache poi 3.17 dependency but XSSFWorkbook not present in this.

      • Hi Sanjeet,

        Try to add the below code in your pom.xml file



        Replace @ with < in the above code Thanks, Rajkumar

    4. Hello
      I saw your code for data driven testing using excel file in TestNG. You created object array. but If we have 50 sets of data, it is hard to create 5o object. So could please pass the code using excel file in testNG ?I have not found the code in web. I hope you will provide the code

    5. Your explanation is good

    6. Hey Raj, your block is too good for the learners, I really appreciate your help and support.

      Raj, you gave a good example on @Dataprovider and how to use it in Data Driven Framework (by taking ‘Test Data’ in the class level itself (last example)).

      Can please tell me how to grab the details from the external source (Excel) using @dataprovider annotation.for the same FB login page.??

    Leave a Comment

    Share via
    Copy link
    Powered by Social Snap