Data Driven Framework in Selenium

knoldus 651 views 20 slides Jul 04, 2022
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

In this session, we will discuss the introduction to the Data-Driven Testing Framework in Selenium. We will take a look at the importance of the Data-Driven Testing framework and also the integration of Apache POI and TestNg with the help of a demonstration.


Slide Content

Presented By : Anshita Mathur
QA Consultant
Data Driven Framework
in Selenium

Lack of etiquette and manners is a huge turn off.

KnolX Etiquettes
Punctuality
Respect Knolx session timings, you
are requested not to join sessions
after a 5 minutes threshold post
the session start time.
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Mute
Please keep your window on mute
Avoid Disturbance
Avoid leaving your window
unmuted after asking a question

Agenda
01What is Data Driven Framework ?
02Advantages of using DDT
04Use of TestNG in DDT
What is Apache POI library03
05Demo

What is Data Driven Framework ?

●Data Driven Framework is a testing strategy in which the data set under test, is stored separately from the test script
●It is used to drive test cases and suites from an external data feed. The data feed can be data sheets like xls, xlsx, and csv
files
●To read or write an Excel, Apache provides a very famous library POI
● This library is capable enough to read and write both XLS and XLSX file format of Excel
●Data Driven Testing is also known as parameterized testing or table driven testing
●The TestNG framework helps us with a parameterization feature in which we can parameterize different test values and
even keep our test data separate from our test scripts

There are two ways by which we can achieve parameterization in TestNG and they are as follows:
●With the help of Parameters annotation and TestNG XML file
@Parameters({“name”, “searchKey”})
● With the help of DataProvider annotation
@DataProvider(name= “searchProvider”)

Why Data Driven Testing ?
➔Testers frequently have multiple data sets for a single test
➔Data driven testing helps keeping data separate from test scripts
➔The same test scripts can be executed for different combinations of inputs
➔Test data maintenance involving lot of human resources with lot of time and manual efforts

For Example:

Benefits of using the Data Driven Testing Framework
➔Automation Testing is driven by the data set under test
➔Same test script will work for different data sets
➔Faster Execution
➔Less Maintenance
➔Permits better error handling

Selenium Webdriver + Apache POI
●Selenium Webdriver does not support read and write operations on excel files, but it can be supported with the
integration of third party tool i.e Apache POI
●Apache POI is an open source library to work with Microsoft Documents

Integrating Selenium Webdriver and Apache POI
1.Using Maven:
●Go to IDE and create a project
●Add the required dependencies for Apache POI



2. Using Jars:
●Go to poi.apache.org
●Download the Jar file
●Add this jar file in your project directory

Integrating Selenium Webdriver and Apache POI
Add these Apache POI Dependencies in pom.xml file:

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>

“The coordination between the main code and data set will be taken care by TestNG Data Providers, which is a
library that comes as a part of the Apache POI files.”

TestNG
●TestNG is the framework created for executing unit tests and it is also used by the software testers to efficiently run
the automated test scripts created in Selenium Webdriver
●TestNG allows users to perform data-driven testing
●This testing allows users to execute the same test multiple times with multiple sets of data.

Data Driven Testing using @DataProvider
●TestNG supports two ways for passing parameters directly to our Test Methods.
●We can pass parameters through Data Providers or an xml File.
●To achieve the data-driven testing, DataProvider feature is used.
●DataProvider is a data feeder method that executes the test method with multiple sets of data.
●Similar to TestNG Parameters, DataProviders are a means to pass data to test scripts in TestNG.
●Using DataProvider in TestNG, we can easily inject multiple values into the same test case.
●It comes inbuilt in TestNG and is popularly used in data-driven frameworks.

Add TestNG in your Project
●Add the TestNG Dependency in pom.xml file:

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<scope>test</scope>
</dependency>

●Or, we can add Jar file in project directory.

Types of MS Excel files

Demo

QA

Thank You !