62
TEST AUTOMATION_FUNCTIONAL TESTING PCSR PC SURENDRA REDDY Page 1 Qtp INDEX: PAGE No: INTRODUCTION 5 WAYS OF TESTING MANUAL TESTING AUTOMATION TESTING DRAWBACKS OF MANUAL TESTING DRAWBACKS OF AUTOMATION TESTING INTRODUCTION TO AUTOMATION TESTING NEED OF AUTOMATION TESTING FRAMEWORK TO LEARN ANY AUTOMATED TOOL TYPES OF AUTOMATED TOOL HISTORY OF QTP BASICS OF QTP 7 ANATOMY OF QTP RECORD AND RUN SETTINGS RECORDINGS RECORDING MODES CONTEXT SENSITIVE ANALOG LOW LEVEL VB SCRIPT OBJECT REPOSITORY TYPES OF OBJECT REPOSITORIES LOCAL SHARED OPERATIONS ON OBJECT REPOSITORY OBJECT REPOSITORY MANAGER OPERATIONAL OVERVIEW OF RECORDING AND RUNNING OBJECT IDENTIFICATION SMART IDENTIFICATION OBJECT SPY TYPES OF OBJECTS RUN TIME OBJECTS TEST OBJECTS QTP LIFE CYCLE 17, 17, 17, 38, 29, 29 PHASE 1: TEST PLANNING PHASE 2: GENERATING THE BASIC TEST PHASE 3: ENHANCING THE TEST INSERTING THE CHECK POINTS INTRODUCTION OPERATIONAL OVERVIEW OF CHECK POINTS TYPES OF CHECK POINTS STANDARD BITMAP DATABASE TEXT TEXT AREA ACCESSIBILITY XML PAGE TABLE IMAGE

02 test automation functional testing (qtp)

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 1

Qtp

INDEX: PAGE No:

INTRODUCTION 5

WAYS OF TESTING

MANUAL TESTING

AUTOMATION TESTING

DRAWBACKS OF MANUAL TESTING

DRAWBACKS OF AUTOMATION TESTING

INTRODUCTION TO AUTOMATION TESTING

NEED OF AUTOMATION TESTING

FRAMEWORK TO LEARN ANY AUTOMATED TOOL

TYPES OF AUTOMATED TOOL

HISTORY OF QTP

BASICS OF QTP 7

ANATOMY OF QTP

RECORD AND RUN SETTINGS

RECORDINGS

RECORDING MODES

CONTEXT SENSITIVE

ANALOG

LOW LEVEL

VB SCRIPT

OBJECT REPOSITORY

TYPES OF OBJECT REPOSITORIES

LOCAL

SHARED

OPERATIONS ON OBJECT REPOSITORY

OBJECT REPOSITORY MANAGER

OPERATIONAL OVERVIEW OF RECORDING AND RUNNING

OBJECT IDENTIFICATION

SMART IDENTIFICATION

OBJECT SPY

TYPES OF OBJECTS

RUN TIME OBJECTS

TEST OBJECTS

QTP LIFE CYCLE 17, 17, 17, 38, 29, 29

PHASE 1: TEST PLANNING

PHASE 2: GENERATING THE BASIC TEST

PHASE 3: ENHANCING THE TEST

INSERTING THE CHECK POINTS

INTRODUCTION

OPERATIONAL OVERVIEW OF CHECK POINTS

TYPES OF CHECK POINTS

STANDARD

BITMAP

DATABASE

TEXT

TEXT AREA

ACCESSIBILITY

XML

PAGE

TABLE

IMAGE

Page 2: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 2

SYNCHRONIZING TEXT EXECUTION

DATA DRIVEN TESTING

PARAMETERIZATION

DIFFERENT WAYS OF PARAMETERIZATION

INSERTING OUTPUT VALUES

INTRODUCTION

OPERATIONAL OVERVIEW

TYPES OF OUTPUT VALUES

STANDARD

TEXT

TEXTAREA

DATABASE

XML

MEASURING TRANSACTIONS

START TRANSACTION

END TRANSACTION

INSERTING THE PROGRAMATIC STATEMENTS

OBJECT CALLS

CONDITION STATEMENTS

LOOPING STATEMENTS

COMMENTS

UTILITY OBJECT STATEMENTS

DEVELOPING THE SCRIPT STATEMENTS MANUALLY

FREQUENTLY USED METHODS

REAL TIME SCENARIOS TO USE METHODS

HOW TO DEVELOP SCRIPTS IN REAL TIME

WORKING WITH DATA TABLES

AVOIDING CHECKPOINTS IN REAL TIME

AVOIDING OUTPUT VALUES IN REAL TIME

CASE STUDIES

PHASE 4: DEBUGGING THE TEST

INTRODUCTION

BREAK POINTS

STEP INTO

STEP OUT

STEP OVER

DEBUG FROM STEP

RUN TO STEP

DEBUG VIEWER PANE

WATCH

VARIABLES

COMMAND

PHASE 5: TEST EXECUTION

NORMAL EXECUTION

BATCH EXECUTION

PHASE 6: RESULT ANALYSIS

ANALYZING THE RESULTS

IDENTIFYING THE DEFECTS

REPORTING MT-Notes

MANUAL DEFECT REPORTING

BUG TRACKING TOOL ORIENTED DEFECT REPORTING

INTEGRATION WITH QUALITY CENTER

Page 3: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 3

ACTIONS 33

INTRODUCTION

TYPES OF ACTIONS

NORMAL ACTIONS

REUSABLE ACTIONS

EXTERNAL ACTIONS

CREATING NEW ACTIONS

SPLITTING ACTIONS

RENAMING ACTIONS

WORKING WITH DATA TABLE ACTION SHEETS

WORKING WITH INPUT AND OUTPUT PARAMETERS

FUNCTIONS 32

NEED OF FUNCTIONS

CREATING USER DEFINED FUNCTIONS

WORKING WITH UDF’S

LIBRARIES 36

INTRODUCTION

CREATING LIBRARY FILES

ASSOCIATING LIBRARY FILES

ADDITIONAL CONCEPTS 59, 31, 59, 53

FILE SYSTEM OBJECT

ENVIRONMENT VARIABLES

DATABASE CONNECTIONS

MS ACCESS

SQL SERVER

ORACLE

CREATING LOG FILES

VIRTUAL OBJECT CONFIGURATION 56

RECOVERY SCENARIO MANAGER 29

INTRODUCTION

TYPES OF TRIGGER EVENTS

CREATING THE RECOVERY FILES

ASSOCIATING THE RECOVERY FILES

ERROR HANDLING

DESCRIPTIVE PROGRAMMING 60

INTRODUCTION

CREATING DESCRIPTIVE SCRIPTS

ADVANTAGES

REGULAR EXPRESSIONS 56

INTRODUCTION

ADVANTAGES OF REGULAR EXPRESSIONS

AUTOMATION OBJECT MODEL 58

INTRODUCTION

WORKING WITH AOM OBJECTS

ADVANTAGES

Page 4: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 4

DYNAMIC HANDLING OF OBJECT REPOSITORIES 58

FRAMEWORK IMPLIMENTATION 32

LINEAR

MODULAR

KEYWORD DRIVEN

HYBRID

DATA DRIVEN

FEATURES IN LATEST VERSION 61

WORKING WITH QUALITY CENTER QC-Notes

VB SCRIPT 38

VB SCRIPT LANGUAGE OVERVIEW

VARIABLES

CONSTRANTS

DATA TYPES

ARRAYS

STATEMENTS

CONDITIONAL STATEMENT

IF……..THEN

SELECT CASE

LOOPING STATEMENTS

FOR………..NEXT

DO…………WHILE

DO………….UNTIL

WHILE…...WEND

OTHER STATEMENTS

CALL

DIM

EXIT

WAIT

EXECUTE

OPTION EXPLICIT

SET

WITH

OPERATORS

ARTHEMATIC

COMPARISION

CONCATINATION

LOGICAL

PROCEDURES

SUB PROCEDURES

FUNCTION PROCEDURES

PRE DEFINED FUNCTIONS

DATA AND TIME

STRING

CONVERSION

TRIMMING

OTHER FUNCTIONS

PREPARED BY 62

PC SURENDRA REDDY

Page 5: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 5

QTP

WAYS OF TESTING:

There are 2 ways of Testing:

1. MANUAL TESTING

2. AUTOMATION TESTING

1. MANUAL TESTING: Manual Testing is a process, in which all the phases of STLC (Software Testing Life Cycle) like

Test planning, Test development, Test execution, Result analysis, Bug tracking and Reporting are accomplished

successfully and manually with Human efforts.

DRAWBACKS:

1. More no of human resources are required.

2. Time consuming.

3. Less accuracy.

4. Tiredness.

5. Simultaneous actions are almost impossible.

6. Repeating the same task again and again in same fashion is almost impossible.

2. AUTOMATION TESTING: Automation Testing is a process, in which all the drawbacks of Manual Testing are

addressed properly and provides speed and accuracy to the existing testing process.

DRAWBACKS:

1. Automated tools are expensive.

2. All the areas of the application can’t be tested successfully with the automated tools.

3. Lack of automation Testing experts.

Note: Automation Testing is not a replacement for Manual Testing, it is just continuation for Manual Testing.

Note: Automation Testing is recommended to be implemented only after the application has come to a stable stage.

AUTOMATED TOOLS: Automated tool is defined as an assistant of test engineer, which works based on the

instructions and information given by us and finally shows the result.

General framework to learn any automated tool:

1. How to give the instructions?

2. How to give the information?

3. How to use its recording facility?

4. How to use its replay facility (or) play facility?

5. How to use analyze facility?

Page 6: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 6

TYPES OF AUTOMATED TOOLS:

There are 2 types of BLACK BOX TESTING Automated Tools:

1. FUNCTIONAL TOOL (QTP)

2. PERFORMANCE TOOL (LOAD RUNNER)

Apart from these 2 tools the test engineer will use MANAGEMENT TOOL (QUALITY CENTER) for managing the

testing process.

QTP: QUICK TEST PROFESSIONAL.

Introduction of QTP:

Type of the Tool : Functional tool.

Company : Introduced by INTERACTIVE IN CORP. & taken over by HP in the year 2002.

Script language : VB Script (It can understand other scripting languages also).

Versions :

VERSION YEAR OF RELEASED

ASTRA 1998

5.0 2000

5.5 2001

6.0 2002

6.5 2003

8.0 2004

8.2 2005

9.0 2006 FEB

9.1 2007 JAN

9.2 2007 FEB

9.5 2008 JAN

Page 7: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 7

QTP taken by HP in the year 2002 from Mercury interactive in corporation.

WINRUNNER was the first tool of Mercury interactive in corp., all the objects of WINRUNNER are developed by

structured programming language. The script language used is the text Script Language.

To test the functionality of the application we use QTP.

TEST PANE – SCRIPT AREA.

FUNCTIONALITY TESTING: It is a type of testing in which one will perform testing the functionality of an application, functionality means behavior of the application.

ANATOMY OF QTP:

VB SCRIPT:

Syntax:

Complete HIERARCHY.OPERATION.”VALUE”

CLASS NAME(“OBJECT NAME”).-------------------.OERATION.”VALUE”

VbWindow(“emp”)VbEdit(“ename”).set”SURI”

VbWindow(“emp”)VbEdit(“eage”).set”26”

VbWindow(“emp”)VbEdit(“esal”).set”40,000”

VbWindow(“emp”)VbEdit(“edesig”).set”SE”

VbWindow(“emp”)VbButton(“submit”).CLICK

VB Script for standard Windows application:

Window(“emp”)WinEdit(“ename”).set”SURI”

Window(“emp”)WinEdit(“eage”).set”26”

Window(“emp”)WinEdit(“esal”).set”40,000”

Window(“emp”)WinEdit(“edesig”).set”SE”

Window(“emp”)WinButton(“submit”).CLICK

VB Script for Java application:

JavaWindow(“emp”)JavaEdit(“ename”).set”SURI”

JavaWindow(“emp”)JavaEdit(“eage”).set”26”

JavaWindow(“emp”)JavaEdit(“esal”).set”40,000”

JavaWindow(“emp”)JavaEdit(“edesig”).set”SE”

JavaWindow(“emp”)JavaButton(“submit”).CLICK

Page 8: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 8

VB Script for .NET application:

SWFWindow(“emp”)SWFEdit(“ename”).set”SURI”

SWFWindow(“emp”)SWFEdit(“eage”).set”26”

SWFWindow(“emp”)SWFEdit(“esal”).set”40,000”

SWFWindow(“emp”)SWFEdit(“edesig”).set”SE”

SWFWindow(“emp”)SWFButton(“submit”).CLICK

VB Script for WEB application:

Browser(“ie”)Page(“yahoo”).WebEdit(“user name”).set”SURI”

