Вы находитесь на странице: 1из 20
G A R e d d y @ O n e T e s t
G A R e d d y @ O n e T e s t
G A R e d d y @ O n e T e s t i n g C e n t e r
w w w . O n e T e s t i n g C e n t e r . c o m

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com GAReddy @ OneTestingCenter @ QTP www.OneTestingCenter.com GAReddy
GAReddy @ OneTestingCenter @ www.OneTestingCenter.com GAReddy @ OneTestingCenter @ QTP www.OneTestingCenter.com GAReddy
GAReddy @ OneTestingCenter @ www.OneTestingCenter.com GAReddy @ OneTestingCenter @ QTP www.OneTestingCenter.com GAReddy

GAReddy @ OneTestingCenter @ QTP www.OneTestingCenter.com

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

Document History

Designed by GAReddy @ OneTestingCenter www.OneTestingCenter.com

Table of Content

DOCUMENT HISTORY

2

1

PURPOSE OF THIS DOCUMENT

3

2

NEED FOR AUTOMATION FRAMEWORK

3

3

WHAT IS AN AUTOMATION FRAMEWORK

3

4

INTRODUCTION AND EXAMPLES

4

5

ARCHITECTURE AND DEMO

6

6

KEYWORD DRIVEN FRAMEWORK MAIN ELEMENTS-------------------------------6

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

1 Purpose of this document

How to design an Automation Framework and how to implement framework with regards to an Application is always a great puzzle. Let me put it simple here to explain you. I would cover how to plan, how to design and how to implement an Automation Framework. My approach gives you the overview, complete automation structure, most relevant features, advantages and full-fledged implementation of Automation Framework

2 Need for Automation Framework

With the FIVE major goals of Automation Framework (1) Rapid Design and Development (2) Most Reliable and Repeatable tests (3) Time Saving and Resource Saving (4) Easy and Fast Tests (Smoke , Functional and Regression Tests) (5) Low Maintenance and yet High Quality and Productivity Increase This Keyword Driven Framework (Designed by GAReddy@OneTestingCenter) proves and gives complete learning and implementation scope with the above points kept in mind. Hope, my friends, my students would enjoy reading this, learning this and implementing this.

3 What is an Automation Framework

0

Automation Framework is a well-structured, planned, practiced and supported environment for Automation Testing

0

It’s a warehouse where automation testing process begins, executes, accumulates results and ends up.

0

Automation Framework uses fully established implementation such as initiation, moderation, execution and finalization.

0

Automation Framework is the complete reference of the Automation Testing Process representing structure, process guidelines, and implementation and so on.

0

Test automation framework is a set of assumptions, concepts, and practices that provide support for automated software testing.

0

A comprehensive architecture to drive the complete test automation process.

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

4

Introduction

There are SEVEN different Frameworks available on the market these days. Each has got its own purpose and use. Let me list out them here.

Record and Play back Framework

Linear Framework

Simple Framework

Action Driven Framework

Data Driven Framework

Functional Decomposition Framework

Modularity Framework

Function Library Framework

Keyword Driven Framework

Table Driven Framework

Step Driven Framework

Hybrid Framework

Combination of two or more

Keyword + Data Driven

Functional + Data Driven

Test Driven Framework

Model Driven Framework

Out of all frameworks, the most important and all the testers who are very curious is about is Keyword Driven Framework and so let me talk about that and let me explain you in depth of Keyword Driven Framework.

Keyword Driven Framework developed by GAReddy @ OneTestingCenter is targeted to implement in Smoke, Functional and Regression tests. Keyword Driven Framework uses Keywords and GUI modeling concepts. Keyword Driven Framework has got a major purpose to go on and to test any Application for which the keywords are the base relevant tests that match as common.

Example:

If I design a script like below:

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com As we observe the above snap, it ’ s a simple

As we observe the above snap, its a simple and only one function. The function name is AppTest(). But then it’s very powerful, reusable and most needed function to test any Web Edit , any Web Button , any Link and any Image on any Application. On the first shot, the Web Edit and Web Button names are static (given as arguments / parameters on the function call and later on these are parameterized or keyword driven by means of the KEYWORD DRIVEN FRAMEWROK approach)

This helps us testing any Application that has any Web Edit , any Web Button , any Link and any Image on any Application. Of course, yes, the Web Edits and Web Buttons names keep changing but then I would be calling the same above function to test any kind of web edit ad web button. Down the line, we would use these Objects and keywords on excel and we would keep on passing these objects and object names as parameters to the same function repeatedly.

Look at the below chart:

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com A simple table but helps us to replace the objects based

A simple table but helps us to replace the objects based the test step we operate on the Application. And this is how, we would proceed to design and develop keyword driven tests and functional libraries to test the Application. And thus, the same keyword driven tests could reusable and repeatable for any tests and for any Application.

