Data Driven Testing(DDT) using selenium

0 Comments

Data Driven Testing(DDT) using selenium

 

Data Driven Framework is widely using in the market for Automation Testing in the current market. In the Data Driven automated testing approach we make the test data set in the excel sheet, and that file imported into integrated development kit to feed to the software under test.

                

A Test Automation framework is a set of assumptions, concepts, and practices that provide support for automated software testing. This is an execution environment for automated tests. Framework empowers testers to write valuable tests that are reusable, maintainable, scalable and resilient across all the browsers. Once the framework is created it can be used across the projects in an organization with few changes in configuration, test data & object repository. It helps in fast execution with minimal human intervention. A nontechnical user can write scripts with proper documentation.

 

Let’s take a look of some famous testing framework.

 

Functionality of Data Driven Test

To test a functionality we need to create 100 of test cases including positive and negative.

DDT import an excel in an automated testing tool and execute the test cases one by one.

Suppose we need to test the login page which contains multiple input fields with 100 different data sets.

To test this you have to follow below approach:

Create 100 scripts one for each dataset and execute each test one by one.

Import the data from the excel sheet and execute the script multiple times with different data.

It is imported from and used to test the features of the application.

 

 

In this article, we will see how to automate the test scenario of login page of http://www.way2automation.com/angularjs-protractor/banking/#/login with the Data-Driven framework.

 

Prerequisites

  • Eclipse IDE

  • Java

  • TestNG

  • Install Maven in eclipse

  • Firefox browser

  • Selenium Webdriver (supports all major browsers. We will use Firefox, Chrome, and IE)

  • Apache POI to perform operations with excel like read, write and update excel sheet

Apache POI

Apache POI (Poor Obfuscation Implementation) is an API written in Java to support read and write operations – modifying office files. This is the most common API used for Selenium data driven tests.One of the most remarkable features of Apache POI is that it supports read and write operations on both .xls and .xslx files.

We need to copy the below dependencies and paste it into our pom.xml .

Screen Shot 2017-11-02 at 5.48.00 PM.png

 

Screen Shot 2017-11-02 at 5.48.13 PM.png

 

 

Steps for Admin Login

 

i) Launch the Browser

ii) Navigate to http://www.way2automation.com/angularjs-protractor/banking/#/login

iii) Click on Bank Manager Login button

 

Getting Started

 

Data Driven framework is used to drive the test cases and suite from an external file. The data feed can be data sheets like xls, xlsx, and csv files.

 

Step 1: Create the test data with which we would be executing the test scripts.

Step 2: Download JAR files of Apache POI and Add Jars to your project library.  Let us create an excel file and save it as “testdata.xlsx” and place it in the created package location.

We will use the data excel file and the file looks as below

 

Step 3: Now follow the below code to read data from the excel sheet and use it to login to http://www.way2automation.com/angularjs-protractor/banking/#/login

 

External Files which has to be imported :-

Configuration File(Config.properties) :-

#

testsiteurl=http://www.way2automation.com/angularjs-protractor/banking/#/login

browser=chrome

env=uat

implicit.wait=10

explicit.wait =5

Object Repository File(OR.properties) :-

#Login Test

username = .//*[@id='identifierId']

nextBtn = .//*[@id='identifierNext']/content/span

password = .//*[@id='password']/div[1]/div/div[1]/input

 

#Bank Manager Login test

bmlBtn_CSS=.btn.btn-primary.btn-lg[ng-click='manager()']

addCustBtn_CSS=button[ng-class='btnClass1']

firstName_CSS=.form-control.ng-pristine.ng-invalid.ng-invalid-required.ng-touched

lastName=.form-control.ng-pristine.ng-untouched.ng-invalid.ng-invalid-required[placeholder='Last Name']

postCode=.form-control.ng-pristine.ng-untouched.ng-invalid.ng-invalid-required[placeholder='Post Code']

}

Step 4: Right click on the test case class and click on Run as –> TestNG Test.

Note: If you encounter any problems during this process, please check the following points.

  • Make sure all the mentioned jars are added to the project and are properly configured.

  • Required software is correctly installed.

  • Proper use of an interface with respect to excel file, like HSSF for .xls and XSSF for .xlsx.

  • Valid row and column index is used.

  • Excel file must be closed before execution.

  • Proper classes used for the excel file like XSSF used for .xlsx files and HSSF used for .xls files.

PROJECT CODE:

Comments

WRITE A COMMENT