Browser(“ie”)Page(“yahoo”).WebEdit(“password”).set”surendra”

Browser(“ie”)Page(“yahool”).Webbutton(“login”).CLICK

Browser(“ie”)Page(“emp”).WebEdit(“ename”).set”SURI”

Browser(“ie”)Page(“emp”).WebEdit(“eage”).set”26”

Browser(“ie”)Page(“emp”).WebEdit(“esal”).set”40,000”

Browser(“ie”)Page(“emp”).WebEdit(“edesig”).set”SE”

Browser(“ie”)Page(“emp”).WebButton(“submit”).CLICK

Page 9: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 9

ADD INN MANAGER: Add inn manager is a feature provided by the QTP, which is used for making the QTP,

compatible with the desired environments.

Add inn manager will show the list of all available add inn’s, while opening the QTP, so that

one can select the desired add inn’s and make the QTP compatible with those environments. With the default

purchase of QTP, 3 built in add inn’s will be provided:

1. ACTIVE X

2. VISUAL BASIC

3. WEB

By default QTP will be always compatible with standard windows environment. Apart from the above add inn’s any

other add inn’s are required, one need to purchase them separately.

Note: HP people also provides single license for all the add inn’s.

PARTS OF QTP:

1. TEST PANE

2. ACTIVE SCREEN

3. DATA TABLE

4. DEBUG VIEWER PANE

5. INFORMATION PANE

6. MISSING RESOURCES PANE

7. TOOL OPTIONS

1. TEST PANE: Test pane is an area provided by the QTP, which is used for developing, viewing, and modifying the

test script.

Test pane shows the script in 2 views:

1. EXPERT VIEW

2. KEYWORD VIEW

1. EXPERT VIEW: Expert view shows the script in VB script format.

2. KEYWORD VIEW: Keyword view shows the script in graphical user interface, which is further divided into 4 parts:

1. ITEM

2. OPERATION

3. VALUE

4. DOCUMENTATION

Note: Any modifications done in one view will be reflected in the other view.

2. ACTIVE SCREEN: Active screen is an a area provided by QTP, which holds the snapshots related to each and every

recorded scripts statements and used for easily understanding and enhancing the scripts.

Page 10: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 10

RECORDING AND RUNNING:

OPERATIONAL OVERVIEW OF RECORDING: DURING RECORDING QTP WILL DO THE FOLLOWING:

1. It will generate the corresponding script statements related to the user actions.

2. It will store the required and related objects information in the object repository.

OPERATIONAL OVER VIEW OF RUNNING: DURING RUNNING QTP WILL DO THE FOLLOWING:

1. It will read the instruction (script statement) and understands, what action to be performed on which object.

2. It realizes that it needs some information to identify the object.

3. It will go for object repository and search for required information.

4. If at all the information is available, using that information, it will try to identify the object.

5. If at all the object is identified then it will perform action on it.

RECORD AND RUN SETTINGS:

It is a feature provided by QTP, which is used for making the QTP understand what exactly it need to do, and

how exactly it should behave during recording and running.

NAVIGATION:

a. Activate the menu item Automation.

b. Select the option RECORD and RUN settings.

c. Select the desired Environment tab.

d. Select the required Option.

e. Click on Apply and OK.

RECORDING MODES:

There are 3 types of Recording Modes:

1. NORMAL/CONTEXT SENSITIVE RECODING MODE.

2. ANALOG RECORDING MODE.

3. LOW LEVEL RECORDING MODE.

1. NORMAL RECORDING MODE:

It is used for recording the operations performed on the standard GUI objects in different contexts.

2. ANALOG RECORDING MODE:

This recording mode is used for recording continuous operations.

NAVIGATION:

a) Keep the tool under normal recording mode.

b) Activate the menu item automation.

c) Select the option analog recording.

d) Select one of the following options:

o Record relative to the screen.

o Record relative to the following window.

If at all second option is selected, specify the window title with the help of hand icon, click on start analog

record button.

Page 11: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 11

Ex: Following Script will be produced for Paint Brush depending upon the above Option selected:

Record relative to the screen: Desktop.Runanalog’Track1’

Record relative to the following window: Window(‘PAINT’).Runanalog’Track1’

Where as Track1 is the internal file used for recording the actions performed by the user. 3. LOW LEVEL RECORDING MODE:

It is a special recording mode provided by the QTP, which is used for recording at least some operations on

the non supported environments also.

Usually people avoid this mode, due to the following reasons:

a. All the operations can’t be recorded.

b. The script is not easily understandable and enhance able.

OBJECT REPOSITORY:

It is a storage place, where one can store the object information and it is also acts as an interface between

the Test Script and AUT (Application Under Test), In order to identify the objects during execution.

TYPES OF OBJECT REPOSITORY:

There are 2 types of Object Repositories:

1. LOCAL

2. SHARED

LOCAL REPOSITORY: For each and every action in a Test (SCRIPT FILE). One separate local repository will be created

and managed by QTP automatically. The information present in the local repository can be used by that action.

SHARED REPOSITORY: Whenever we feel that same common objects information need to shared by so many actions

present in the different Tests (SCRIPT FILE), then it is suggested to create a shared repository with that common

information and associate it to all required actions.

By doing like this the advantage is, if any modifications are required in future than it is very easy.

Note: We can associate one (or) more shared repositories to an action apart from its local repository.

NAVIGATION FOR CREATING SHARED REPOSITORY:

Activate the Menu item Resources.

Select the option Object Repository Manager.

Add the required objects information.

Click on SAVE.

Browse the desired location and SAVE with .TSR extension.

NAVIGATION FOR CREATING SHARED REPOSITORY WHENEVER THE INFORMATION ALREADY AVAILABLE IN THE LOCAL REPOSITORY:

Open the Object Repository.

Activate the Menu item File in Object Repository.

Select the option Export Local Objects.

Browse the desired location and SAVE with .TSR extension.

NAVIGATION FOR ASSOCIATING THE SHARED REPOSITORY TO AN ACTION:

Activate the Menu item Resources.

Page 12: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 12

Select the option Associate Repositories.

Add the required Repositories to the list.

Select the desired Repository in the list.

Select the desired Action.

Click on the Associate Button.

Click on OK.

NAVIGATION FOR MODIFYING THE INFORMATION IN THE SHARED REPOSITORY:

Activate the Menu item Resources.

Select the option Object Repository Manager.

Open the required Object Repository.

Do the required Modifications.

Click on SAVE.

Can you convert Local to Shared Repository?

A: It’s not converting from Local to Shared Repository, Its Copying of the objects from Local to Shared Repository

through Export Object Data from Object Repository File menu.

OPERATIONS ON OBJECT REPOSITORY:

1. NAVIGATION FOR ADDING THE OBJECTS:

Activate the Menu item Resources.

Select the option Object repository.

Click on Add Objects to Local.

Click on the title bar of the window.

Click on OK.

Select one of the following Options:

o Select objects only

o Default objects only

o All object types

o Selected object types

If at all the 4th option is selected, then select the desired types of objects, using select button.

Click on OK button.

2. NAVIGATION FOR DELETING THE OBJECTS:

Right click on the desired object in the Object Repository.

Select the option Delete by right clicking on it.

Confirm the deletion by clicking on YES.

3. NAVIGATION FOR RENAMING THE OBJECTS:

Right click on the desired object in the Object Repository.

Select the option Rename.

Specify the desired Name.

Page 13: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 13

4. NAVIGATION FOR UPDATING THE PROPERTIES LIST:

Select the desired object in the Object Repository.

Click on Add button.

Select the desired properties in the list.

Click on OK.

Select the desired properties in the list, which are to be removed.

Click on the Remove button.

5. NAVIGATION FOR UPDATING PROPERTIES VALUE:

Select the desired object in the Object Repository.

Select the desired property in the properties list.

Click on the ‘Configure the Value’ button.

Specify the desired Value.

Click on OK.

HIGHLIGHTING THE APPLICATION: This option is used for highlighting the corresponding object in the application,

upon selecting the object name in the Object Repository.

LOCATING THE REPOSITORY: This option is used for locating the object name in the Object Repository, upon

specifying the corresponding object in the application.

OBJECT IDENTIFICATION:

The object identification concept is based on 4 types of properties and an Ordinal Identifier.

One can specify a list of properties under Mandatory section, list of properties under

Assistive section, list of properties under the Base Filter section, list of properties under the Optional Filter section

and an Ordinal Identifier.

QTP WILL LEARN THE INFORMATION IN THE FOLLOWING WAY, INCASE OF ONLY NORMAL IDENTIFICATION:

First of all QTP will learn all the Mandatory properties, it will think whether those

properties are sufficient or not, if it feels not sufficient, then it will learn 1st Assistive property, and then once again

think whether all those properties are sufficient for identifying the object uniquely, if it feels not sufficient it will

learn the 2nd Assistive property and once again think whether they are sufficient or not, if not sufficient then it will

repeat the same process by learning the next Assistive properties one by one till it feels satisfy, if not all the Assistive

properties are learned, still QTP not satisfy then finally it will learn the Ordinal Identifier, whatever learned during

the above process will be stored in the object repository.

QTP WILL LEARN THE INFORMATION IN THE FOLLOWING WAY, INCASE OF SMART IDENTIFICATION ALSO:

QTP will learn all the Mandatory properties, all the Base Filter properties, all the

Optional Filter properties at a time, stores the Base Filter properties and Optional Filter properties in a secrete place

and will not think about them. It will think whether the Mandatory properties are sufficient for identifying the object

uniquely, if it feels not sufficient, it will learn the first Assistive property and continues the process same as above.

Page 14: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 14

Ex:

OR: OBJECT REPOSITORY.

QTP WILL LEARN THE INFORMATION IN THE FOLLOWING WAY DURING THE IDENTIFICATION:

First of all it will use all the properties present in the object repository and will try to identify the

object, if it fails then it will use Smart Identification mechanism and will try to identify the object finally as follows:

First it will use all the Base Filter properties and will try to identify the object, if at all more then

one objects are found, it will consider those objects and filters all the remaining objects.

It will take the first Optional Filter property and will try to identify the object in the considered

objects, if at all more than one matches are found then it will consider only those objects and filters the remaining

objects, then it will take the second Optional Filter property and repeats the same process till it finds exactly one

match or one object.

In case all the Optional Filter properties are used but still QTP is unable to find exactly one match,

then it will go to Object Repository and check whether the Ordinal Identifier is available or not, if it is available using

that it will roughly identify the object otherwise hands up.

Ex:

While learning the properties it will stops still it satisfies that it is enough for identifying the objects and stores the

information in the Normal Identification, then what the use of Smart Identification?

While learning for example in the Login screen first LOGIN and CLEAR buttons are DISABLED.

DISABLE

E

Page 15: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 15

While identifying the objects, suppose user enters UN and PW, then the LOGIN and CLEAR buttons are ENABLED.

So the properties of LOGIN and CLEAR buttons are varying, so it is difficult to identify the objects with the learned

properties in the Normal Identification, so it will go for Smart Identification for identifying the objects.

Ex:

Why can’t we specify object name as the property for identifying the objects very easily?

Suppose the application has dynamic button, then it will change its behavior depending upon the user action.

So it is difficult for identifying the object with the object name property.

ENABLE

BEFORE

AFTER

DYNAMIC BUTTON

Page 16: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 16

Ex: Configuration of the objects that are identified should not change, it will affect the remaining objects, in case if

any object is not identified, then try to change the properties of those objects in the object repository.

ORDINAL IDENTIFIER:

There are 3 types of Ordinal Identifier’s:

1. LOCATION

2. INDEX

3. CREATION TIME

1. LOCATION: Whenever the Location is selected as an Ordinal Identifier. QTP will generate some numbers like 0, 1,

2, 3………. based on the sequence of the objects located in the application.

2. INDEX: Whenever the Index is selected as an Ordinal Identifier. QTP will generate some numbers like 0, 1, 2,

3………. based on the index of the pages related to those objects.

3. CREATION TIME (FOR BROWSER OBJECT IN WEB ENVIRONMENT ONLY): Whenever the Creation Time is selected as an

Ordinal Identifier. QTP will generate some numbers like 0, 1, 2, 3………. based on the loading time of the objects in

the browser.

NAVIGATION FOR OBJECT IDENTIFICATION CONFIGURATION:

Activate the menu item Tool.

Select the option Object Identification.

Select the desired Environment.

Select the desired class of the Object.

Specify the required properties in the mandatory list and Assistive list.

Select an Ordinal Identifier.

If at all the Smart Identification is also required then, select the checkbox enabled Smart Identification.

Click on configure button.

Specify the required Base Filter and Optional Filter properties.

Click on OK.

OBJECT SPY: It is a handy feature provided by the QTP, which shows complete object information like list of object