5 Framework Architecture

Test Plan The Plan, Complete document which explains the process, step by step implementation, guidelines,
Test Plan
The Plan, Complete document which explains the process, step by step
implementation, guidelines, structure and so.
Test Cases
Test Cases which are to be automated.
Test Cases which are part of Smoke / Functional / Regression tests
Pre-work to select manual test cases to be automated, should be done
Scenario Files
Application Module wise scenarios to be tested (contained in excel)
Test Results
For every test execution, the test results should be stored
For results tracking, results comparison
Test Scripts
Automated Test Scripts, which are designed of manual tests, should be
placed separately (like Smoke, Functional, Regression test types)
Object Repository
All AUT Objects
Shared Object Repository (mostly commonly used and shared repository)
App
Log files
Event Logs
Script Logs
Logs
Error Logs
Recovery
Scenarios
Events that interrupt the automation execution, Recovery Scenario tests
should be placed here.
Error Handling
Scripts that deal different possibilities of handling various run time errors
Test Data
Application Test Data which are to be submitted on APP (App test data
which are to be manipulated)
Common Library
Contains the common library files (Initiation, Clear Cache, BaseState )
Function Library
Contains the Application functional testing Library files (OpenApp,
Reservation, Login, Logout )
QTP@StartUp
Initiates QTP at first shot and thus invokes Driver Script for test run
DriverScript
Driver Script to drive the tests, to manage the tests,
iLIB
ScedularScript
Scheduler script to start and continue tests automatically on app based on
the time that is triggered.
VBScript
StrComp, InStr, Data Functions and so…
GenericScripts
Clear caches, close browsers, create objects, load files, imports, exports…
<Application> Automation

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

Automation Framework Architecture

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com Automation Framework Architecture GAReddy @ OneTestingCenter @ QTP
GAReddy @ OneTestingCenter @ www.OneTestingCenter.com Automation Framework Architecture GAReddy @ OneTestingCenter @ QTP
GAReddy @ OneTestingCenter @ www.OneTestingCenter.com Automation Framework Architecture GAReddy @ OneTestingCenter @ QTP

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com < Application > ApplicationMap Driver ErrorHandling LIB

<Application>

ApplicationMap@ www.OneTestingCenter.com < Application > Driver ErrorHandling LIB BusinessLogicLib FrameworkLib

Driver< Application > ApplicationMap ErrorHandling LIB BusinessLogicLib FrameworkLib

ErrorHandling< Application > ApplicationMap Driver LIB BusinessLogicLib FrameworkLib TestObjectLib

LIB< Application > ApplicationMap Driver ErrorHandling BusinessLogicLib FrameworkLib TestObjectLib ObjectRepository

BusinessLogicLibApplication > ApplicationMap Driver ErrorHandling LIB FrameworkLib TestObjectLib ObjectRepository GlobalOR

FrameworkLibApplicationMap Driver ErrorHandling LIB BusinessLogicLib TestObjectLib ObjectRepository GlobalOR TestResults

TestObjectLibDriver ErrorHandling LIB BusinessLogicLib FrameworkLib ObjectRepository GlobalOR TestResults ExcelResults

ObjectRepository

GlobalOR

TestResults

ExcelResults

HTMLReports

QTPResults

TestCases

TestPlan

TestData

RecoveryScenarios

TestData

EventLogs

ScenarioLogs

ErrorLogs

1. Application Map:

This contains the Application Map Excel, elaborating the application objects and objects information. Application Map excel contains the parent (Browser) and child (Page, Web Edit, Web Button….) objects.

Application Map can be developed in two ways

Method#1:

Create Object repository Convert OR into XML format Convert XML OR into Excel driven (Keyword) this could be done by script

Method#2:

Create an Excel with the below Structure Fill out the excel with Objects Information from the Application Use Descriptive Programing to create DP @ Object Repository Use Driver Script to read them and perform tests on Application

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

Consider the below snap:

This is an example for second method

the below snap: This is an example for second method Consider following Test Cases: o Open

Consider following Test Cases:

o

Open a Browser

o

Navigate to URL (URL=www.google.com)

o

Wait until complete page is loaded

o

Enter Invalid Email ID on Email Edit box

o

Enter Invalid Pwd on Password Edit box

o

Click on Sign in Button

o

Verify the Error Message for invalid Email ID and Pwd

o

Enter valid Email ID on Email Edit box

o

Enter valid Pwd on Password Edit box

o

Click on Sign in Button

o

Verify that the user should be logged in correctly.

o

Verify Page Title

o

Close the Browser

Here is the Application Map for the above test cases:

