How to make our TestNG Selenium Framework Data-Driven

Manul Wickramanayaka
Test Automation Hub
5 min readJun 2, 2021

--

Topics to be covered

What is meant by Data-Driven?
Test Scenario
Setting up dependencies
Getting test data from excel
Creating Object Array
Use of TestNG @DataProvider

What is meant by Data-Driven?

A Data-Driven Framework in Selenium is a technique of separating the “data set” from the actual “test case” (code). Since the test case is separated from the data set, one can easily modify the test case of a particular functionality without making changes to the code. It is used to fetch test cases and suites from external files like Excel, .csv, .xml or some database tables.

In the article How to Read/Write Data from Excel File-Apache POI I have shown you how to read and write data in Excel files using Apache POI.

So to understand this concept let's continue the same scenario in the article.

Test Scenario

Here we are going to navigate to the site “www.saucedemo.com” which is going to be our test environment and enter the username and password as login information from our excel files then clicks…

--

--