properties and values, list of methods, syntax of methods, description of methods of both the Test objects and Run

Time objects then and there on the spot immediately.

NAVIGATION:

Activate the menu item Tools.

Select the option Object Spy.

Specify the desired object in the application with the help of handy icon.

TYPES OF OBJECTS:

There are 2 types of objects:

1. RUN TIME OBJECTS

2. TEST OBJECTS.

Page 17: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 17

1. RUN TIME OBJECTS: All the original objects present in the application are known as Run Time objects.

2. TEST OBJECTS: The reference objects for the original objects present in the object repository are known as Test

objects.

QTP LIFE CYCLE: QTP LIFE CYCLE CONTAINS 6 PHASES:

1. TEST PLANNING

2. GENERATING THE BASIC TEST

3. ENHANCING THE TEST

4. DEBUGING THE TEST

5. EXECUTING THE TEST

6. ANALYZING THE RESULTS

1. TEST PLANNING:

In this phase the Automation Test Lead will do the following:

He will understand the Requirements.

He will identify the area to be Automated.

He will analyze the dynamism of the application and based on that he will do all the pre configurational settings to

that tool, in such a way that it will be compatible to that application.

He will do the Resource planning (Who has to do what?).

He will do the Scheduling.

He will prepare the Automation Test Plan document with all the above analyzed information.

2. GENERATING THE BASIC TEST:

Script related to basic operation done in the application called Basic Script.

In this phase one will generate the basic script for both the positive and negative flow of the application.

3. ENHANCING THE TEST:

Adding something to the Basic Script called enhancing the test.

One can enhance the test in the following ways:

Inserting the check point statement.

Synchronizing the test by inserting the synchronization point statements.

Parameterizing the test (Data Driven Testing-DDT).

Inserting the output value statements.

Measuring the transactions by inserting transactional point statement.

Inserting the programmatic statements.

Inserting the comments.

Inserting the script statements manually.

CHECK POINT: Check point is a feature provided by the QTP, which is used for checking something during the

execution, at any point of time.

OPERATIONAL OVERVIEW OF CHECK POINT: CHECK POINT works in 2 phases:

1. PRE EXECUTION PHASE

2. WHILE EXECUTION PHASE

Page 18: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 18

1. PRE EXECUTION PHASE:

In this phase it will do the following:

It will capture the expected value.

It will generate the corresponding script statement.

2. WHILE EXECUTION PHASE:

In this phase it will do the following:

It will capture the required Actual value.

It will compare the Actual value with the Expected value.

Finally it will show the result as PASS (or) FAIL.

TYPES OF CHECKPOINTS:

1. STANDARD CHECKPOINT

2. BITMAP CHECKPOINT

3. TEXT CHECKPOINT

4. TEXT AREA CHECKPOINT

5. DATABASE CHECKPOINT

6. XML CHECKPOINT (FROM RESOURCE)

7. PAGE CHECKPOINT

8. TABLE CHECKPOINT

9. IMAGE CHECKPOINT

10. ACCESSIBILITY CHECKPOINT

Note: PAGE, TABLE and IMAGE are hidden WEB Checkpoints.

Note: XML, DATABASE CheckPoints are enabled in the menu INSERT because they are not related to application.

1. STANDARD CHECKPOINT:

It is used for checking the standard GUI objects properties values.

It can be inserted in 2 ways:

1. Through Application

2. Through Active Screen

NAVIGATION THROUGH APPLICATION:

Keep the cursor in the desired location.

Keep the tool under Recording Mode.

Activate the menu item Insert.

Go to Checkpoint.

Select the option standard Check Point.

Specify the desired object in the application.

Click on OK.

Select the desired properties to be checked and specify the desired expected value.

Click on OK.

Stop Recording.

Page 19: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 19

NAVIGATION THROUGH ACTIVE SCREEN:

Keep the cursor on the desired statement.

So that the corresponding Snapshot will be available in the Active Screen.

Go to Active Screen.

Right click on the desired object.

Select the option insert Standard CheckPoint.

Click on OK.

Select the desired properties to be checked.

Select the desired Expected values.

Select one of the following options:

o Before current step

o After current step.

Click on OK.

BITMAP CHECKPOINT:

It is used for checking the expected pixels are present in the selected area of the application (or) not.

It is also used for checking the complete Bitmap (or) a part of the Bitmap.

One can insert the Bitmap check point through Application (or) Active screen

NAVIGATION THROUGH APPLICATION:

Keep the cursor in the desired location.

Keep the tool under Recording Mode.

Activate the menu item Insert.

Go to Check Point.

Select the option Bitmap CheckPoint.

Specify the desired Bitmap in the Application.

Click on OK.

If required select the desired part of the Bitmap using select area button.

Select the Checkbox, save only selected area.

Click on OK.

Stop Recording.

NAVIGATION THROUGH ACTIVE SCREEN:

Keep the cursor on the desired statement, so the corresponding Snapshot is available in the Active Screen.

Go to the Active Screen, right click on the Bitmap.

Select the option, insert Bitmap CheckPoint.

Click on Ok.

If required select the desired part of the Bitmap using select area button.

Select the Checkbox, save only selected area.

Select any one of the following option:

o Before current step

o After current step

Click on OK.

BITMAP: It is a particular area, where it stores some pixels, we can’t do any actions on it.

IMAGE: We can do some actions on it, we can use it as a Hyperlink/Object.

Page 20: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 20

TEXT CHECKPOINT: It is used for checking the text present on the specified objects, it can be inserted through

Application as well as through Active Screen.

NAVIGATION THROUGH APPLICATION:

Keep the cursor in the desired location.

Keep the tool under Recording.

Activate the menu item Insert.

Go to the CheckPoint.

Select the option Text CheckPoint.

Specify the desired object by using hand icon.

Click on OK.

Specify the desired expected text in the Application.

Select the Required option:

Match case Ignore spaces

Exact match Text not displayed

Click on OK.

Stop Recording.

NAVIGATION THROUGH ACTIVE SCREEN:

Keep the cursor in the desired statement, so the corresponding Snapshot is available in the Active screen.

Go to the Active screen.

Right click on the desired object.

Select the option insert CheckPoint.

Click on OK.

Specify the desired expected Text.

Select the Required option:

Match case Ignore spaces

Exact match Text not displayed

Select on of the following option:

o Before current step

o After current step.

Click on OK.

TEXT AREA CHECKPOINT:

It is used for checking the text present in a specified area of the application, it can be inserted only through

application.

NAVIGATION THROUGH APPLICATION:

Keep the cursor in the desired location.

Keep the tool under Recording.

Activate the menu item Insert.

Go to the CheckPoint.

Select the option Text area CheckPoint.

Specify the desired area in the Application

Specify the desired expected object Text.

Select the Required option:

Page 21: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 21

Match case Ignore spaces

Exact match Text not displayed

Click on OK.

Stop Recording.

WIZARD: It is a group of windows, which accepts some information from the user and accomplishes the task in a complex way.

DATABASE CHECKPOINT: It is used for checking the contents of a database.

DATABASE: it is a Base (or) a Place, where one can store and retrieve Data.

There are 3 types of Database Testing:

1. Store and Retrieval Database Testing

2. Database Design Testing

3. Database Content Testing

Create a Database and a Table in Access.

NAVIGATION FOR CREATING DATABASE CHECK POINT:

Activate the menu item Insert.

Go to Checkpoint.

Select the option Database CheckPoint.

Select the option-specify SQL statement manually.

Click on Next.

Click on Create.

Click on New.

Specify the desired Driver/Provider from the list.

Click on Next

Specify the Data Source Name (DSN).

Click on Next.

Click on Finish.

Click on Select.

Browse the desired Database.

Click on OK.

Click on OK.

Click on OK.

Specify the required SQL statements

Click on Finish.

Select one of the following options:

o Before current step

o After current step

Click on OK.

XML CHECKPOINT: It is used for checking the contents of a XML file.

XML: It is a universal understandable language used for Data Transformation.

Page 22: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 22

Ex: Create a file with .XML with the help of notepad as follows: <ENVIRONMENT>

<VARIABLE>

<VAR>

<NAME>

SURI

</NAME>

</VAR>

</VARIABLE>

<VARIABLE>

<VAR>

<NAME>

RAVI

</NAME>

</VAR>

</VARIABLE>

</ENVIRONMENT>

DATABASE--------> INFO File:

NAME SALARY

SURI 45000

RAVI 52000

MANJU 22000

GOPI 33000

NAVIGATION FOR CREATING XML CHECKPOINT:

Activate the menu item Insert.

Go to CheckPoint.

Select the option XML CheckPoint.

Browse the desired XML file.

Click on OK.

Select the desired contents to be checked and Specify the requested expected values.

Select one of the following options:

o Before current step

o After current step

Click on OK.

PAGE CHECKPOINT: It is used for checking the properties of a Page.

NAVIGATION:

Keep the cursor on the desired statement.

Go to Active Screen.

Right click on the screen.

Select the option insert Standard CheckPoint.

Select the page in the Hierarchy.

Click on OK.

Select the desired properties to be checked.

Select one of the following options:

o Before current step

o After current step

Click on OK.

Page 23: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 23

TABLE CHECKPOINT: It is used for checking the contents of a Table.

NAVIGATION:

Keep the cursor on the desired statement.

Go to Active Screen.

Right click on the screen.

Select the option insert Standard CheckPoint.

Select the page in the Hierarchy.

Click on OK.

Select the desired properties to be checked.

Select one of the following options:

o Before current step

o After current step

Click on OK.

IMAGE CHECKPOINT: It is used for checking the properties of an Image.

NAVIGATION:

Keep the cursor on the desired statement.

Go to Active Screen.

Right click on the screen.

Select the option insert Standard CheckPoint.

Select the page in the Hierarchy.

Click on OK.

Select the desired properties to be checked.

Select one of the following options:

o Before current step

o After current step

Click on OK.

WEB CHECK POINTS: PAGE, TABLE AND IMAGE CHECK POINTS ARE HIDDEN CHECK POINTS, WE CAN USE ONLY THROUGH STANDARD CHECK POINT.

ACCESSABILITY CHECKPOINT: It is used for checking whether the page is developed according to the WORLD WIDE

WEB CONSORTIUM (W3C) standards or not. With the help of these checkpoints one can confirm whether that page

can be accessible all over the world comfortably or not.

NAVIGATION:

Keep the cursor on the desired statement.

Go to Active Screen.

Right click on the page.

Select the option insert Accessibility CheckPoint.

Select one of the following options:

o Before current step

o After current step

Click on OK.

Page 24: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 24

SYNCHRONIZATION: It is a process of matching the speeds of both the tool and the application in order to keep them

in sync with each other, in order to obtain proper Testing results.

Here the main concept is making the tool to wait, till the application finishes its work, to do the

same we can follow any one of the following way:

1. Inserting the synchronization point statement.

2. Increasing the default time.

3. Inserting the wait statement.

Note: Synchronization point statement affects only one statement, it adds the time specified with the default time.

NAVIGATION FOR INSERTING THE SYNCHRONIZATION POINT:

Keep the cursor in the desired location.

Keep the tool under Recording mode.

Activate the menu item Insert.

Select the option Synchronization point.

Specify the desired object in the application.

Click on OK.

Select the desired property name.

Specify the desired property value.

Specify the extra time in milliseconds.

Click on OK.

Stop Recording.

To avoid the above navigation, one can directly insert the following statement:

SYNTAX:

HIERARCHY.WAITPROPERTY”PROPETY NAME”, PROPERTY VALUE, EXTRA TIME IN MILLISECONDS

Ex:

WINDOW(“FLIGHT RESERVATION”).WINBUTTON(“DELETE ORDER”).WAITPROPERTY”ENABLED”, TRUE, 14000

NAVIGATION FOR MODIFYING DEFAULT TIME:

Activate the menu item File.

Select the option settings.

Specify the desired Time in object Synchronization Time Out field.

Click on OK.

Note: It effects all the script statements in the script area.

SYNTAX FOR WAIT STATEMENT:

WAIT(TIME IN SECONDS)

Note: It effects only one statement, but it will wait till the time is finished, even though the action is completed.

VARIABLE: It is a name given to the memory location, which can hold some value, it can change values in any

number of times if required.

FLAT FILE: The file without any specific format.

Page 25: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 25

PARAMETRIZATION: It is a process of replacing the constant values with variables in order to increase the scope of

test.

MAINLY WE FOLLOW 5 STEPS IN RETESTING (MANUAL TESTING):

1. REQUIREMENTS

2. TEST CASES

3. OPTIMIZATION

4. EXECUTION

5. RESULT ANALYSIS

MAINLY WE FOLLOW 5 STEPS IN DATA DRIVEN TESTING (QTP):

1. DATA TABLE

2. SCRIPT STATEMENTS

3. OPTIMIZATION