Here is the Application Map for the above test cases: Brief Explanation of above snap: Based

Brief Explanation of above snap:

Based on keyword contained in ObjectType such as Browser, Page, Web Edit, Web Button…the corresponding functions are called to create the Application Map Application Map is created by means of the Descriptive Programing.

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

Based on the keyword on the Activity column such as Navigate, Set, Click, Verify Property…the corresponding functions are called to test the application ( to perform actions=activities=methods on the application) Let me put the description of all columns used on the snap:

ParentObject Any object in QTP, is identified primarily by its PARENT and CHILD relationship. So ParentObject (or Browser) column contains the name of Parent Browser in which objects reside. ChildObject The Pages information (names, titles) are placed in this ChildObject Column ObjectType The Most important column where the Objects (which are uniquely separated by theier types) are placed here (Example: ObjectType = Web Edit / Web Button / Link / Image…) This is one of the columns where keywords are considered for descriptive programing based object repository (or Application Map) ObjectName This column contains the objects names on the Application This is useful for adding information / properties to the descriptive programing. Example: Object names could be like (a link having a name like “Home”, a web button having name like “Sign in” and so on…) Activity The Drilled out column, most needed column, which helps identifying actions to be performed on Application. Activity = Action = Method Click, Set, Activate, Sync, SetSecure and so on… ParamValue This column is intended for test data which is to be applied on Application

The Application Map:

The Application Map is one of the most critical items in this framework. Since the Application GUI is not stable enough, so as suggested ‘Application Map file’ concept has been implemented. Application Map is a .vbs file consisting subroutines that create runtime object by using Descriptive programming. With the use of application map file, creation of object repository step has been omitted.

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

Consider the below snippet of code for implementing an Application Map file concept

of code for implementing an Application Map file concept In above snap, of code, ApplicationMap function
of code for implementing an Application Map file concept In above snap, of code, ApplicationMap function
of code for implementing an Application Map file concept In above snap, of code, ApplicationMap function

In above snap, of code, ApplicationMap function accepts Object & Object name are used for Object Repository creation. Object Repository is in the form of Descriptive Programing. Initially Parent Objects i.e. Browser & Browser Page descriptions are created. And then, based on keyword in ObjectType column of Intermediate table, other objects are created using the Descriptive Programing

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

Once the objects has been created using Application Map, next step is to perform actions on the object to drive the test script forward.

Component Functions

Component Functions are those functions that perform specific tasks (such as set, click , navigate and so on…). And as part of these, I have continued creating “User Defined Functions” for specific purposes. In this automation framework various Component Functions for each type of object

(such as WebEdit, WebButton, WebElement, WebLink, etc

single .vbs file. Note: Component Functions are also called as Test Object Fucntions

)

have been clubbed in a

Consider the below snap of code for Component Functions.

a Consider the below snap of code for Component Functions. In above snap of code, the
a Consider the below snap of code for Component Functions. In above snap of code, the

In above snap of code, the Browser, Page & Object descriptions (derived from Application Map) have been passed as parameter to the Component function.

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

Apart from Object descriptions, the action which needs to be performed on these object along with parameter required to perform the action has also been passed. Expected value & user defined checkpoint message passed to these functions are in turn passed to “User defined Function” for further comparison with actual value derived in component function.

Example:

Just refer fnBrowser Function in above snap. In this function different actions (activities) like Invoke, navigate, Open, Close and so actions / activities / methods are done on the Application. And these activities are driven by the SELECT CASE <Activity>

And we can also add extra code to help for initial conditions; synchronizations apart from those above functions. And such functions are called as Support Functions

Driver Function

Driver Function (Driver LIB) (to drive the entire test process) After understanding the primary purpose of Application Map, Component Function, Support Function) let us now understand how the Driver Function drives the Application Map.

Let us first take look at the role of driver in driving the Application Map Function Driver in this framework is the QTP Script. Driver script processes tables listing Steps to execute. Driver reads each record from the DataTable and passes each Step to Application Map for the descriptive programing object repository which is used during test process.

Consider the below snap:

programing object repository which is used during test process. Consider the below snap: GAReddy @ OneTestingCenter

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

Role of all items in Test Automation Framework Main Driver mainly deals with the entire set up required before running the individual test scripts. The Driver Script consists of the following components, which are plug and play units. Data Tables: - The Data tables play crucial role in this framework. Data Tables could be two types here. Data Tables of QTP Data Tables of Excel OR We could also make use of data tables from Database servers (like SQL, Oracle ) I have used Excel Data tables which are imported into QTP and used here. Data Tables help designing manual test cases

