Create data driven framework in selenium webdriver in easy way

Today in this article we will mainly discuss how to implement data driven framework in selenium webdriver using TestNG data provider.Data driven framework in selenium webdriver

We have so many frameworks like Keyword driven framework, Hybrid  Framework, POM that is Page object model and data driven framework, each framework having its own feature so we need to decide which framework to choose for this project.

I created Youtube Video for the same 

 

 

 

Data driven framework in selenium webdriver

this framework purely depends on data and data source can be anything like Excel file, CSV File, database.

In data driven framework script will be separated from Data part, it means so if any changes happen we do not have to modify all the test cases.

Example-

I have to create 50 Gmail accounts so I have two approaches to do this

First- I can create 50 scripts and run them.

Second- I can keep all data separate in the file and changes the data only that is required for script and script will be only one. In future, any changes in my application then I have to modify my one script only not fifty.

In simple words when we have to execute same script, multiple sets of data we will adopt data driven framework

In this post, we are taking data from 2D Array and feeding data into script

Scenario 1- Open Facebook and type username and password and login

this test case should run 2 times with different set of data(data we have provided in the 2D array)

Lest Implement the same

 

 

Data driven framework in selenium webdriver using Excel files

In above post, we have seen data driven using 2D array but once your test data will increase then you have to switch to Excel or CSV or Database.

Create some test data in Excel that we will pass to the script. For demo purpose, I have to take username and password in Excel.

 

Point to keep in mind before creating data driven framework in selenium webdriver

 

Before implement the program please make sure you are familiar with Reading Data from Excel.
Copy below program and before executing make sure following Thing configured correctly.

Eclipse, TestNG, JExcel jar
Scenario -Open Facebook and login with different username and password
username and password will be coming from excel sheet

Note- in below program we have 2 rows only so test case will execute 2 times with different data
package DataDrivenTesting;

 

I hope you have enjoyed the data driven framework in selenium webdriver and Hope you will implement the same. If you still have any doubt then let me know in the comment section. You can implement the same data driven framework using POM (Page Object model ) which will be the advanced version of data driven framework in selenium webdriver.

 

Kindly share this with your friends as well.