4. EXECUTION

5. RESULT ANALYSIS

DATA DRIVEN TESTING: It is a concept introduced in automation in order to implement Retesting.

Steps to follow to perform DDT:

1. Collect data into Data Table.

2. Generate the basic Test.

3. Do the required Enhancements and parameterize the test.

4. Execute the list.

5. Analyze the Result

PARAMETRIZATION: It is a process of replacing the constant values with variables or parameters, in order to increase

the scope of test.

Parameterization can be done in 3 ways:

1. DATA DRIVEN WIZARD

2. KEYWORD VIEW

3. MANUALLY

NAVIGATION THROUGH DATA DRIVEN WIZARD:

Activate the menu item tools.

Select the option Data Driver.

Select the desired constant value in the list.

Click on Parameterized button.

Next.

Click on Parameterized options button.

Select the desired column name.

Click on OK.

Click on Finish and then OK.

NAVIGATION THROUGH KEYWORD VIEW:

Go to Keyword view.

Select the desired constant value to be parameterized.

Click on configure the button.

Select the option parameter.

Select the desired column name.

Click on OK.

Page 26: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 26

TO AVOID THE ABOVE NAVIGATION, PARAMETERIZATION CAN BE DONE MANUALLY IN THE FOLLOWING WAY:

Ex:

X=DATA TABLE(“V1”,I)

VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE1”).SET X

VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE2”).SET DATATABLE(“V2”,I)

VBWINDOW(“CALCULATOR”).VBEDIT(“ADD”).CLICK

NAVIGATION FOR PARAMETERIZING THE CHECKPOINT:

Right click on the CheckPoint statement.

Select the option CheckPoint properties.

Select the option Parameter.

Click on Parameter options button.

Select the desired column name.

Click on OK.

Click on OK.

OUTPUT VALUES: It is a feature provided by the QTP, which is used for capturing a value from an application (or)

from a Data Base (or) from a XML files and stores it under a desired column in the Runtime Data table.

TYPES OF OUTPUT VALUES:

1. STANDARD OUTPUT VALUE: It is used for capturing the standard GUI objects properties values, it can be perform

through an Application or Active screen.

2. TEXT OUTPUT VALUE: It is used for capturing the text present on the objects.

3. TEXT AREA OUTPUT VALUE: It is used for capturing the text present in the specified area.

4. DATABASE OUTPUT VALUE: It is used for capturing a value from Database.

5. XML OUTPUT VALUE: It is used for capturing a value from XML file.

NAVIGATION FOR STANDARD OUTPUT VALUE THROUGH APPLICATION:

Keep the cursor in desired location.

Keep the tool under Recording mode.

Activate the menu item insert.

Go to OutPut value.

Select the desired object in the Application.

Click on OK.

Select the desired properties to be captured.

Modify the name if required.

Click on OK.

Stop Recording.

NAVIGATION THROUGH ACTIVE SCREEN:

Keep the cursor on desired statement, so that the corresponding Snapshot is available in Active Screen.

Go to Active Screen.

Right click on desired object.

Select the object, Insert OutPut value.

Click on OK.

Select the desired property to be captured.

Modify the name if required.

Select one of the following option:

Page 27: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 27

o Before current step

o After current step

Click on OK.

MEASURING TRANSACTIONS: It is a concept provided in QTP used for calculating the Time taken by an Application

approximately to perform a Task. (Or) Execution Time of block of script statements, to do the same QTP has

introduced START TRANSACTION & END TRANSACTION POINTS.

NAVIGATION FOR START TRANSACTION:

Keep the cursor in desired location.

Activate the menu item insert.

Select the option START TRANSACTION.

Specify the desired Transaction name.

Select one of the following options:

o Before current step

o After current step

Click on OK.

NAVIGATION FOR END TRANSACTION:

Keep the cursor in desired location.

Activate the menu item insert.

Select the option END TRANSACTION.

Specify the desired Transaction name.

Select one of the following options:

o Before current step

o After current step

Click on OK.

Ex: SERVICES. START TRANSACTION <TRANSACTION NAME>

-----------------------------

-------------------------------

-------------------------

SCRIPT STATEMENTS

---------------------------

---------------------------------

--------------------------------

SERVICES. END TRANSACTION <TRANSACTION NAME>

INSERTING THE PROGRAMMATIC STATEMENTS:

Any VB Script contains the following types of Programmatic Statements:

1. NORMAL STATEMENTS (or) OBJECT CALLS

2. CONDITIONAL STATEMENTS

3. LOOPING STATEMENTS

4. UTILITY STATEMENTS

Apart from the above Programmatic statements Comments also will be available in a program.

Page 28: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 28

COMMENTS: Comments are used for increasing the readability of the script. It starts with single quote (‘).

Ex: ‘This Program is for Normal Recording.

SYSTEM UTIL UTILITY OBJECT: This utility object is mainly used for invoking the Application with the help of Run

method.

Syntax: SYSTEMUTIL.RUN “PATH”

Note: One can even invoke the application with the help of invoke application statement.

Syntax: INVOKEAPPLICATION “PATH”

REPORTER UTILITY OBJECT: It is used fro sending an extra result step to the result window.

Syntax: REPORTER.REPORTEVENT STATUS, “STEPNAME”, “DETAILS/MSG”

Ex:

REPORTER.REPORTEVENT MICDONE, “MYREP”, “ADD IS SUCCESSFUL”

(Or)

REPORTER.REPORTEVENT 0, “MYREP”, “ADD IS SUCCESSFUL”

Note: MIC-MICROSOFT INTEGER CONVERSION.

STATUS: 0-PASS

1-FAILED

2-DONE

3-WARNING

4. DEBUGGING THE TEST:

It is a process of executing the script in a user desired passion with some temporary breaks, in order to

identify the Errors.

To do the same QTP has provided Breakpoint feature and Step commands.

BREAKPOINT: It is a feature provided by QTP which is used for breaking the execution temporarily.

STEP COMMANDS:

1. STEP INTO: It is used for executing a single step, if that step is a functional call step then it will make the pointer

step into the function and breaks the execution at the first statement.

2. STEP OUT: It is used only after entering into the function, it will execute all the remaining statements inside the

function from the position of the pointer and breaks the execution after stepping out of the function.

3. STEP OVER: This statement is used for executing any step until it is finished, for example if it is a functional call

statement it will execute all the statements inside the function and then breaks the execution.

4. RUN TO STEP: This is used for executing all the statements up to the before statement, where the cursor is

available.

5. DEBUG FROM STEP: This is used for bringing the pointer to a desired statement without executing any of the

previous statements.

Page 29: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 29

Ex:

FUNCTION MYFUNC()

MSGBOX “HAI”

MSGBOX “HELLO”

MSGBOX “BYE”

END FUNCTION

‘ MAIN PROGRAM

MSGBOX “WELCOME”

CALL MYFUNC()

MSGBOX “SEE U”

MYFUNC()

MSGBOX “TA TA”

MYFUNC()

MSGBOX “TAKE CARE”

MSGBOX “HAPPY WEEKEND”

4. DEBUG VIEWER PANE: It is an area provided by the QTP, which is used for Viewing, Modifying (or) Setting the

current values of variables (or) expressions during the execution break with the help of 3 tabs by name WATCH,

VARIABLES & COMMAND.

WATCH: Quick result search.

VARIABLES: List of variables

COMMAND: To modify the values.

Ex:

DIM A, B

A=10

B=20

MSGBOX A ---------------10_______COMMAND A=40

MSGBOX A ----------------40_______WATCH A*B

MSGBOX A ----------------800

5. EXECUTING THE TEST: In this phase one will execute the Test.

6. ANALYZING THE RESULT: In this phase one will analyze the Result.

RECOVERY SCENARIOS: During the execution sometimes QTP may face some problematic statements, where in it

need to recover by itself and should continue the execution, to do the same the test engineer need to define a

solution well in advance and attach it to the corresponding test before starting the execution.

Usually QTP may face the following types of problems:

1. Problems related to POP UP WINDOWS.

2. Problems related to OBJECT STATE.

3. Problems related to TEST SCRIPT EXECUTION.

4. Problems related to APPLICATION CRASH.

Page 30: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 30

To define the solutions for above problems QTP has provided 4 Trigger Events:

1. POP UP WINDOW

2. OBJECT STATE

3. TEST RUN ERROR

4. APPLICATION CRASH

NAVIGATION FOR OBJECT STATE PROBLEM:

Activate the menu item resources.

Select the option Recovery Scenario Manager.

Click on new scenario button.

Click on next.

Select the Trigger event as Object State.

Click on next.

Specify the desired object in the application.

Click on Ok.

Click on next.

Specify the required properties.

Click on next.

Click on next.

Specify the recovery operation as function call.

Click on next.

Browse the desired library file.

Specify the desired function name.

Write the required script inside the function.

Click on next.

Remove the check box (Add another recovery operations)

Click on next.

Specify the scenario name.

Click on next.

Select the required check boxes:

o Add scenario to current test

o Add scenario to default test settings

Click on finish

Save the file with .qrs extension

Click on close.

Note: .QRS-QUICK RECOVERY SCENARIO.

NAVIGATION FOR ASSOCIATING THE EXISTING RECOVERY SCENARIO TO THE CURRENT TEST:

Activate the menu item file.

Select the option settings.

Select the recovery tab.

Click on add button.

Browse the desired recovery scenario.

Click on add scenario

Click on apply.

OK.

Page 31: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 31

ENVIRONMENT VARIABLES:

Whenever some common values need to be used in multiple scripts then it is suggested not to declare the

local variables in all tests individually, it is better to declare all the common variables in a separate environment file,

attach it to all the required tests and use those variables inside those test.

By doing this the advantage is in future if the environment is changed and some of the values of those

variables need to be updated in order to make the scripts compatible with that environment, then with minimum

efforts, we can update the values in the environment file instead of updating all the script files.

There are 2 types of Environment Variables:

1. BUILT IN VARIABLES

2. USER DEFINED VARIABLES

1. BUILT IN VARIABLES: These variables by default will be available with every new test, so any one can use them

directly in any test using the following syntax:

Syntax: ENVIRONMENT.VALUE(“BUILT IN VARIABLE NAME”)

Ex: MSGBOX ENVIRONMENT.VALUE(“ProductName”)&(ENVIRONMENT(“ProductVer”)

2. USER DEFINED VARIABLES: Whenever we feel that we no need some common variables, to develop number of

scripts depending upon our application, then we must declare the user defined variables in a separate environment

file, attach that file to the required test and use those variables inside those tests.

NAVIGATION FOR CREATING AN ENVIRONMENT FILE WITH ENVIRONMENT VARIABLES:

Activate the menu item File.

Select the option settings.

Select the Environment tab.

Select the variable type as User Define.

Add all the required variables and values.

Click on Export.

Browse the desired location and save with .XML extension.

To avoid the above navigation one can directly develop the environment file as follows:

Open the Notepad

Develop the script as follows and Save the file with .XML extension. <ENVIRONMENT>

<VARIABLE>

<NAME>A</NAME>

<VALUE>10</VALUE>

</VARIABLE>

<VARIABLE>

<NAME>PATH</NAME>

<VALUE>”C:\CAL.EXE”</VALUE>

</VARIABLE>

</ENVIRONMENT>

Page 32: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 32

NAVIGATION FOR ASSOCIATIONG AN ENVIRONMENT FILE TO THE REQUIRED TEST:

Activate the menu item File.

Select the option settings.

Select the Environment tab.

Select the variable type as User Define.

Select the check box load variables and values from external file.

Browse the desired Environment file.

Click on apply and OK.

To avoid the above navigation one can directly write the script statements with following syntax:

ENVIRONMENT.LOADFROMFILE”PATH OF ENVIRONMENT FILE”

Ex: ENVIRONMENT.LOADFROMFILE”E:\envfile.xml”

PATH=ENVIRONMENT.VALUE(“PATH”)

X=ENVIRONMENT(“A”)

Y=ENVIRONMENT(“B”)

SYSTEMUTIL.RUN PATH

VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE1”).SET X

VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE2”).SET Y

VBWINDOW(“CALCULATOR”).VBBUTTON(“SUB”).CLICK

Ex: DEBUG FROM TEST :

FUNCTION MYFUNC()

MSGBOX “HELLO”

MSGBOX “HAI”

END FUNCTION

MSGBOX “WELCOME”

MYFUNC()

MSGBOX “BYE”

FRAMEWORK: It is defined as a generic work or a set of guidelines to perform a task in an effective, efficient and

optimized way.

Types of Frameworks:

1. LINEAR FRAMEWORK

2. MODULAR FRAMEWORK

3. KEYWORD DRIVEN FRAMEWORK

4. HYBRID FRAMEWORK

5. DATA DRIVEN FRAMEWORK