Library Functions: - For reading data from Driver tables, Support Library Functions (that consist database handling functions, application verification functions, generic functios) are included in the Main Driver script. TestSettings.vbs:- The TestSettings.vbs in this framework is used to declare and define the variables which are not going to changes frequently e.g. schema name/ password for the main driver tables, the sequence list for the intermediate tables, etc. The idea being at any point of time, the script executor should not require to interfere the Main driver code. Initialization.vbs is also included in the Main Driver Script

Keyword Driven Framework Main Elements

1. Keywords Keywords could be anything but that should define the purpose, Keywords could give need for reusability, Keywords could establish bridge between Application and test script. Mostly Keywords are the methods / actions / activities that could relate Application objects through Automation tool to perform actions on. Keywords Example:

2. StartUp Script

o

Startup Script

o

Starts up QTP, starts executing test

o

Loads corresponding library files

o

Loads corresponding driver script (test script)

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

o Loads corresponding results paths

o Loads corresponding results paths 3. Driver Script  Driver script is the single

3.

Driver Script

Driver script is the single main script of the Driver Engine.

It iteratively traverses through the data of business scenario flow and calls the respective reusable scripts sequentially.

It also enables us to execute a reusable script any number of times in a particular data row of the variable test data sheet.

It also updates the database for execution results of a particular script run

4.

Function LIB

Functional Libraries help us to reuse them multiple times, at multiple places on multiple applications. Functional LIBs can be there ways

Business Functional LIB

Generic Functional LIB

Test Object Functional LIB

 Business Functional LIB  Generic Functional LIB  Test Object Functional LIB GAReddy @ OneTestingCenter

GAReddy @ OneTestingCenter @ QTP

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com 5. Exception Handling o Exceptions are conditions which stops

5. Exception Handling

o

Exceptions are conditions which stops test script execution

o

Exceptions might occur at any time during script execution

o

Exceptions in QTP can be handled by using any one of the following two methods

o

i) Recovery Scenarios

o

ii) On Error Resume Next statement

o

Recover Scenarios will be implemented on all the modules.

o

Recovery Scenarios can be defined using Recovery Scenario Manager in QTP.

o

Application specific Recovery Scenarios like recovery from security warning, unknown pop-ups etc will be defined using Recovery Scenario Manager.

o

On Error Resume Next

o

…Script ….

o

If err.number <>0 then

o

….error handling script / scenario

o

PrintLog Err.Number & Error.Description

o

End If

6. ObjectRepository

o

Object Repository acts as a translator between QTP script and the QTP Environment to work on AUT.

o

QTP stores information it learns about a Browser / Window or an object in object repository in the form of logical names and physical descriptions

o

Properties

o

Methods

o

When QTP runs a test, it uses the object repository to locate objects.

o

QTP reads an object description in the repository and then looks for an object with the same properties in the application under test.

o

Types of Object Repositories:

o

Per Action Object Repository

o

Shared Object Repository

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

7.

Results Results could be in four ways:

Text File Reporting (called as logs) Event Logs Script Logs Error Logs

Reporting (called as logs) Event Logs Script Logs Error Logs Excel Reporting Test Scenario Status Test

Excel Reporting Test Scenario Status Test Case Status Test Step Status

Logs Error Logs Excel Reporting Test Scenario Status Test Case Status Test Step Status GAReddy @

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

HTML Reporting Complete Test Reporting Every Step reporting

HTML Reporting Complete Test Reporting Every Step reporting QTP Results Reporting Reporter.ReportEvent reports Print

QTP Results Reporting Reporter.ReportEvent reports Print Reports

o

Results of the Automation Scripts will be reported using Reporter Utility object

o

Results are reported at test case level and at every important state of the application.

o

Syntax: Reporter.ReportEvent <status>,"Scenario/Case Name“ ,“Scenario/Case description”

o

Status can be either micpass or micfail or micdone or micwarning

o

Example: Reporter.ReportEvent micPass,"Login Scenario","Auditee Logged In Successfully”

o

Sample results snapshot that is reported using Reporter.ReportEvent statement is shown

o

We would also generate results in the form HTML Reports / Excel Reports / Text File reports

o

Example:

o

Test Case Status

o

Test Step Status

o

Event Logs

o

Script Logs

GAReddy @ OneTestingCenter @ www.OneTestingCenter.com

AOM AOM is Automation Object Model This AOM helps us to initialize QTP, make use of QTP utilities during execution time. AOM also helps us to run a batch tests (number of tests at a time) AOM also helps us to schedule our test execution by means of Task Scheduler AOM initiates QTP, starts execution, runs all tests one by one, accumulates the test results and stores them in result directory and at the end stops testing process by closing QTP.

and at the end stops testing process by closing QTP. Friends, Recapture all the things, I

Friends,

Recapture all the things, I have thought you. Start implementing one by one. Use all the learning. Do well.