1. LINEAR FRAMEWORK:

Generate the basic script for the required end to end scenario.

Enhance the script.

Debug the script.

Execute the script.

Analyze the script.

Page 33: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 33

2. MODULAR FRAMEWORK:

Develop the individual components for the tasks which need to be repeatedly perform.

Make them as reusable components.

Prepare the driver scripts for the end to end scenarios.

Execute the driver scripts.

Analyze the results.

ACTION: it is a set of instructions to perform a specific task.

Types of Actions:

1. NORMAL

2. REUSABLE

Reusable Actions called in another test are known as External Actions.

External Actions are non editable.

NAVIGATION FOR INSERTING NEW ACTION:

Activate the menu item Insert.

Select the option Call to New Action.

Specify the desired Action name.

Select one of the following options:

o At the end of the test

o After the current step

Click on OK.

NAVIGATION FOR SPLITTING AN ACTION INTO 2 ACTIONS:

Save the Action.

Keep the cursor on the first line of the second part.

Activate the menu item Edit.

Go to Action.

Select the option Split Action.

Select one of the following options:

o Independent of each other

o Nested

Specify the desired names for the Actions.

Click on OK.

NAVIGATION FOR RENAMING ACTION:

Activate the menu item Edit.

Go to Action.

Select the option rename Action.

Specify the desired name.

Click on OK.

Page 34: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 34

NAVIGATION FOR MAKING AN ACTION AS REUSABLE ACTION:

Activate the menu item Edit.

Go to Action.

Select the option Action properties.

Select the checkbox Reusable Action.

Click on OK.

NAVIGATION FOR CALLING AN EXISTING ACTION:

Activate the menu item Insert.

Select the option Call to Existing Action.

Browse the desired test.

Select the desired Action.

Select one of the following options:

o At the end of the test

o After the current step

Click on OK.

Ex:

Record the Flight reservation application.

Split the script as Action1 (LOGIN), Action2 (INSERT ORDER), Action3 (OPEN ORDER), Action4 (LOGOUT).

Save the script.

Open a new file.

Call the existing Actions.

Enhance the script if necessary.

Run the script.

Difference between Functions and Actions:

1. We can use Actions with in QTP where as we can use functions anywhere (i.e. outside QTP also).

2. We can call Functions with in Actions but we can't call Actions with in Functions.

3. Generally Functions are saved with ".vbs" extension, where as Actions will save with ".mts".

3. AUTOMATION TESTING PROCESS WITH KEYWORD DRIVEN FRAMEWORK:

Q: What is Automation Testing process?

A: Create the Folder structure as follows:

Page 35: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 35

TD-TEST DATA

REP-REPOSITORY

LIB-LIBRARY

REC-RECOVERY

ENV-ENVIRONMENT

TEST-SCRIPT FILES

LOG-HIGH LEVEL RESULT FILES

TEST LOG: It is a chronological record of all relevant details about the execution of a Test.

NAVIGATION:

Develop the required Test Data Files, Repository Files, Library Files, Recovery Files and Environment Files and

save them in corresponding folders.

Open the main Test and associate all the required resources.

Develop the script in such a way that it is executed based on the keywords specified in the Data Table.

Save the script in the corresponding folder.

Whenever required open the script.

Specify the desired keywords.

Execute the script and analyze the result.

Add objects information in the object repository through Add Objects to Local or through Shared Repository.

For invoking the application we use SYSTEMUTIL.RUN statement.

Create a library file with .VBS extension through notepad as follows:

FUNCTION LOGIN()

Dialog("Login").Activate

Dialog("Login").WinEdit("Agent Name:").Set "suri"

Dialog("Login").WinEdit("Password:").SetSecure "4b55acb065483d2d7c0ba692c91a3baabd597428"

Dialog("Login").WinButton("OK").Click

END FUNCTION

FUNCTION INSORD()

Window("Flight Reservation").WinButton("Button").Click

Window("Flight Reservation").ActiveX("MaskEdBox").Type "111111"

Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver"

PROJECT NAME_AUTOMATION

TD

REP

LIB

REC

ENV

TEST

LOG

Page 36: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 36

Window("Flight Reservation").WinComboBox("Fly To:").Select "Los Angeles"

Window("Flight Reservation").WinButton("FLIGHT").Click

Window("Flight Reservation").Dialog("Flights Table").WinList("From").Select "6252 DEN 12:48 PM LAX 03:48 PM AA $100.80"

Window("Flight Reservation").Dialog("Flights Table").WinButton("OK").Click

Window("Flight Reservation").WinEdit("Name:").Set "suri"

Window("Flight Reservation").WinButton("Insert Order").Click

END FUNCTION

FUNCTION OPNORD()

Window("Flight Reservation").WinButton("Button_2").Click

Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"

Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "5"

Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click

END FUNCTION

FUNCTION LOGOUT()

Window("Flight Reservation").WinMenu("Menu").Select "File;Exit"

END FUNCTION

Write the script in QTP Test Pane as follows:

SYSTEMUTIL.RUN "C:\PROGRAM FILES\MERCURY INTERACTIVE\QUICKTEST PROFESSIONAL\SAMPLES\FLIGHT\APP\FLIGHT4A.EXE"

VAR=DATATABLE("KEYS",1)

SELECT CASE VAR

CASE "L1"

CALL LOGIN()

CASE "L2"

CALL INSORD()

CASE "L3"

CALL OPNORD()

CASE "L4"

CALL LOGOUT()

END SELECT

4. HYBRID FRAME WORK: It is a mixture of two or more frameworks is known as Hybrid Framework.

5. DATA DRIVEN FRAME WORK: DATA DRIVEN TESTING.

LIBRARY FILES: It is an area provided by QTP, where one can develop and store the user define functions.

NAVIGATION FOR CREATING THE LIBRARY FILES:

Open the Notepad

Develop all the required Functions in it.

Save it with .VBS (VISUAL BASIC SCRIPT) extension.

Activate the menu item New.

Select the option Function Library

Develop all the required Functions

Save it with .QFL (QUICK FUNCTION LIBRARIES) or .VBS extension.

Page 37: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 37

NAVIGATION FOR ASSOCIATING THE LIBRARY FILE TO THE REQUIRED TEST:

Activate the menu item File.

Select the option Settings

Select the Resource tab.

Click on add button.

Browse the desired Library file.

Click on Apply and OK

DIFFERENCES: a) Win runner is a Functional testing tool

b) Load runner is Performance tool

c) Test director is Management tool

d) Silk test is a Functional testing tool

a) Win runner:

1. You can record the script automatically or manually you can write scripts.

2. This is mainly use for Regression testing.

b) Load runner:

1. This tool is mainly used for Performance testing.

2. We can also use this tool for Load testing and Stress Testing

c) Test director:

1. This is a Management tool.

2. Test director tool contains:

a. Test Plan

b. Test Cases

c. Time estimation

d. Schedule documents

e. Bug Lists

d) Silk test:

1. Silk Test is a tool specifically designed for doing Regression and Functionality testing.

2. It is developed by Segue Software Inc.

3. Silk Test is the industry’s leading functional testing product for e-business applications,

whether Window based, Web, Java, or traditional client/server-based.

4. Silk Test also offers test planning, management, direct database access and validation, the

flexible and robust for Test scripting language.

5. A built in recovery system for unattended testing, and the ability to test across multiple

platforms, browsers and technologies.

Page 38: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 38

VB SCRIPT

VARIABLE: It is a name given to a memory location, which can hold a value and that can be changed any number of

times in future if required.

Naming conventions of a Variable:

Variable name should be a meaningful name.

Variable name should always start with an Alphabet.

It should not exceed 255 characters long.

It should not include periods (.).

It should not be same as Keywords or Reserved words.

Declaration of a Variable:

One can declare the Variables in VB Script using the following Keywords:

DIM

PRIVATE

PUBLIC

DIM X : By default it is PRIVATE

PRIVATE X : This Variable scope is limited to particular block

PUBLIC X : we can use Variable in any block, this scope is Global.

Option EXPLICIT: Option EXPLICIT statement restricts the usage of new variables in the program without declaration.

Whenever a new variable is found during the execution immediately an error will be shown, if at all the option

Explicit statement is not used any misspelled variable name also will be treated as new variable.

Ex: Option Explicit

Dim apppath

Apppath=”d:\........................”

------------ appapth

------------

------------ appath It shows error

------------

------------ apppath

If we don’t use option Explicit, it will not show any Error.

CONSTANT: It is a name given to a memory location , which can hold a value that can’t be changed in future.

Ex: CONST pi=3.15

ARRAY: It is a special type of variable, which can hold many values.

There are 2 types of Arrays:

1. Single dimension array

2. Multi dimension array

Arrays can declared as fixed length arrays as well as dynamic arrays.

Page 39: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 39

Ex: Fixed length Arrays:

DIM a(10)

-----------------

------------------

a(0)=’---------`

a(1)=’---------‘

---------

-----------

a(9)=’-----------`

a(10)=’------------`

Ex: Dynamic Arrays:

Dim a()

--------------

----------------

REDIM a(20)

-----------------

--------------

REDIM PRSERVE a(30)

--------------

Note: Dynamic arrays can be resized any no of times, while resizing if at all we want to preserve the previous

locations, than we need to use PRESERVE keyword along with REDIM keyword.

OPERATORS: 1. ARTHIMATIC OPERATORS:

+ Ex: a+b

- Ex: a-b

* Ex: a*b

MOD Ex: 20 MOD 7=6

^ Ex: 10 ^ 2=100

2. ASSIGNMENT OPERATOR:

= Ex: a=10

3. CONCATINATION OPERATOR:

& Ex: var=”Suri”

Msgbox ‘My name is:”& var

4. COMPARISION OPERATORS:

<

>

<=

>=

=

<>

Page 40: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 40

5. LOGICAL OPERATORS:

AND

OR

XOR

NOT

TRUTH TABLES:

AND

EXP1 EXP2 RESULT

T T T

T F F

F T F

F F F

OR

EXP1 EXP2 RESULT

T T T

T F T

F T T

F F F

XOR

EXP1 EXP2 RESULT

T T F

T F T

F T T

F F F

NOT

EXP RESULT

T F

F T

CONDITIONAL STATEMENTS:

1. IF---THEN---ELSE: It is used for executing either TRUE block or FALSE block of statements based on the condition.

Syntax: IF <CONDITION> THEN

---------------------

-------------------

ELSE

----------------

------------------

ENDIF

Page 41: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 41

2. SELECT-CASE STATEMENT: Whenever we want to execute a particular block of statements among many blocks

then we will choose select case statement.

Syntax: SELECT CASE var

CASE1

-----------

---------

CASE2

---------

----------

ELSE CASE

----------

----------

END SELECT

LOOPING STATEMENTS:

Looping statements are used for executing a certain block of statements repeatedly and continuously for some

number of times.

1. FOR---NEXT: It is used for executing a block of statements repeatedly for certain number of times.

Syntax: FOR I=1 TO 10 STEP 1

----------------

-------------

NEXT

2. WHILE-----WEND: It is used for executing a block of statements repeatedly as long as the condition is being

satisfied.

Syntax: WHILE <CONDITION>

------------

------------

WEND

3. DO WHILE---LOOP: It is used for executing a block of statements repeatedly as long as the condition is being

satisfied.

Syntax: DO WHILE <CONDITION>

----------------

--------------

LOOP

4. DO-----LOOP WHILE: It is used for executing a block of statements repeatedly as long as the condition is being

satisfied, but first time execution will be done without checking the condition.

Syntax: DO

-------------

--------------

LOOP WHILE <CONDITION>

Page 42: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 42

5. DO UNTIL----LOOP: This loop is used for executing the block of statements repeatedly as long as the condition is

not being satisfied.

Syntax: DO UNTIL <CONDITION>

------------

-----------

LOOP

6. DO----LOOP UNTIL: This loop is used for executing the block of statements repeatedly as long as the condition is

not being satisfied, but first time execution will be done without checking the condition.

Syntax: DO

-----------

------------

LOOP UNTIL <CONDITION>

PROCEDURES: Procedures are used for reusability, whenever we want a task need to be performed again and again

many number of times in different situations and also may be in different programs then we will prepare one

procedure for that task and call that procedure any number of times in any number of programs.

There are 2 types of PROCEDURES:

1. FUNCTION PROCEDURES

2. SUB PROCEDURES

1. Function Procedures can return a value, but Sub Procedures can’t returns a value.

2. Sub Procedures will be executed more faster then Function Procedures, so whenever we no need to return any

value, it is better to use Sub Procedure.

Ex: Function Procedure:

FUNCTION ADD(a,b)

RESULT=A+B

ADD=RESULT

END FUNCTION

MAIN PRG:

VAR=ADD(10,20)

--------------

---------------

VAR1=ADD(20,30)

---------------

------------------

Ex: Sub Procedure:

SUB LOGIN(UN,PW)

------------- SET UN

------------- SET PW

------------- LOGIN, CLICK

END SUB

Page 43: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 43

MAIN PRG:

---------------------

------------------

LOGIN(“SURI”,”TESTING”)

----------------

----------------------

LOGIN(“RAVI”,”ENG”)

--------------

-----------------

Difference between Functions and Procedures:

1. Function returns a value, but a procedure may return or may not return a value.

2. Function can take only input arguments, but procedure may take both input and out put parameters.

REAL TIME SCENARIO WITH METHODS:

1. CAPTURE BITMAP: It is a method used for capturing the snapshot of any object and storing it in the desired

location during the execution.

Syntax: OBJECT HIERARCHY.CAPTURE BITMAP ”PATH OF THE LOCATION WITH FILE NAME.BMP EXTENSION”

Ex: WINDOW(“FLIGHT RESERVATION”)DIALOG(“OPEN ORDER”)WINBUTTON(“OK”).CAPTUREBITMAP “D:\SURI\DEFECT.BMP”

2. EXIST: It is a method used for checking whether the object is existing or not, if at all the object is existing than it

will return a value TRUE otherwise it will make the QTP wait till the object exists, soon after the object exists it will

return a value TRUE and allows the QTP for further execution. In case the object doesn’t exist till the maximum time

(Default time + Extra time) specified than finally it will return FALSE and allows the QTP for further execution.

Syntax: VAR=OBJECT HIERARCHY.EXIST[(TIME IN SECONDS)]

Ex: VAR=OBJECT HIERARCHY.EXIST(15)

3. WAIT PROPERTY: It is a method used for making the tool to wait based on the objects properties value or up to

the maximum time.

Syntax: OBJECT HIERARCHY.WAIT PEOPERTY ”PROPERTYNAME”

Ex: WINDOW(“FLIGHT RESERVATION”).WINBUTTON(“DELETE ORDER”).WAIT PROPERTY “ENABLED”,TRUE,1400

4. WAIT: It is a method used for making the tool to wait till the specified time is elapsed.

Syntax: WAIT(TIME IN SECONDS)

5. CLICK: It is a method used for clicking on a desired object.

Syntax: OBJECT HIERARCHY.CLICK [X,Y,[BUTTON]]

0-LEFT

1-RIGHT

2-CENTRE

6. DBL CLICK: It is a method used for double clicking on a desired object.

Syntax: OBJECT HIERARCHY.DBLCLICK[X,Y,[BUTTON]

0-LEFT

1-RIGHT

2-CENTRE

Page 44: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 44

7. SET: It is a method used for performing operations on the following objects:

1. EDIT BOX

2. CHECK BOX

3. RADIO BUTTON

EDIT BOX: It is a method used for setting any value into the edit box.

Syntax: OBJECT HIERARCHY.SET “VALUE”

Ex:

CHECK BOX: It is a method used for selecting or deselecting the check box.

Syntax: OBJECT HIERARCHY.SET “ON/OFF”

Ex:

RADIOBUTTON: It is a method used for selecting a radio button in a group of radio buttons.

Syntax: OBJECT HIERARCHY.SET

Ex:

CASE STUDY 1:

Develop the script for entering CID, CNAME, CAGE, CPHNO and click on SUBMIT.

VBWINDOW(“CUST”).VBEDIT(“CID”).SET “001”

VBWINDOW(“CUST”).VBEDIT(“CNAME”).SET “SURI”

VBWINDOW(“CUST”).VBEDIT(“CAGE”).SET “26”

VBWINDOW(“CUST”).VBEDIT(“CPHNO”).SET “9985621122”

VBWINDOW(“CUST”).VBBUTTON(“SUBMIT”).CLICK

CASE STUDY 2:

Develop the script for selecting the STE, ISTQB, and SQL SERVER check boxes and clicking on NEXT button.

SURENDRA

Page 45: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 45

NEXT

SRSS:

STE

QTP

LR

LIVE PROJECT

ISTQB

SQL SERVER

VBWINDOW(“SRSS”).VBCHECKBOX(“STE”).SET “ON”

VBWINDOW(“SRSS”).VBCHECKBOX(“ISTQB”).SET “ON”

VBWINDOW(“SRSS”).VBCHECKBOX(“SQL SERVER”).SET “ON”

VBWINDOW(“SRSS”).VBCHECKBOX(“NEXT”).SET “ON”

CASE STUDY 3:

Develop the script for deselecting the STE check box, selecting the QTP and LIVE PROJECT check boxes and clicking on

NEXT button.

SRSS:

STE

QTP

LR

LIVE PROJECT

ISTQB

SQL SERVER

VBWINDOW(“SRSS”).VBCHECKBOX(“STE”).SET “OFF”

VBWINDOW(“SRSS”).VBCHECKBOX(“ISTQB”).SET “ON”

VBWINDOW(“SRSS”).VBCHECKBOX(“SQL SERVER”).SET “ON”

VBWINDOW(“SRSS”).VBCHECKBOX(“NEXT”).SET “ON”

CASE STUDY 4:

Develop the script for entering the COUNTRY, AGE, GENDER, selecting the check box PHOTO PROFILES ONLY and

clicking on SEARCH button.

NEXT

Page 46: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 46

MATRIMONY:

COUNTRY:

AGE:

MALE

FEMALE

PHOTO PROCESS ONLY

VBWINDOW(“MATRIMONY”).VBEDIT(“COUNTRY”).SET “INDIA”

VBWINDOW(“MATRIMONY”).VBEDIT(“AGE”).SET “26”

VBWINDOW(“MATRIMONY”).VBRADIOBUTTON(“FEMALE”).SET

VBWINDOW(“MATRIMONY”).VBCHECKBOX(“PHOTO PROCESS ONLY).SET “ON”

VBWINDOW(“MATRIMONY”).VBBUTTON(“SEARCH”).CLICK

8. SELECT: It is a method used for selecting an item from a combo box or list box.

Syntax: OBJECT HIERARCHY.SELECT “ITEM”

CASE STUDY 5:

Develop the script for entering TRAIN NO, TRAIN NAME, and selecting the STARTING POINT and DESTINATION, entering the DOJ,

selecting the CLASS, BIRTH, selecting the BREAKFAST, LUNCH, or DINNER checkboxes and clicking on NEXT.

RESERVATION:

TRAIN NO:

TRAIN NAME:

FROM:

TO:

DOJ:

FIRST A/C UB

SECOND A/C MB

SLEEPER LB

BREAKFAST

LUNCH

DINNER

VBWINDOW(“RESERVETION”).VBEDIT(“TRAIN NO”).SET “1234”

VBWINDOW(“RESERVETION”).VBEDIT(“TRAIN NAME”).SET “RAYALASEEMA”

VBWINDOW(“RESERVETION”).VBCOMBOBOX(“FROM”).SELECT “HYD”

VBWINDOW(“RESERVETION”).VBCOMBOBOX(“TO”).SELECTT “KMP”

VBWINDOW(“RESERVETION”).VBEDIT(“DOJ”).SET “121210”

SEARCH

SEARCH

Page 47: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 47

VBWINDOW(“RESERVETION”).VBRADIOBUTTON(“FIRST A/C”).SET

VBWINDOW(“RESERVETION”).VBRADIOBUTTON(“UB”).SET

VBWINDOW(“RESERVETION”).VBCHECKBOX(“BREAKFAST”).SET “ON”

VBWINDOW(“RESERVETION”).VBCHECKBOX(“LUNCH”).SET “ON”

VBWINDOW(“RESERVETION”).VBCHECKBOX(“DINNER”).SET “ON”

VBWINDOW(“RESERVETION”).VBBUTTON(“NEXT”).CLICK

9. ACTIVATE: It is a method used for activating a dialog or a window.

Syntax: OBJECT HIERARCHY.ACTIVATE

10. CLOSE: It is a method used for closing a window.

Syntax: OBJECT HIERARCHY.CLOSE

11. TYPE: It is a method used for performing the keyboard related operations

Syntax: OBJECT HIERARCHY.TYPE “KEY VALUE”

Ex: OBJECT HIERARCHY.TYPE MICTAB

12. SET SECURE: It is a method used for setting the encrypted data into the edit box.

Syntax: OBJECT HIERARCHY.SET SECURE “ENCRYPTED STRING”

NOTE: To generate the encrypted string QTP has provided special tool by name PASSWORD ENCODER.

NAVIGATION: START------>PROGRAMS-------->QTP-----TOOLS----------->PASSWORD ENCODER.

13. GET RO PROPERTY: It is A method used for getting the run time objects properties value during the execution.

Syntax: VAR=OBJECT HIERARCHY.GETROPROPERTY (“PROPERTY NAME”)

14. GET TO PROPERY: It is a method used for getting the test objects properties value.

Syntax: OBJECT HIERARCHY.GETTOPROPERTY (“PROPERTY NAME”)

CASE STUDY 6:

Develop the script for clicking on OK button, if it is existing and enabled.

FORM:

OK

Page 48: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 48

VAR=VBWINDOW(“FORM”).VBBUTTON(“OK”).EXIST

IF (VAR=TRUE) THAN

VAR1= VAR=VBWINDOW(“FORM”).VBBUTTON(“OK”).GETROPROPERY (“ENABLED”)

IF (VAR1=TRUE) THAN

VAR=VBWINDOW(“FORM”).VBBUTTON(“OK”).CLICK

ELSE

REPORTER.REPORTEVENT 3,”MYREP”,”OK BUTTON IS DISABLED”

ENDIF

ELSE

REPORTER,REPORTEVENT 3,”MYREP”,”OK BUTTON IS NOT EXIST”

ENDIF

CASE STUDY 7:

Develop the script for selecting the PID, entering the QUANTITY, PNAME, RATE, clicking on CAL button and checking

whether it is working fine or not.

PRODUCT:

PID:

PNAME:

PRATE:

QUANTITY:

AMOUNT:

VBWINDOW(“PRODUCT”).VBCOMBOBOX(“PID”).SELECT “007”

Q=6

R= VBWINDOW(“PRODUCT”).VBEDIT(“PRATE”).GETROPROPERY(“TEXT”)

EV=R*Q

VBWINDOW(“PRODUCT”).VBEDIT(“QUANTITY”).SET Q

VBWINDOW(“PRODUCT”).VBBUTTON(“CAL”).CLICK

AV= VBWINDOW(“PRODUCT”).VBEDIT(“AMOUNT”).GETROPROPERTY(“TEXT”)

IF(EV=AV) THEN

REPORTER.REPORTEVENT 0,”MYREP”,”CAL BUTTON WORKING PROPERLY”

ELSE

REPORTER.REPORTEVENT 1,”MYREP”,”CAL BUTTON NOT WORKING PROPERLY”

ENDIF

CASE STUDY 8:

Develop the script for selecting the PID, entering the QUANTITY, PNAME, RATE, clicking on CAL button, if it is existing

and enabled and checking whether the CAL button is working properly or not.

CAL

Page 49: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 49

PRODUCT:

PID:

PNAME:

PRATE:

QUANTITY:

AMOUNT:

VBWINDOW(“PRODUCT”).VBCOMBOBOX(“PID”).SELECT “007”

Q=2

VBWINDOW(“PRODUCT”).VEDIT(“QUANTITY”).SET Q

RATE= VBWINDOW(“PRODUCT”).VBEDIT(“PRATE”).GETROPROPERY(“TEXT”)

EV=RATE*Q

V1=VBWINDOW(“PRODUCT”).VBBUTTON(“CAL”).EXIST

IF(V1=TRUE) THEN

ENV= VBWINDOW(“PRODUCT”).VBBUTTON(“CAL”).GETROPROPERTY(“ENABLED”)

IF(ENV=TRUE) THEN

VBWINDOW(“PRODUCT”).VBBUTTON(“CAL”).CLICK

ACTVAL=VBWINDOW(“PRODUCT”).VBEDIT(“AMOUNT”).GETPROPERTY.”TEXT”

IF(ACTVAL=EV) THEN

REPORTER.REPORTEVENT 0,”MYREP”,”CAL BUTTON WORKING PROPERLY”

ELSE

REPORTER.REPORTEVENT 1,”MYREP”,”CAL BUTTON NOT WORKING PROPERLY”

ENDIF

ELSE

REPORTER.REPORTEVENT 1,”MYREP”,”CAL BUTTON IS ENABLED”

ENDIF

ELSE

REPORTER.REPORTEVENT 1,”MYREP”,”CAL BUTTON IS NOT EXIST”

ENDIF

CASE STUDY 9:

Develop the script for entering 10 into VAL1, 20 into VAL2 and clicking on ADD button, if it is existing, enabled and

checking whether it is working properly or not.

CAL:

VAL1:

VAL2:

RESULT:

CAL

ADD

Page 50: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 50

VBWINDOW(“CAL”).VBEDIT(“VAL1”).SET “10”

VBWINDOW(“CAL”).VBEDIT(“VAL1”).SET “20”

EV=30

V1= VBWINDOW(“CAL”).VBBUTTON(“ADD”).EXIST

IF(V1=TRUE) THEN

V2= VBWINDOW(“CAL”).VBBUTTON(“ADD”).GETROPROPERTY “ENABLED”

IF(V2=TRUE) THEN

VBWINDOW(“CAL”).VBBUTTON(“ADD”).CLICK

AV= VBWINDOW(“CAL”).VBEDIT(“RESULT”).GETROPROPERTY “TEXT”

IF(CINT(AV)=CINT(EV)) THEN

REPORTER.REPORTEVENT 0,”MYREP”,”ADD BUTTON WORKING PROPERLY”

ELSE

REPORTER.REPORTEVENT 1,”MYREP”,”ADD BUTTON NOT WORKING PROPERLY”

ENDIF

ELSE

REPORTER.REPORTEVENT 1,”MYREP”,”ADD BUTTON IS ENABLED”

ENDIF

ELSE

REPORTER.REPORTEVENT 1,”MYREP”,”ADD BUTTON DOESN’T EXIST”

ENDIF

15. SET TO PROPERTY: It is a method used for setting the test objects properties value temporarily during the

execution.

Syntax: OBJECT HIERARCHY.SETTOPROPERTY “PROPERTY NAME”, “PROPERTY VALUE”

CASE STUDY 10:

Develop a script for clicking on a button 3 times, whose text property value is changing from START to STOP and

STOP to START dynamically.

FORM:

START

FORM

OR

DBUTTON

NATIVE CLASS-BUTTON

TEXT-START

DYNAMIC BUTTON

Page 51: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 51

VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).CLICK

VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).SETTOPROPERTY “TEXT”, “STOP”

VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).CLICK

VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).SETTOPROPERTY “TEXT”, “START”

VBWINDOW(“FOR”).VBBUTTON(“DBUTTON”).CLICK

SIMPLE VB SCRIPT FUNCTIONS USED DURING COMPARISION AND CALCULATIONS:

1. CINT: it is used for converting any value into integer value.

2. CDBL: It is used for converting any value into double value or decimal value.

3. CSTR: It is used for converting any value into string value.

4. CBOOL: It is used for converting any value into Boolean value.

5. LTRIM: It is used for trimming the left side spaces.

6. RTRIM: It is used for trimming right side spaces.

7. TRIM: It is used for trimming the both side spaces.

Ex:

IF (CINT(EV)=CINT(LTRIM(AV))) THEN

---------------------

-----------------

ELSE

-----------------

---------------------

ENDIF

8. LEFT: It is used for getting the left side substring.

9. RIGHT: It is used for getting the right side substring.

10. MID: It is used for getting the middle substring.

11. LEN: It is used for getting the length of a string.

Ex:

VAR=”SURENDRA”

VAR1=LEFT(VAR,4)-----------SURE

VAR2=RIGHT(VAR,3)---------DRA

VAR3=MID(VAR,3,3)---------REN

VAR4=MID(VAR,2,4)---------UREN

VAR5=LEN(VAR)---------------8

12. UCASE: It is used for converting the string into upper case.

13. LCASE: It is used for converting the string into lower case.

14. ROUND: It is used for rounding a value to the nearest integer.

Page 52: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 52

BATCH TESTING/EXECUTION: It is a concept provided in QTP used for executing the group of script files continuously

at a time. To do the same QTP has provided a special tool by name TEST BATCH RUNNER. By using it one can create

the batch files and execute them comfortably.

Note: BATCH FILE EXTENSION IS .MTB (MERCURY TEST BATCH/MODULE TEST BATCH).

Note: BATCH TESTING CONCEPT IS USALLY USED DURING REGRESSION TESTING.

NAVIGATION:

START----->PROGRAMS------>QTP--------->TOOLS----->TEST BATCH RUNNER.

QTP----->TOOLS----->OPTIONS------>RUN------>CHECK [ALLOW THE MERCURY PRODUCTS TO RUN TEST AND COMMANDS].

3. DATA TABLE METHODS: Data Table Methods are used for making the QTP perform operations on the runtime

data table during the execution.

1. ADD SHEET: It is used for adding an extra sheet to the runtime data table.

Syntax: DATATABLE.ADD SHEET “SHHET NAME”

2. DELETE SHEET: It is used for deleting a specified sheet from runtime data table.

Syntax: DATATABLE.DELETE SHEET “SHEET NAME”

3. IMPORT: It is used for importing the complete data present in the excel file to the run time data table.

Syntax: DATATABLE.IMPORT “PATH OF THE EXCEL FILE”

4. IMPORT SHEET: It is used for importing the specified sheet of data from excel file to a specified sheet in the run

time data table.

Syntax: DATATABLE.IMPORT SHEET “PATH OF THE EXCEL FILE”, “SOURCE SHEET ID”,”DESTINATION SHEET ID”

5. EXPORT: It is used for capturing all the sheets of data present in the run time data table to an excel file.

Syntax: DATATABLE.EXPORT “PATH OF THE EXCEL FILE”

6. EXPORT SHEET: It is used for exporting a specified sheet of data from the run time data table to an excel file.

Syntax: DATATABLE.EXPORT SHEET “PATH OF THE EXCEL FILE”,”SHEET ID TO BE EXPORTED”

7. SET CURRENT ROW: It is used making the QTP focus on specified row.

Syntax: DATATABLE.SETCURRENTROW(ROW NUMBER)

8. SET NEXT ROW: It is used for making the QTP focus on the next row of the currently focused row.

Syntax: DATATABLE.SETNEXTROW

9. SET PREV ROW: It is used for making the QTP focus on the previous row of the currently focused row.

Syntax: DATATABLE.SETPREVROW

10. VALUE: It is used for getting the value from the specified sheet, specified column and the currently focused row.

Syntax: VAR=DATATABLE(“COLUMN NAME”,”SHEET ID”/”SHEET NAME”)

11. GET SHEET: it is used for making the QTP focus on a specified sheet.

Syntax: DATATABLE.GETSHEET(SHEET ID)

Page 53: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 53

12. GET ROW COUNT: It is used for getting the row count of any specified sheet. By default it will get the row count

of global sheet, if we don’t focus any sheet.

Syntax 1: VAR=DATATABLE.GETROWCOUNT

Syntax 2: VAR=DATATABLE.GETSHEET(SHEET ID).GETROWCOUNT

Ex:

DATATABLE.ADDSHEET “SURENDRA”

DATATABLE.IMPORTSHEET “D:\SURI\TD1.XLS”,1,3

N=DATATABLE.GETSHEET(3).GETROWCOUNT

FOR I=1 TO N

DATATABLE.SETCURRENTROW(I)

VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE1”).SET DATATABLE(“V1”,3)

VBWINDOW(“CALCULATOR”).VBEDIT(“VALUE1”).SET DATATABLE(“V2”,3)

VBWINDOW(“CALCULATOR”).VBBUTTON(“ADD”).CLICK

ACTVAL= VBWINDOW(“CALCULATOR”).VBEDIT(“RESULT”).GETPROPERTY(“TEXT”)

EXPVAL=DATATABLE(“EV”,3)

IF(CINT(EXPVAL)=CINT(ACTVAL)) THEN

REPORTER.REPORTEVENT 0,”MYREP”,”ADD OPERATION IS SUCCESS”

DATATABLE(“RES”,3)=”PASS”

ELSE

REPORTER.REPORTEVENT 0,”MYREP”,”ADD OPERATION IS NOT SUCCESS”

DATATABLE(“RES”,3)=”FAIL”

ENDIF

NEXT

DATATABLE.EXPORTSHEET “D:\SURI\LOG\LOGFILE1.XLS”,3

DATATABLE.DELETESHEET “SURENDRA”

CHECK SYNTAX: It is a feature provided by QTP used for checking the syntax in our script or program.

5. INFORMATION PANE: It is an area provided by QTP, which is used for viewing the syntax related information

during the syntax check.

6. MISSING RESOURCES PANE: While opening any test, if at all any attached resources are missing then that

information will be shown in the missing resources pane.

Page 54: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 54

7. TOOL OPTIONS (SHORTCUTS):

S.No. SHORTCUT DISCRIPTION

1 CTRL+S SAVE

2 CTRL+0 OPENS AN EXISTING TEST

3 CTRL+SHIFT+O OPENS AN EXISTING BUSSINESS OR SCRIPTED COMPONENT

4 CTRL+ALT+O OPENS AN EXISTING APPLICATION AREA

5 SHIFT+ALT+O OPENS AN EXISTING FUNCTION LIBRARY

6 CTRL+ALT+I IMPORTS A DOCUMENT FROM ZIP FILE

7 CTRL+SHIFT+SPACE DISPLAYS A SYNTAX OF A METHOD

8 CTRL+ALT+S EXPORT TEST TO ZIP FILE

9 CTRL+ALT+M IMPORT TEST TO ZIP FILE

10 CTRL+P PRINT

11 CTRL+Z UNDO

12 CTRL+Y REDO

13 CTRL+C COPY

14 CTRL+V PASTE

15 CTRL+X CUT

16 DELETE DELETE

17 CTRL+I INSERT

18 CTRL+K DELETE

19 CTRL+R FILL RIGHT

20 CTRL+D FILL DOWN

21 F9 RECALCULATES THE SELECTED DATA IN THE DATATABLE

22 CTRL+PAGE DOWN/PAGE UP TOGGLES BETWEEN KEYWORD VIEW AND EXPERT VIEW

23 CTRL+TAB CHANGES THE DISPLAY TO ANOTHER OPEN DOCUMENT TYPE

24 SHIFT+F10 OPENS CONTEXT MENU

25 CTRL+F FIND

26 CTRL+H REPLACE

27 CTRL+G GOTO

28 CTRL+B BOOK MARKS

29 F7 STOP GENERATOR

30 F8;INSERT NEW STEP

31 SHIFT+F8 NEW STEP AFTER BLOCK

32 F3 RECORD

33 F5 RUN

34 F4 STOP

Page 55: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 55

35 CTRL+F5 RUN FROM STEP

36 SHIFT+ALT+F3 ANALOG RECORDING

37 CTRL+SHIFT+F3 LOW LEVEL RECORDING

38 CTRL+R OBJECT REPOSITORY

39 F11 STEP INTO

40 F10 STEP OVER

41 SHIFT+F11 STEP OUT

42 CTRL+F10 RUN TO STEP

43 CTRL+T ADD TO WATCH

44 F9 INSERT/REMOVE BREAKPOINT

45 CTRL+F9 ENABLE/DISABLE BREAKPOINT

46 CTRL+SHIFT+F9 CLEAR ALL

47 CTRL+F7 CHECK SYNTAX

48 F12 STANDARD CHECK POINT

49 CTRL+F12 CHECK SYNTAX

50 SHIFT+F12 STANDARD OUTPUT VALUE

51 CTRL+ENTER;ALT+ENTER OBJECT PROPERTIES

52 CTRL+M COMMENT BLOCK

53 CTRL+SHIFT+M UN COMMENT BLOCK

54 ALT+G GOTO FUNCTION DEFINATION

55 CTRL+SPACE COMPLETE WORD

56 CTRL+SHIFT+SPACE ARGUMENT INFO

57 CTRL+W APPLY “WITH” TO SCRIPT

58 CTRL+SHIFT+W REMOVE “WITH” TO STATEMENTS

59 CTRL+N NEW TEST

60 CTRL+SHIFT+N BUSSINESS COMPONENT

61 CTRL+ALT+N APPLICATION AREA

62 SHIFT+ALT+N FUNCTION LIBRARY

63 SHIFT+F4/SPACE TO OPEN THE LIST FOR THAT CELL

64 SHIFT+TAB TO MOVE THE FOCUS LEFT OR RIGHT WITH IN A SINGLE ROW, UNLESS YOU ARE IN A CELL

THAT IS IN A EDIT MODE, AND THEN YOU CAN USE TAB KEYS

65 ALT+F4 CLOSE THE APPLICATION

66 ALT+SPACE+C CLOSE THE APPLICATION

67 ALT+F+X EXIT

68 F1 HELP

Page 56: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 56

VIRTUAL OBJECT CONFIGURATION: It is a process of making the QTP to treat an user defined object or a specified

area in an application as a VIRTUAL OBJECT, once created VIRTUAL OBJECT will be permanently remembered by QTP,

unless until we delete them.

NAVIGATION:

Activate the menu item tools.

Go to Virtual Objects.

Select the option new Virtual Object.

Click on next.

Select the desired standard class.

Click on next.

Mark the object.

Click on next.

Select one of the following options:

o Entire parent hierarchy

o Parent only

Click on next.

Specify the object name.

Specify the collection name.

Click on Finish.

Ex:

VBWINDOW(“FORM”).ACTIVATE

VBWINDOW(“FORM”).CLICK 250,34

VBWINDOW(“FORM”).VIRTUALBUTTON(“VIRBUTTON”).CLICK

VBWINDOW(“FORM”).CLICK 266,124

VBWINDOW(“FORM”).CLICK 222,54

REGULAR EXPRESSIONS: Whenever the QTP is unable to identify the object, due to regular changes in its properties

values dynamically than to solve that problem one need to replace the corresponding constant value in the object

repository with a suitable regular expression.

NAVIGATION:

Open the object repository.

Select the desired object.

Select the desired property value.

Click on configure the value button.

Replace the constant value with suitable regular expression.

Select the check box Regular Expression.

Click on OK.

Ex:

Record the Flight Faxing order.

Change the Fax Order properties through Object repository.

Set the Fax Order---Text-----Fax Order-------Fax Order.* through configure the value.

Enhance the script as follows:

Page 57: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 57

WINDOW("FLIGHT RESERVATION").ACTIVATE

WINDOW("FLIGHT RESERVATION").WINMENU("MENU").SELECT "FILE;OPEN ORDER..."

WINDOW("FLIGHT RESERVATION").DIALOG("OPEN ORDER").WINCHECKBOX("ORDER NO.").SET "ON"

WINDOW("FLIGHT RESERVATION").DIALOG("OPEN ORDER").WINEDIT("EDIT").SET "5"

WINDOW("FLIGHT RESERVATION").DIALOG("OPEN ORDER").WINBUTTON("OK").CLICK

WINDOW("FLIGHT RESERVATION").WINMENU("MENU").SELECT "FILE;FAX ORDER..."

WINDOW("FLIGHT RESERVATION").DIALOG("FAX ORDER NO. 5").ACTIVEX("MASKEDBOX").TYPE "11111111111"

WINDOW("FLIGHT RESERVATION").DIALOG("FAX ORDER NO. 5").WINBUTTON("SEND").CLICK

WINDOW("FLIGHT RESERVATION").CLOSE

DATA TABLE:

NO. TEXT

1 12

2 6

3 4

4 8

5 14

6 16

INPUT/OUTPUT PARAMETERS: It is a concept provided by the QTP, which is used for passing the values into the

Action and returning the values from the Action.

NAVIGATION FOR DECLARING THE INPUT/OUTPUT PARAMETERS:

Activate the menu item edit.

Go to Action.

Select the option Action properties.

Select the parameters tab.

Specified the desired number of Input and Output parameters.

Click on OK.

Ex: USING INPUT/OUTPUT PARAMETERS:

VBWINDOW("CALCULATOR").ACTIVATE

VBWINDOW("CALCULATOR").VBEDIT("VALUE1").SET PARAMETER("A")

VBWINDOW("CALCULATOR").VBEDIT("VALUE2").SET PARAMETER("B")

VBWINDOW("CALCULATOR").VBBUTTON("ADD").CLICK

VAR1=VBWINDOW("CALCULATOR").VBEDIT("RESULT").GETROPROPERTY ("TEXT")

PARAMETER("C")=VAR1

VBWINDOW("CALCULATOR").VBBUTTON("SUB").CLICK

VAR2=VBWINDOW("CALCULATOR").VBEDIT("RESULT").GETROPROPERTY ("TEXT")

PARAMETER("D")=VAR2

VBWINDOW("CALCULATOR").VBBUTTON("MUL").CLICK

VAR3=VBWINDOW("CALCULATOR").VBEDIT("RESULT").GETROPROPERTY ("TEXT")

PARAMETER("E")=VAR3

VBWINDOW("CALCULATOR").VBBUTTON("CLEAR").CLICK

VBWINDOW("CALCULATOR").CLOSE

Page 58: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 58

Ex: CALLING AN ACTION BY PASSING INPUT VALUES AND SPECIFYING THE VARIABLES FOR CAPTURING THE RETURN VALUES:

GO TO----->INSERT----->CALL TO EXISTING ACTION---->SPECIFY THE FILE AND ACTION---------->OK.

RUNACTION "ACTION1 [TEST1]", ONEITERATION,10,20,R1,R2,R3

MSGBOX R1

MSGBOX R2

MSGBOX R3

DYNAMIC HANDLING OF OBJECT REPOSITORIES: This is a concept provided in QTP used for associating and

removing the object repositories during the execution dynamically to do the same QTP has provided a utility object

by name REPOSITORIESCOLLECTION.

Ex:

REPPATH="C:\USERS\SURI\DESKTOP\TSR1.TSR"

REPOSITORIESCOLLECTION.REMOVEALL

REPOSITORIESCOLLECTION.ADD(REPPATH)

VBWINDOW("VBWINDOW").VBEDIT("VBEDIT_1").SET "10"

VBWINDOW("VBWINDOW").VBEDIT("VBEDIT_2").SET "20"

VBWINDOW("VBWINDOW").VBBUTTON("ADD").CLICK

VBWINDOW("VBWINDOW").CLOSE

VAR=REPOSITORIESCOLLECTION.FIND(REPPATH)

MSGBOX VAR

REPOSITORIESCOLLECTION.REMOVE(VAR)

NOTE:

REPOSITORIESCOLLECTION.REMOVEALL: Used to remove the previous repositories from the Test.

REPOSITORIESCOLLECTION.ADD: Used to associate the repository to the Test.

REPOSITORIESCOLLECTION.FIND: Used to find the position of the repository. Before removing we have to find the repository.

REPOSITORIESCOLLECTION.REMOVE: Used to remove the association of the repository from the Test. In order to increase the

performance, if there are more no of repositories to the Test.

AUTOMATION OBJECT MODEL: It is a concept introduced in QTP, which is used for automating the operations on

QTP through scripting.

Ex:

DEVELOP THE FOLLOWING SCRIPT IN NOTEPAD AS .VBS FILE:

DIM QTAPP

DIM QTTEST

SET QTAPP=CREATEOBJECT("QUALIFICATION.APPLICATION")

QTAPP.LAUNCH

QTAPP.VISIBLE=TRUE

QTAPP.OPEN "D:\TEST1",TRUE

SET QTTEST=QTAPP.TEST

QTTEST.RUN

QTTEST.CLOSE

QTAPP.OPEN "D:\TEST2",TRUE

SET QTTEST=QTAPP.TEST

QTTEST.RUN

QTTEST.CLOSE

QTAPP.QUIT

Page 59: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 59

CLASS NAME----------OBJECT-------------METHOD.

Double Click on the .VBS file.

DATABASE CONNECTIONS:

Ex:

DATABASE CONNECTION TO ACCESS:

DIM CON,RS

SET CON=CREATEOBJECT("ADODB.CONNECTION")

SET RS=CREATEOBJECT("ADODB.RECORDSET")

CON.PROVIDER="MICROSOFT.JET.OLEDB 4.0"

CON.OPEN= "D:\DB1.MDB"

RS.OPEN "SELECT * FROM INFO",CON

DO UNTIL RS.EOF

VBWINDOW("CALCULATOR").VBEDIT("VALUE1").SET RS.FIELDS("V1")

VBWINDOW("CALCULATOR").VBEDIT("VALUE2").SET RS.FIELDS("V2")

VBWINDOW("CALCULATOR").VBBUTTON("ADD").CLICK

RS.MOVENEXT

LOOP

DATABASE CONNECTION TO ORACLE:

CON.PROVIDER=ORAOLEDB.1;SERVER=LOCALHOST;UID=SCOTT;PWD=TIGER;DATABASE=TESTDATA”

DATABASE CONNECTION TO SQL SERVER:

CON.PROVIDER=SQLOLEDB.1;SERVER=LOCALHOST;UID=SURI;PWD=TESTING;DATABASE=TESTDATA”

DYNAMIC HANDLING OF FILE SYSTEM: It is a concept provided by QTP used for performing the operations on the file

system dynamically during the execution.

Ex:

DIM FSO,VAR

SET FSO=CREATEOBJECT("SCRIPTING.FILESYSTEMOBJECT")

SET MYFILE=FSO.OPENTEXTFILE("D:\LOGFILE96.TXT",2,TRUE)

VBWINDOW("CALCULATOR").VBEDIT("VALUE1").SET "10"

VBWINDOW("CALCULATOR").VBEDIT("VALUE2").SET "20"

VBWINDOW("CALCULATOR").VBBUTTON("ADD").CLICK

VAR=VBWINDOW("CALCULATOR").VBEDIT("RESULT").GETROPROPERTY("TEXT")

MYFILE.WRITELINE("THE RESULT IS: "& VAR)

MYFILE.CLOSE

Note: MODES: 1-READ, 2-WRITE, And 8-APPEND.

Page 60: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 60

DESCRIPTIVE PROGRAMMING: If at all the objects description is described in the program itself, then that is known

as descriptive programming.

NORMAL SCRIPT DEVELOPED THROUGH RECORDING WHEN OBJECTS INFORMATION PRESENT IN THE OBJECT REPOSITORY:

DIALOG("LOGIN").ACTIVATE

DIALOG("LOGIN").WINEDIT("AGENT NAME:").SET "SURI"

DIALOG("LOGIN").WINEDIT("PASSWORD:").SETSECURE "4B6156E1859AA4023F50BCA2E414AAC3732C88D7"

DIALOG("LOGIN").WINBUTTON("OK").CLICK

STATIC DESCRIPTIVE: 1ST STYLE:

SCRIPT DEVELOPED MANUALLY WHEN OBJECTS INFORMATION NOT PRESENT IN THE OBJECT REPOSITORY:

DIALOG("TEXT:=LOGIN","WIDTH:=320").ACTIVATE

DIALOG("TEXT:=LOGIN","WIDTH:=320").WINEDIT("ATTACHED TEXT:=AGENT NAME:").SET "SURI"

DIALOG("TEXT:=LOGIN","WIDTH:=320").WINEDIT("ATTACHED TEXT:=PASSWORD:").SETSECURE

"4B6156E1859AA4023F50BCA2E414AAC3732C88D7"

DIALOG("TEXT:=LOGIN","WIDTH:=320").WINBUTTON("TEXT:=OK").CLICK

STATIC DESCRIPTIVE: 2ND STYLE:

SCRIPT DEVELOPED MANUALLY WHEN OBJECTS INFORMATION NOT PRESENT IN THE OBJECT REPOSITORY AND DECLARING THE

OBJECTS PROPERTIES GLOBALLY:

SET LIN=DESCRIPTION.CREATE

LIN("TEXT").VALUE="LOGIN"

LIN("WIDTH").VALUE="320"

SET AN=DESCRIPTION.CREATE

AN("ATTACHED TEXT").VALUE="AGENT NAME:"

SET PW=DESCRIPTION.CREATE

PW("ATTACHED TEXT").VALUE="PASSWORD:"

SET OK=DESCRIPTION.CREATE

OK("TEXT").VALUE="OK"

DIALOG(LIN).ACTIVATE

DIALOG(LIN).WINEDIT(AN).SET "SURI"

DIALOG(LIN).WINEDIT(PW).SETSECURE "4B6156E1859AA4023F50BCA2E414AAC3732C88D7"

DIALOG(LIN).WINBUTTON(OK).CLICK

DYNAMIC DESCRIPTIVE: 3RD

STYLE:

DEFINING THE OBJECT INFORMATION IN THE LIBRARY FILE. ATTACH THE LIBRARY FILE TO THE REQUIRED TEST, AND DEVELOP

THE SCRIPT AS FOLLOWS:

Page 61: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 61

DIALOG(LIN).ACTIVATE

DIALOG(LIN).WINEDIT(AN).SET "SURI"

DIALOG(LIN).WINEDIT(PW).SETSECURE "4B6156E1859AA4023F50BCA2E414AAC3732C88D7"

DIALOG(LIN).WINBUTTON(OK).CLICK

FEATURES IN LATEST VERSION 10.0:

Centrally manage and share Testing assets, Dependencies, and Versions in Quality Center 10.0.

System monitoring while running your Tests.

Improve portability by saving copies of Tests together with their Resource files.

Call Actions dynamically during the Test run.

Develop your own Bitmap checkpoint comparison algorithm.

Centrally manage your work items and to do tasks in the to do pane.

Improve Test results, Analysis with new Reporting functionality.

Test standard and custom Delphi objects using the Delphi add-in and Delphi add-in extensibility.

Page 62: 02 test automation functional testing (qtp)

TEST AUTOMATION_FUNCTIONAL TESTING PCSR

PC SURENDRA REDDY

Page 62

PPCC SSUURREENNDDRRAA RREEDDDDYY MM..CC..AA..

[email protected]