thomson reuters qtp training presentation

127
Kumar Kothuru Amarendra K Quick Test Professional 1 Training December 16th, 2009

Upload: sravan-vasireddy

Post on 11-Nov-2014

3.335 views

Category:

Education


0 download

DESCRIPTION

QTP Training

TRANSCRIPT

Page 1: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Am

are

ndra

Kum

ar

Koth

uru

Quick Test Professional

1

Training

December 16th, 2009

Page 2: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Introduction to Automation Testing 3

• VB Scripting Concepts 11

• Introduction to QTP 19

• QTP Record & Playback 28

• Actions 34

• Object Repository 43

• Types of Objects 57

• Data Parameterization 60

Concepts

Am

are

ndra

Kum

ar

Koth

uru

• Data Parameterization 60

• Synchronization 68

• Check Points & Output Values 75

• Transaction Points 86

• QTP Options & Test Settings 88

• Test Results 96

• Descriptive Programming 99

• Regular Expressions 106

• Functions & Library Files 110

• Recovery Scenarios & Error Handling 113

• File System Handling 120

• Database Handling 123

2

Page 3: Thomson reuters qtp training presentation

Introduction to Automation Testing

3

Introduction to Automation Testing

Page 4: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Software Test Automation is the process of automating the steps of manual testcases using an automation tool Or utility to shorten the testing life cycle withrespect to time…

• When application undergoes regression, some of the steps might be missed out orskipped which can be avoided in Automation…

Introduction to Automation

Am

are

ndra

Kum

ar

Koth

uru

4

• Automation helps to avoid human errors and also expedite the testing process…

• To implement the Test Automation detailed planning and effort is required

• Automation saves time and effort which results in reduction of the Test life cycle…

Page 5: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Automation advantages..Automation advantages..

Advantages of Automated Testing

FAST Tests are run significantly faster than human users.

Reliable Tests perform precisely the same operations each time they arerun, thereby eliminating human error. Also reduces the chancesof missing out any scenario.

Am

are

ndra

Kum

ar

Koth

uru

5

of missing out any scenario.

Repeatable You can test how the Web site or application reacts afterrepeated execution of the same operations.

Programmable You can program sophisticated tests that bring out hiddeninformation

Comprehensive You can build a suite of tests that covers every feature in yourWeb site or application.

Reusable You can reuse tests on different versions of a Web site orapplication, even if the user interface changes.

Page 6: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Why we need Automation Testing?

Am

are

ndra

Kum

ar

Koth

uru

6

No TestingNo Testing Manual TestingManual Testing

� Time consuming

� Low reliability

� Human resources

� Inconsistent

Automated TestingAutomated Testing

� Speed

� Repeatability

� Programming capabilities

� Coverage

� Reliability

� Reusability

Page 7: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

When Automation is applicable?

• Regression Testing Cycles are long and iterative

• If the application is planned to have multiple releases /builds

• If it’s a long running application where in small

Am

are

ndra

Kum

ar

Koth

uru

7

• If it’s a long running application where in smallenhancements/ Bug Fixes keeps happening

• Test Repeatability is required

Page 8: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Which Test Cases to Automate?

� Tests that need to be run for every build of the application (sanity

level)

� Tests that use multiple data values for the same actions (data driven

tests)

� Tests that require detailed information from application internals (e.g.,SQL, GUI attributes)

Am

are

ndra

Kum

ar

Koth

uru

SQL, GUI attributes)

8

More repetitive execution?Better candidate for automation.

Page 9: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Which Test Cases Not to Automate?

� Usability testing– "How easy is the application to use?"

� One-time testing, "ASAP" testing– "We need to test NOW!"

� Ad hoc/random testing– based on intuition and knowledge of application

Am

are

ndra

Kum

ar

Koth

uru

– based on intuition and knowledge of application

� Tests without predictable results

9

Improvisation required?Poor candidate for automation.

Page 10: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

From Manual to Automated Testing

Perform user actions

1

Wait for processes to complete

2

Verify AUT functions as expected

3

Repeat steps until all applications are verified compliant

4

Am

are

ndra

Kum

ar

Koth

uru

10

Generate automated script

1Synchronize script playback to application performance

2

Add verification

3

Run test or suite of tests

4

Page 11: Thomson reuters qtp training presentation

VB Scripting Concepts

11

VB Scripting Concepts

Page 12: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Variables/Objects – Dim, Set, Const, Option Explicit, Option Implicit

• If -Then – ElseIf - Else – End If Conditional Statements

• Select Case

• Control Structures

• For – Next

VB Scripting Overview

Am

are

ndra

Kum

ar

Koth

uru

• For Each – Next

• While – Wend

• Do While/Until – Loop

• Do - Loop – While/Until Condition

• Sub Routines and Functions

• Arrays

• VB Script Methods – StrComp, Len, Mid, Date, Now, Instr, Msgbox, Trim, Join, Split, CreateObject etc…

12

Page 13: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Dim – used to declare a variable and the variable is treated as a variant. At run-time,based on the value type, memory will be allocated to the variable based on the datatype of value user assign to it. It is not mandatory to declare variable in VB Script.

• Set – It is mandatory to use this while assigning any type of object to a variable.

E.g. Set obj = CreateObject(“ADODB.Connection”)

• Option Explicit – used to make the variable declaration is mandatory. If not

VB Scripting Concepts

Am

are

ndra

Kum

ar

Koth

uru

• Option Explicit – used to make the variable declaration is mandatory. If notdeclared, user will get error message.

• Option Implicit – By default VB Script uses this keyword in the back ground and itis not mandatory.

• Const – used to declare constants

E.g. Const var_Const = “Sony”

13

Page 14: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• If Then – ElseIf – Else

If <Condition 1> Then

Statement 1

ElseIf <Condition 2> Then

Statement 2

Else

• Simple If Then

If <Condition> Then

Statement 1

Statement 2 etc…

End If

• Select Case Statement• If Then Conditional Statements

• Select Case

Select Case expression

[Case expression-1

[statements-1]]

[Case expression-2

[statements-2]]

VB Scripting Concepts

Am

are

ndra

Kum

ar

Koth

uru

Else

Statement 3

End If

• If Then - Else

If <Condition> Then

Statement 1

Else

Statement 2

End IF

14

• Nested IfIf <Condition1> Then

Statement1Else

If <Condition 2> ThenStatement 2

ElseStatement 3

End IfEnd If

[Case expression-n

[statements-n]] ...

[Case Else

[else statements]]

End Select

Page 15: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• For … Next Statement

For counter = start To end [Step stepcounter]

[statements]

[Exit For]

[statements]

Next

• Control Structures• Do…While/Until… Loop Statement

Do [{While | Until} condition]

[statements]

[Exit Do]

[statements]

Loop

VB Scripting Concepts

Am

are

ndra

Kum

ar

Koth

uru

15

• For Each...Next Statement

For Each element In group

[statements]

[Exit For]

[statements]

Next

• While. . .Wend Statement

While condition

Version [statements]

Wend

• Do…Loop... While/Until… Statement

Do

[statements]

[Exit Do]

[statements]

Loop [{While | Until} condition]

Page 16: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Sub Routines & functions

• A procedure/function is a grouping of code statements that can be called by an associatedname to accomplish a specific task or purpose in a program. Once a procedure/function isdefined, it can be called from different locations in the program as needed.

• Difference between Sub Routine and Function – Sub Routine cannot able to return anyvalue from it but function can able do it.

• Parameter types – ByRef, ByVal. Default Parameter Type is ByRef so that you canindirectly return more than one parameter value from a function.

VB Scripting Concepts

Am

are

ndra

Kum

ar

Koth

uru

16

indirectly return more than one parameter value from a function.

Sub Routine

Sub SubRoutineName([[ByRef|ByVal] Param 1, Param 2…Param n])

[Statement 1]

[Statement 2]

[Exit Sub]

[Statement n]…

End Sub

Function

Function FunctionName ([[ByRef|ByVal] Param 1, Param 2…Param n])

[Statement 1]

[Statement 2]

[Exit Function]

[Statement n]…

FunctionName = Value ‘ to return value

End Function

Page 17: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Array – It is a collection of similar type of data.

• Static length of Array

• Dynamic length of Array

E.g. for Static length array

Dim var_Array(10)

For counter = 0 to 9

var_Array(counter) = counter

VB Scripting Concepts

Am

are

ndra

Kum

ar

Koth

uru

17

var_Array(counter) = counter

Next

E.g. for Dynamic length array

Dim var_Array()

var_Value = InputBox(“Enter any number greater than zero”)

While counter <= var_Value

Redim Preserve var_Array(counter)

var_Array(counter) = counter

counter = counter + 1

Wend

Page 18: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Abs Array Asc Atn

CBool CByte CCur CDate

CDbl Chr CInt CLng

Conversions Cos CreateObject CSng

CStr Date DateAdd DateDiff

DatePart DateSerial DateValue Day

Derived Math Escape Eval Exp

Filter FormatCurrency FormatDateTime FormatNumber

FormatPercent GetLocale GetObject GetRef

Hex Hour InputBox InStr

• VB Script Built–in Functions

VB Scripting Concepts

Am

are

ndra

Kum

ar

Koth

uru

Hex Hour InputBox InStr

InStrRev Int, Fix IsArray IsDate

IsEmpty IsNull IsNumeric IsObject

Join LBound LCase Left

Len LoadPicture Log LTrim; RTrim; and Trim

Maths Mid Minute Month

MonthName MsgBox Now Oct

Replace RGB Right Rnd

Round ScriptEngine ScriptEngineBuildVersion ScriptEngineMajorVersion

Second SetLocale Sgn ScriptEngineMinorVersion

Sin Space Split Sqr

StrComp String StrReverse Tan

Time Timer TimeSerial TimeValue

TypeName UBound UCase Unescape

VarType Weekday WeekdayName Year

18

Page 19: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Introduction to QTP

Am

are

ndra

Kum

ar

Koth

uru

19

Introduction to QTP

Page 20: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Benefits

• Verify the functionalities of integrated and multi environment enterprisesolutions.

• Minimize the time and effort required to develop a powerful test suite.

• Practice collaborative testing to leverage existing Quality Assurance

Benefits of QTP

Am

are

ndra

Kum

ar

Koth

uru

• Practice collaborative testing to leverage existing Quality Assuranceresources.

• Integrate with WinRunner, LoadRunner and Test Director.

20

Page 21: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

QTP Supports

Am

are

ndra

Kum

ar

Koth

uru

21

QTP supports

Page 22: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Expands QTP capabilities for specific environments

• Allows for context sensitive recording depending on your environment

� web

� client/server

QTP Add-in Manager

Am

are

ndra

Kum

ar

Koth

uru

� terminal emulator

• Allows for the verification of Environment - specific objects

• Allows for synchronization depending on the environment

22

Page 23: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

QTP Add-in Manager

Am

are

ndra

Kum

ar

Koth

uru

23

Page 24: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

QuickTest Window

• The QuickTest window contains the following key elements:

• QuickTest title bar—Displays the name of the currently open test.

• Menu bar—Displays menus of QuickTest commands.

• File toolbar—Contains buttons to assist you in managing your test.

• Test toolbar—Contains buttons to assist you in the testing process.

• Debug toolbar—Contains buttons to assist you in debugging your test (not displayed by default).

QTP User Interface

Am

are

ndra

Kum

ar

Koth

uru

• Debug toolbar—Contains buttons to assist you in debugging your test (not displayed by default).

• Action toolbar—Contains buttons and a list of actions, enabling you to view the details of an individual action or the entire test flow (available only in the Tree View, not displayed by default).

• Test pane—Contains the Tree View and Expert View tabs.

• Test Details pane—Contains the Active Screen.

• Data Table—Assists you to parameterize your test. The Data Table contains the Global tab and a tab for each action.

• Debug Viewer pane—Assists you in debugging your test. The Debug Viewer pane contains the Watch Expressions, Variables, and Command tabs (not displayed by default).

• Status bar—Displays the status of the QuickTest application.

24

Page 25: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Script

Library File

QTP User Interface

Am

are

ndra

Kum

ar

Koth

uru

25

Data Table window

Local Sheet(Action1)

Global Sheet

Export view (code)

Debug Viewer

Page 26: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Quick Test testing process consists of 7 main phases

1. QTP Automation Testing Process

• Test Environment

• Test Conditions

2. Creating Test Script

• Recording script using Record & Play back method

• Using Keyword View

QTP Testing Process

Am

are

ndra

Kum

ar

Koth

uru

•• Using Descriptive Programming

3. Enhancing your Test Script

• Adding logic and conditional statements

• Parameterization

• Inserting Validation statements using checkpoints/descriptive programming

4. Debugging your test

• Check that it operates smoothly and without interruption.

5. Run Test

• Check the behavior of your application

6. Analyzing the test results

7. Reporting defects

26

Page 27: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Verify that the application under test is stable and ready for testing

• Verify the test case and list the steps in the correct order

• Verify the test data to be used to record the basic steps

• Verify the testing environment standards are adhered to

Steps to prepare Automation Testing

Am

are

ndra

Kum

ar

Koth

uru

• Verify the testing environment standards are adhered to

• Verify the QuickTest and the add-ins , if any, are installed and runningwithout errors

27

Page 28: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Record & Play Back

Am

are

ndra

Kum

ar

Koth

uru

28

Record & Play Back

Page 29: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Recording Types

• Standard Recording : Enables you to record in normal mode withoutcapturing mouse events & co-ordinates

Record & Play Back

Am

are

ndra

Kum

ar

Koth

uru

• Analog Recording : Enables you to record the exact mouse &keyboard operations. Quick Test tracks every movement of themouse

• Low Level Recording : Enables you to record on any object whetheror not Quick Test recognizes the specific object . This mode ofrecording is used if the exact co-ordinates of the object is important

29

Page 30: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

How Quick Test Recognizes Objects

• For each object class, QTP has a default set of properties that it alwayslearns.

Record & Play Back

Am

are

ndra

Kum

ar

Koth

uru

� Mandatory Properties

� Assistive properties

� Ordinal Identifiers

• Usually, only a few properties are needed to uniquely identify an object andthose vary from object to objects.

30

Page 31: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Record & Play Back

Am

are

ndra

Kum

ar

Koth

uru

31

Recorded Script in Keyword view which contains descriptions for the code

Page 32: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Record & Play Back

Am

are

ndra

Kum

ar

Koth

uru

32

Recorded Script in Export view contains only code

Page 33: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Record & Play Back

Am

are

ndra

Kum

ar

Koth

uru

33

• Record and run test on any open Browser/Windows based application - tester can record onany opened browser

• Open the following address/Record and run only on - tester can record on specifiedapplication/application URL only

Page 34: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Actions

Am

are

ndra

Kum

ar

Koth

uru

34

Actions

Page 35: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Action is nothing but a block of statements and will be executed first when user startexecuting the test script just like a main function in C language.

• Once new test script is created, one action will be automatically created in the test scriptwith the default name “Action1” and will be executed by default.

• Once an action is created, ObjectRepository file(.bdb), Resources file(.mtr) and Scriptfile(.mts) would be created and one sheet would be added in Default.xls file exist in the

Actions

Am

are

ndra

Kum

ar

Koth

uru

35

file(.mts) would be created and one sheet would be added in Default.xls file exist in thetest script folder.

• Inserting a new ActionInsert � Call to New Action

Page 36: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Types of Calling an Action

• Call to New Action – Calling new action into the test script

• Call to Copy of Action – Calling the existing action from other test script into current testscript. It is not necessary that the called action should be reusable action. User can alsoable to make changes to the called action from local test script and it will not affect theactual test script.

Actions

Am

are

ndra

Kum

ar

Koth

uru

actual test script.

E.g. RunAction "Copy of Action2", oneIteration

• Call to Existing Action – Calling the existing action from other test script into current testscript. It is compulsory that the called action should be a reusable action. User cannot ableto make changes in called action from local test script so that it won’t affect the actual testscript.

E.g. RunAction "Action3 [Test2]", oneIteration

• Call to WinRunner ����Test/Function – Calling WinRunner Test script or function from QTPTest Script.

36

Page 37: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Reusable Actions

When you plan a suite of tests, you may realize that each test requires identical activities,such as logging in. For example, rather than recording the login process three times inthree separate tests and enhancing this part of the script (with checkpoints andparameterization) separately for each test, you can create an action that logs into a flightreservation system in one test. Once you are satisfied with the action you recorded and

Actions

Am

are

ndra

Kum

ar

Koth

uru

37

reservation system in one test. Once you are satisfied with the action you recorded andenhanced, you can insert the existing action into other tests.

Making the action as reusable action

Page 38: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Insert Call to an Action

You can call a reusable action multiple times within a test (from the local test), and youcan call it from other tests. When you insert a call to an external action, the action isinserted in read-only format. User can view the components of the action in the actiontree, but you cannot modify them.

Inserting calls to reusable actions makes it easier to maintain your tests, because when

Actions

Am

are

ndra

Kum

ar

Koth

uru

38

Inserting calls to reusable actions makes it easier to maintain your tests, because whenan object or procedure in your application changes, it needs to be updated only one time,in the original action.

Note: If the test calling an action uses per-action repository mode, the called action’saction object repository will be read-only (as are the steps of the called action) in the testcalling the action. If the test you are calling from uses a shared object repository, thecalled action will use the same shared object repository as the test calling the action.Before running the test, confirm that the shared object repository contains all the objectsthat are in the called action. Otherwise, the test may fail.

Page 39: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Splitting Actions

User can split an existing action into two sibling actions or into parent-child nested actions.

Options disable when splitting an Action is used:

Actions

Am

are

ndra

Kum

ar

Koth

uru

39

• when an external action is selected• when the first line of the action is selected• while recording a test• while running a test• when you are working with a read-only test

Page 40: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Nesting Actions

Sometimes you may want to run an action within an action. This is called nesting.It helps you maintain the modularity of your test and enable you to run one action oranother based on the results of a conditional statement.Actions can be viewed from top-level test flow or drilled-down into action steps

Actions

Am

are

ndra

Kum

ar

Koth

uru

40

Page 41: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Exit Actions

You can add a line in your script in the Expert View to exit an action before it runs in itsentirety. You may want to use this option to return the current value of the action to the valueat a specific point in the run. There are four types of exit action statements you can use:

Exiting Actions

Am

are

ndra

Kum

ar

Koth

uru

41

• ExitAction - Exits the current action, regardless of its iteration attributes.

• ExitActionIteration - Exits the current iteration of the action.

• ExitRun - Exits the test, regardless of its iteration attributes.

• ExitGlobalIteration - Exits the current global iteration.

Page 42: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• How to pass/return parameter values to/from an Action

� For example, declare parameters for Action2 i.e. go to “Edit -> Action -> Action Properties… -> Parameters Tab”.

� To pass values, add parameters in Input Parameters and specify its type & Default value & Description.

� To return values, add parameters in Output Parameters and specify its type & Description.

Action Parameters

Am

are

ndra

Kum

ar

Koth

uru

In Action1, use the below Syntax:

Syntax: RunAction “ActionName”, OneIteration/AllIterations, param1, param2, param3,..... Etc.

E.g. In Action1,

Dim c

RunAction "Action2", OneIteration, “a”, “b”, c

Msgbox c

42

In Action2, retrieve the parameter values using the following Syntax so that you can read values from it

Msgbox Parameter(“param1”)

• Code in Action2 -> Parameter(“param3”) = Parameter(“param1”) & Parameter(“param2”)

Page 43: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Object Repository

Am

are

ndra

Kum

ar

Koth

uru

43

Object Repository

Page 44: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• On completion of this chapter, you will be able to do the following

• Define the object in QuickTest Professional

• Describe how objects are recognized by QuickTest Professional

Object Repository

Am

are

ndra

Kum

ar

Koth

uru

• Describe the role of the Object Repository

• Use the Object Repository to find and add objects

• Change object logical names using the Keyword View

44

Page 45: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Textbox

Object Types

Am

are

ndra

Kum

ar

Koth

uru

45

Link

Image

• A QTP Object is a graphic user element in an application interface. E.g. Textbox, Link

• QTP by itself does not define any object information. Instead it uses the sameinformation created by the application developers

• Objects are categorized into classes. E.g. Links, text fields, graphic images

Page 46: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Object Recognition

Am

are

ndra

Kum

ar

Koth

uru

46

• In the interface given above, we will take up the following 2 Textboxes for discussion-

� User Name

� Password

• The only way to distinguish between two objects of same class is by looking at their Object Properties

• Specific characteristics of an object is called Object Property

Page 47: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Object information is stored in the Object Repository

Object Repository

Am

are

ndra

Kum

ar

Koth

uru

47

The Object Repository dialog box displays a tree of all objects in the current component or in the current action or entire test

Page 48: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Assigning and Modifying a Logical Name

Am

are

ndra

Kum

ar

Koth

uru

48

When you want to make the object’s logical name more descriptive to give clarity to the testscript, you can modify the object’s logical name in the object repository

• Open the Object Repository Dialog from the Test Script

• Select the object you want to rename and right click on the object

• Select rename option and change the Logical Name and the changes would be reflectedinto the test script.

Page 49: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Object Repository

Am

are

ndra

Kum

ar

Koth

uru

49

• QTP Object Repository stores properties of the objects during recording. These objects are called as test objects

• which is used by QTP to identify the objects in the AUT during runtime

• To open Object Repository dialog box, Navigate to Tools ���� Object Repository

• Click on + button and get the additional properties of the object

Page 50: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Object Highlight Feature

Am

are

ndra

Kum

ar

Koth

uru

50

• Object highlight feature is used to highlight the particular object to check whether QTP can identify that object when object description is changed

• The window which contains particular object should be available to QTP, to use this feature

• Select any one object in object repository, then click Highlight button. Now the object in the application is highlighted by showing a frame around the object temporarily and causing it to flash for sometime

Page 51: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• There are two types of object repository :

� Per-Action

� Shared

• When you plan to create tests, you must consider how you want to store the objects inyour test.

• You can have a separate action repository for each action and store the objects for

Types of Object Repository

Am

are

ndra

Kum

ar

Koth

uru

51

• You can have a separate action repository for each action and store the objects foreach action in its corresponding action repository.

• you can store all the objects in your test in a common (shared) object repository filethat can be used among multiple tests.

• Per-Action Object Repository file extension is .mtr

• Shared Object Repository file extension is .tsr

Page 52: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• If the test does not call any external actions and the test does not containany steps or any objects, you can change the repository mode or theshared object repository file being used for that test.

• Once any objects or steps have been added to a test, the object repository

Object Repository (Pros & Cons)

Am

are

ndra

Kum

ar

Koth

uru

52

• Once any objects or steps have been added to a test, the object repositorymode cannot be changed from per-action to shared or vice versa. If yourexisting test uses a shared object repository file, you can change theshared object repository file that the test uses.

Page 53: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Adding Objects to the Object Repository

• When you record a test, QuickTest adds each object on which you performan operation to the object repository. You can also add objects to the objectrepository while editing your test.

• There are various ways to add an object to the object repository while editinga test:

Adding Objects to Object Repository

Am

are

ndra

Kum

ar

Koth

uru

53

� Use the Add New Object option in the Object Repository dialog box.You can add any object as a single object or a parent object, along withall its children.

� Choose the View/Add Object option from the Active Screen.

� Insert a step in your test for a selected object from the Active Screen.

Page 54: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Defining new test objects to the Object Repository

Adding Objects to Object Repository

Am

are

ndra

Kum

ar

Koth

uru

54

• Adding test objects to the Object Repository

Page 55: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• When you record a test, QuickTest adds each object on which you perform anoperation to the object repository. You can also add objects to the object repositorywhile editing your test.

• There are various ways to add an object to the object repository while editing atest:

• Use the Add New Object option in the Object Repository dialog box. You can addany object as a single object or a parent object, along with all its children.

Adding Objects to Object Repository

Am

are

ndra

Kum

ar

Koth

uru

55

any object as a single object or a parent object, along with all its children.

• Choose the View/Add Object option from the Active Screen.

• Insert a step in your test for a selected object from the Active Screen.

Note:

To add objects to the object repository using the Active Screen, the Active Screenmust contain information for the object you want to add. You can control howmuch information is captured in the Active Screen in the Active Screen tab of theOptions dialog box.

Page 56: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Spy on controls in browser, see their properties, methods

• See hierarchy of browser objects

Object Spy

Am

are

ndra

Kum

ar

Koth

uru

56

Page 57: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Types of Objects

Am

are

ndra

Kum

ar

Koth

uru

57

Types of Objects

Page 58: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Each recorded browser object has its equivalent Test Object• Objects Hierarchy in browser is also represented as a hierarchy in Object

Repository• New Test Objects can be added to Object Repository by right-clicking the

object in the Active Screen

Test ObjectsTest Objects

Types of Objects

Am

are

ndra

Kum

ar

Koth

uru

58

Utility ObjectsUtility Objects

These are QuickTest environment-specific reserved objects� SystemUtil object� Desktop object � DataTable object� QCUtil object� Reporter object� Services object etc…

Page 59: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Step Generator

Am

are

ndra

Kum

ar

Koth

uru

Replaces the Method Wizard with a dialog box that helps you quickly and easily add methods,reserved objects, and function statements to your test.

59

Page 60: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Data Parameterization

Am

are

ndra

Kum

ar

Koth

uru

60

Data Parameterization

Page 61: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

You can use QuickTest to enhance your tests by parameterizing values in the test.A parameter is a variable that is assigned a value from outside the test in which it is defined.When you create a parameter in the Keyword View, QuickTest creates a corresponding line inVBScript in the Expert View.QuickTest calls the values of a parameterized object from the Data Table using the following syntax: Object_Hierarchy.Method DataTable (parameterID, sheetID)

Parameterization / Data Driven Tests

Am

are

ndra

Kum

ar

Koth

uru

61

Object_Hierarchy.Method DataTable (parameterID, sheetID)

Object_Hierarchy - object-oriented definition of the test object. Method - name of the method that QuickTest executes on the parameterized object. DataTable - Data Table object. parameterID - Name of the column in the Data TablesheetID - Name of the sheet(If the parameter is a global parameter, “dtGlobalSheet” is displayed and for Local Parameter, “dtLocalSheet” is displayed.

Note: Recorded Test / Script is Modified in such a way that Data is driven from the excel sheet

Page 62: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

For example, suppose you are creating a test on the Mercury Tours site, and you select“Paris” as your destination.The following statement is inserted into your test in the Expert View:Browser("Mercury Tours").Page("Find Flights").WebList("depart").Select "Paris"

Now suppose you want to parameterize the destination, and you create a “Departure” column

Parameterization – Object Hierarchy

Am

are

ndra

Kum

ar

Koth

uru

62

Now suppose you want to parameterize the destination, and you create a “Departure” columnin the Data Table. The previous statement is modified to the following:Browser("Mercury Tours").Page("Find Flights").WebList("depart").Select

DataTable("Departure",dtGlobalSheet) and the Object Hierarchy is as follows

Object Hierarchy: Select - is the Method Name DataTable - is the Object Departure - is the name of the column in the Data TabledtGlobalSheet - Indicates name of the sheet in the Data Table

Page 63: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Tests can be parameterize using Data Table parameters or by having QuickTest insertvalues for you based on the parameter type and the parameter-specific preferencesyou set.

The following parameter types are available:

Parameterization – Parameter Types

Am

are

ndra

Kum

ar

Koth

uru

63

• Data Table Parameters

• Environment Variable Parameters

• Random Number Parameters

Page 64: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• User can supply the list of possible values for a parameter by creating a Data Table parameter.• Data Table parameters enable you to create a data-driven test (or action) that runs several times

using the data you supply.• In each repetition, or iteration, QuickTest substitutes the constant value with a different value

from the Data Table.• By default Two sheets (Global & Action1) are available for Data Table Parameterization. Global

sheet is available for all Actions where as Local sheet (action1) is available only to theappropriate action in the test script.

Parameterization – Data Table Parameters

Am

are

ndra

Kum

ar

Koth

uru

64

Data Table Methods� AddSheet Method � DeleteSheet Method � Export Method � GetCurrentRow Method � GetRowCount Method � GetSheet Method � GetSheetCount Method � Import Method � SetCurrentRow Method � SetNextRow Method � SetPrevRow Method

Page 65: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

QuickTest can insert a value from the Environment variable list, which is a list ofvariables and corresponding values that can be accessed from your test. Throughoutthe test run, the value of an environment variable remains the same, regardless of thenumber of iterations.

Parameterization – Environment Variables

Am

are

ndra

Kum

ar

Koth

uru

65

Tip: The environment parameter is especially useful for localization testing, when youwant to test an application where the user interface strings change, depending on theselected language. The environment parameter can be used for testing the sameapplication on different browsers.You can also vary the input values for each language by selecting a different Data Tablefile each time you run the test.

Page 66: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

There are three types of environment variables:

• User-Defined Internal—variables that you define within the test. They are saved with thetest and accessible only within the test in which they were defined.

• User-Defined External—variables that you pre-defined in the active external environmentvariables file (.xml). You can create as many files as you want and select an appropriate

Parameterization – Environment Variables

Am

are

ndra

Kum

ar

Koth

uru

66

file for each test. Note that external environment variable values are designated as read-only within the test.E.g. User defined Environment variableEnvironment(“test”) = “Fujitsu”Msgbox Environment(“test”) ‘display message box with the text Fujitsu

• Built-in—built-in variables, such as Test path and Operating system. They are accessiblefrom all tests, and are designated as read-only.E.g. Built-in Environment variablevar_Username = Environment(“username”) ‘returns windows login user name

Page 67: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

QuickTest can generate random numbers and insert them as the values for aparameter. By default, the random number ranges between 0 and 100. The minimumallowable value for a random number is 0 and the maximum allowable value is2147483647. A different random number is generated each time the parameter iscalled.

E.g.

Parameterization – Random Numbers

Am

are

ndra

Kum

ar

Koth

uru

67

E.g.Browser("Mercury Tours").Page("Find Flights").WebList(“No of Seats").Select RandomNumber(1, 10)

Note: The number of action and global iterations performed during the test run isbased on the number of rows in the Data Table.

Page 68: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Synchronization

Am

are

ndra

Kum

ar

Koth

uru

68

Page 69: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

What is Synchronization

• Synchronization is an enhancement to a test, to instruct QTP to wait for astate of a property on a particular object to change, before advancing to thenext step in the test

Synchronization

Am

are

ndra

Kum

ar

Koth

uru

69

• Synchronization point allows the test to pause while the AUT processes,before moving on to the next step

• Just as a manual tester waits for a visual cue to know whether the AUTcompleted its processing, we need to instruct QTP to wait for a cue whileprocessing and then continue with the steps

Page 70: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Where Synchronization should be added

• Some objects may take several seconds longer than other objects due to processing time,for example:

� For a progress bar to reach 100%

� For a status message to appear

Synchronization

Am

are

ndra

Kum

ar

Koth

uru

� For a button to become enabled

� For a window or pop-up message to open

• On the other hand, Quick Test runs each step in the same length of time

• An “Object not enabled” message appears if Quick Test runs a step and progresses to thenext while the previous step is not yet complete

70

Page 71: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Synchronization

Am

are

ndra

Kum

ar

Koth

uru

71

• To add a synchronization point, do the following-

Select Menu ���� Insert ���� Step ���� Synchronization Point

• Add the synchronization point immediately after the step to be synchronized

Page 72: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Synchronization

Am

are

ndra

Kum

ar

Koth

uru

72

E.g. Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours"). WebEdit("userName").WaitProperty "disabled", False, 10000

Page 73: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Synchronization point settings

Am

are

ndra

Kum

ar

Koth

uru

73

Global TimeoutSync Step Timeout

When the synchronization timeout is set for a step, this value is added to the global timeout value.

Global Timeout + Sync Step Timeout = Total Maximum Timeout

Page 74: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• WaitProperty – method is used to instruct QTP to wait the execution process until it matches with the object property value based on the specified time.

E.g. Browser("Welcome: Mercury Tours").WaitProperty "name", "Welcome: Mercury Tours", 5000

Synchronization

Synchronization Methods

Am

are

ndra

Kum

ar

Koth

uru

74

Property valueProperty Name Time

• Wait – method is used to instruct the QTP to wait the execution process based on the specified time only but not on any condition.E.g. Wait 5 (or) Wait(5) ‘5 Seconds

• Exist – method is used to instruct QTP to wait the execution process based on the specified time and returns Boolean value as per the object existence.E.g. var_Exist = Browser(“Welcome: Mercury Tours”).Exist(5) ‘5 seconds

Page 75: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Check Points and Output Values

Am

are

ndra

Kum

ar

Koth

uru

75

Check Points and Output Values

Page 76: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Checkpoints are the validation statements which verifies the Actual results against Expected results and stores the results

Checkpoints

Insert Check Points in to your testVarious check points used in QTP(while recording) are

Am

are

ndra

Kum

ar

Koth

uru

76

Page 77: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Standard Check Point

Standard Checkpoint enables you to check an object’s property.

Insert->check point->standard check point

A pointing hand will appear and using that you can select a location in the application where standard check point can be inserted. If more than 1 object is associated with the selected location then ‘select an Object’ dialog box appears. On selecting the corresponding objects and clicking ‘OK’ will display different dialog box

Checkpoints

Am

are

ndra

Kum

ar

Koth

uru

77

Check properties dialog box

Page object Check Point Properties

Table object Check Point Properties

WebEdit object Check Point Properties

E.g. Browser(“Google").Page(“Google”).WebEdit(“q”).Check CheckPoint("DbTable")

Page 78: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Checkpoints

Am

are

ndra

Kum

ar

Koth

uru

78

In the Checkpoint Properties (WebEdit) dialog box, you can specify which properties of the object to check and edit the values of these properties.

Page Checkpoint checks the characteristics of a Web page like links, image and loading time of a page. Click ‘Ok’ to add ‘Page check point to test tree.

Page 79: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Database Checkpoint

By inserting Database checkpoints to your test scripts, you can check the contents of databasesaccessed by your Web site or application.

Choose Insert ->Checkpoint ->Database checkpoint and the Database Query Wizard opens.

Checkpoints

Am

are

ndra

Kum

ar

Koth

uru

79

Click finish to go to Data base check point dialog box

Page 80: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Checkpoints

Am

are

ndra

Kum

ar

Koth

uru

80

You can check that a specified value is displayedin a cell in a table on your Web page or in yourapplication by adding a table checkpoint to yourtest.

Click ‘Ok’ to add table check point to the test tree.

E.g. DbTable("DbTable").Check CheckPoint("DbTable")

Page 81: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Expected data

Checkpoints

Am

are

ndra

Kum

ar

Koth

uru

81

QTP captures the current information about the database using the query you have defined andsaves this information as expected data. When you run the test, the database checkpointcompares the current state of the database to the expected data.

Insert statement option

Page 82: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Inserting Output values (while recording)

Quick Test enables you to retrieve a value from your test and store it in the Data Table asan output value. This output value can be subsequently used as an input variable in yourtest.

Output Values

Am

are

ndra

Kum

ar

Koth

uru

82

Page 83: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Standard Output Value

When you run the test, Quick Test retrieves the current value of the property and enters it in the run-time Data Table as an output value.

Choose Insert ->output values ->standard output values. A pointing hand appears. Click an object in your Web page or application to add output values. If the location you clicked is associated with more than one object then ‘Select an object’ dialog box appears and on selecting an objects and clicking ‘OK’ will display corresponding dialog box

Output Values

Am

are

ndra

Kum

ar

Koth

uru

83

Table output value Properties

Page output value Properties

WebEdit output value Properties

Output value dialog box

Page 84: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Output Values

Am

are

ndra

Kum

ar

Koth

uru

84

In the Output Value Properties dialog box, you can choose which property of the object to specify as an output value.

In the Page Output Value Properties dialog box, you can choose which property of the page to specify as an output value.

E.g. Browser(“Google").Page(“Google”).WebEdit(“q”).Output CheckPoint("DbTable")

Page 85: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Text output value

Text output value from a text string retrieves the current value of the text string and enters it in the run-time Data Table as an output value while running the test.

Choose Insert > Output Value > Text Output Value after highlighting the test string that you want to specify as an output value. Click the highlighted test string with pointer hand. The Text Output Value Properties dialog box opens.

Output Values

Am

are

ndra

Kum

ar

Koth

uru

85

Click ‘Ok’ to add Output value test to test tree.

Page 86: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Transactions

Am

are

ndra

Kum

ar

Koth

uru

86

Transactions

Page 87: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• A transaction represents the business process that you are interested in measuring.

• You can measure how long it takes to run a section of your test by defining transactions.

• User can Plan the Scenario as transaction and use the Start Transaction and End Transactionwhile Recording.

• Insert�Start Transaction…

Transactions

Am

are

ndra

Kum

ar

Koth

uru

Services.StartTransaction "LoginTransaction"

• Insert�End Transaction…

Services.EndTransaction "LoginTransaction"

87

Page 88: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

QTP Options

Am

are

ndra

Kum

ar

Koth

uru

88

QTP Options

Page 89: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

QTP Options

Am

are

ndra

Kum

ar

Koth

uru

89

Select the check boxes “Display Add-In Manager on startup” & “Display Welcome Screen on startup” in Tools ���� Options ���� General to view the Add-In Manager and Welcome screens on start up

Page 90: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

QTP - Options

Am

are

ndra

Kum

ar

Koth

uru

90

• To get the execution arrow appear to help with troubleshooting click “Normal” in Tools ���� Options ���� Run

• To view the Test Results after each test run select “View Results” option in Tools ����Options ���� Run

Page 91: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Settings

Am

are

ndra

Kum

ar

Koth

uru

91

Test Settings

Page 92: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Settings

Am

are

ndra

Kum

ar

Koth

uru

92

Click on Modify button to update the Addins to the test script. File ���� Settings ���� Properties. Select or Deselect the check boxes to manage Addins.

Page 93: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Settings

Am

are

ndra

Kum

ar

Koth

uru

93

• Change the iteration settings for test execution

• Change the Object Synchronization timeout to recognize the object

• Enable/disable Smart Identification on Objects

• Apply settings for recovery scenario at the time of script execution

• File ���� Settings ���� Run

Page 94: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Settings

Am

are

ndra

Kum

ar

Koth

uru

94

• Associate the library files with the test script for reusability

• Associate the External Data Tables with the Test script for parameterization

• File ���� Settings ���� Resources

Page 95: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Settings

Am

are

ndra

Kum

ar

Koth

uru

95

• Access Built-in Environment variables

• Access Internal or External User defined Environment variables

• File ���� Settings ���� Environment Variables

Page 96: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Results

Am

are

ndra

Kum

ar

Koth

uru

96

Test Results

Page 97: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• After running a test, we can view a report of major events that occurred during the test run.

• The Test Results window contains a description of the steps performed during the test run.

• If the test contains Data Table parameters, and the test settings it shows on Test Resultswindow.

• Results are grouped by the actions in the test.

Reporter object: Using this object methods and properties, tester can send, filter and

Test Results

Am

are

ndra

Kum

ar

Koth

uru

97

analyze the results to/from Test Results window.

� Reporter.ReportEvent – used to send result to test result window

� Reporter.Filter – used to view the only the required results like pass/fail/etc…

� Reporter.ReportPath – used to retrieve the folder path in which the current test's resultsare stored. Note: but can’t able to set file path at runtime.

E.g:

1) Reporter.ReportEvent micPass, “test case 123 is passed”, “test case for Login”

2) Reporter.Filter = rfEnableErrorsOnly

3) Msgbox Reporter.ReportPath

Page 98: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Test Results Summary

Test Results

Am

are

ndra

Kum

ar

Koth

uru

98

Individual result – Pass Result

Individual result – Fail Result

Page 99: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Descriptive Programming

Am

are

ndra

Kum

ar

Koth

uru

99

Descriptive Programming

Page 100: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Record and Playback Limitations

• Objects will not be identified if the objects in the application aredynamic in nature.

• QTP performance may decrease when the object repository becomesto large, due to the no. of objects added. As the object repository

Descriptive Programming

Am

are

ndra

Kum

ar

Koth

uru

to large, due to the no. of objects added. As the object repositoryincreases, more resources are required to recognize the objects whichmay decrease performance.

• To create scripts using Record and replay application must be uprunning. Which means will have to wait till application deployed to startcreating QTP scripts.

• Scripts maintenance is not easy if UI changes.

100

Page 101: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Descriptive Programming: Instead of storing physical descriptions in ObjectRepository we will pass physical descriptions of the objects during script run-time to identify and access the objects

Advantages:

• One can start creating scripts without application is actually deployed.

Descriptive Programming

Am

are

ndra

Kum

ar

Koth

uru

• The objects in the application are dynamic in nature and need specialhandling to identify the object.

• Object Identification performance would be much faster than OR basedidentification.

• Scripts re-usable.

• Scripts maintenance would be much easier if UI changes.

• User does not wish to use shared repository.

101

Page 102: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Descriptive ProgrammingDescriptive Programming

1. By entering programmatic descriptions directly into statements:

Creating Dynamic Test Object:

micClass(“property1:=value1”[,“property2:=value2”, etc…])

Where:

micClass is the object class as assigned by QuickTest and,

property:=value is a description of the object separated by commas

• At least one Property is required to recognize the object by QTP at runtime.

• If two or more objects contain similar property values, then use “Index” property to recognize the object

Am

are

ndra

Kum

ar

Koth

uru

102

• If two or more objects contain similar property values, then use “Index” property to recognize the object uniquely. Index property value starts from 0(Zero)

• Use regular expressions to recognize objects if object property values tentative.

E.g. 1) Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).Set “Tester”

2) Browser(“name:=Google”).Page(“title:=Google”).WebButton(“name:=Google Search”).Click

3) Browser(“name:=Google”).Page(“title:=Google”).WebButton(“name:=Google.*”).Click

• Tester learns object’s properties to recognize the objects using the Object Spy or object repository.

• Tester writes code to describe object’s properties in the script.

• At run-time, QuickTest bypasses the Object Repository and creates a test object from the script.

• Programmatic description is useful if you want to perform an operation on an object that is not stored in theObject Repository.

Page 103: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Descriptive ProgrammingDescriptive Programming

2. By using description objects for Programmatic description:

Defining Description objects,

For Browser:

Set desc_BrowserProperty = Description.Create()

desc_BrowserProperty("name").Value = “Google"

For Page:

Set desc_PageProperty = Description.Create()

Am

are

ndra

Kum

ar

Koth

uru

Set desc_PageProperty = Description.Create()

desc_PageProperty("title").Value = “Google“

Creating Dynamic Test Object

Assigning Description object to Test Object

E.g. 1) Set BrowserObj = Browser(desc_BrowserProperty)

2) Set BrowserPageObj = Browser(desc_BrowserProperty).Page(desc_PageProperty)

Access Dynamic test objects

E.g. 1) BrowserPageObj.WebEdit(“name:=q”).Set “tester”

2) BrowserObj.Close

103

Page 104: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Descriptive ProgrammingDescriptive Programming

Web Objects standard properties

WebEdit – name WebList – name

Link – name Image – name, alt, file name

WebRadioButton – name WebCheckBox – name

WebElement – innertext, innerhtml WebTable – name, html id

Am

are

ndra

Kum

ar

Koth

uru

104

Browser – name Page – title

WebButton - name

SAP Objects standard properties

For all SAP Objects, either id property or combination of name & GuiComponentType properties is required.

Page 105: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Descriptive ProgrammingDescriptive Programming

Validations using Descriptive Programming

GetROProperty: method is used to retrieve specified test object property value at runtime.

E.g.

1) var_Value = Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).GetROProperty(“value”)

If Strcomp(var_Value,”tester”,0) = 0 Then

Am

are

ndra

Kum

ar

Koth

uru

105

If Strcomp(var_Value,”tester”,0) = 0 Then

Reporter.ReportEvent micPass, “User entered correct value as “ & var_Value, “Passed”

Else

Reporter.ReportEvent micFail, “User entered wrong value as “ & var_Value, “Failed”

End If

2) var_Status = Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).GetROProperty(“disabled”)

Page 106: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Regular Expressions

Am

are

ndra

Kum

ar

Koth

uru

106

Regular Expressions

Page 107: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• A regular expression is a formula for matching strings that follow some pattern.• A regular expression (abbreviated as regexp or regex, with plural forms regexps, regexes, or

regexen) is a string that describes or matches a set of strings, according to certain syntax rules.• You can use a regular expression to identify specific text in a document and either remove it

completely or replace it with other text.• In QuickTest Regular Expressions can be used in 3 places:

� Object Repository� CheckPoints� RegExp object

Regular Expressions

Am

are

ndra

Kum

ar

Koth

uru

107

• regex is the most basic pattern, simply matching the literal text regex. A "match" is the piece of text,or sequence of bytes or characters that pattern was found to correspond to by the regex processing.

• The regular expression serves as a template for matching a character pattern to the string beingsearched. The regular expression pattern (expression) is stored in the Pattern property of theRegExp object.

Order PrecedenceOperator Description\ Escape(), (?:), (?=), [] Parentheses and Brackets*, +, ?, {n}, {n,}, {n,m} Quantifiers^, $, \anymetacharacter Anchors and Sequences| Alternation

Page 108: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• [ \ ^ $ . | ? * + ( ) special characters are Meta Characters. If you want to use any of thesecharacters as a literal in a regex, you need to escape them with a backslash. If you want tomatch 1+1=2, the correct regex is 1\+1=2. Otherwise, the plus sign will have a specialmeaning.

• To match an a or an e, use [ae]. You could use this in gr[ae]y to match either gray or grey.• [0-9a-fA-F] matches a single character, case insensitively.• \d matches a single character that is a digit, \w matches a "word character“ (alphanumeric

characters plus underscore), and \s matches a whitespace character (includes tabs and linebreaks).

Regular Expressions

Am

are

ndra

Kum

ar

Koth

uru

108

breaks).• Non Printable characters - Use \t to match a tab character, \r for carriage return and \n for line

feed.• The dot matches a single character, except line break characters. gr.y matches gray, grey,

gr%y, etc.• The question mark makes the preceding token in the regular expression optional.• E.g.: colou?r matches colour or color• Use curly braces to specify a specific amount of repetition. Use [1-9][0-9]{3} to match a number

between 1000 and 9999. [1-9][0-9]{2,4} matches a number between 100 and 99999.• 07[-./]04[-./]76 matches 07/04/76, 07-04-76, or 07.04.76• .* matches any string• (1[012]|[1-9]):[0-5][0-9] (am|pm) matches mm:ss am/pm time format• \d{5} matches any five digit number

Page 109: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

RegExp object: It provides support for regular expression matching; for the ability to search strings for substrings matching general or specific patterns.

Properties: Global, IgnoreCase, Pattern, MultiLine

Methods: Execute, Test, Replace

Instantiate and access the regular expression object, with the following code:

Regular Expressions

Am

are

ndra

Kum

ar

Koth

uru

109

E.g. 1)

Dim oRegEx 'Create variable.Set oRegEx = New RegExp 'Create regular expression.oRegEx.Pattern = "[0-9a-zA-Z_-()]" 'Set pattern.oRegEx.IgnoreCase = bIgnoreCase 'Set case insensitivity.oRegEx.Global = True 'Set global applicability and match all occurrences in the search stringSet desc_Broswer = Description.Create()desc_Broswer("name").Value = Pattern 'applies the pattern to the description objectSet BrowserObj = Browser(desc_Broswer)BrowserObj.Navigate "www.yahoo.com"

Page 110: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Functions & Library Files

Am

are

ndra

Kum

ar

Koth

uru

110

Functions & Library Files

Page 111: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Creating Functions/SubInsert � Function Definition Generator …

• Using this generator, user can able to create afunction definition without knowing the syntax

• When tester register the user defined function onany test object event and make it as default, thenat runtime, QTP executes the user defined

Function Definition Generator

Am

are

ndra

Kum

ar

Koth

uru

111

at runtime, QTP executes the user definedfunction when that event is fired irrespective ofbuilt-in functionality of the event.

• RegisterUserFunc method is used to registerthe function

• Tester should prepare the logic himself/herself toimplement functionality

Syntax: RegisterUserFunc test Object class name, Event name, Boolean value

Boolean value: True – used to set as Default False – used to set as Built-in only

Page 112: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Function Library is nothing but a file which may contain user defined elements likeVariables, Functions, Sub Routines, Classes, Objects etc…

• It is generally used for reusability

• Can able associate with multiple test scripts

• Provides global scope to the user defined elements

Library Files

Am

are

ndra

Kum

ar

Koth

uru

• Library file extension in QTP can be either .Vbs (Visual basic scripting file) or .Qfl or.Txt (Text file)

• Reduces the script preparation time

• Script Maintenance is easier

112

Page 113: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Recovery Scenarios & Error Handling

Am

are

ndra

Kum

ar

Koth

uru

113

Recovery Scenarios & Error Handling

Page 114: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• To instruct Quick test to recover from unexpected events and errors that occur in the testing environment during the run session.

• A Recovery scenario consists of

� Trigger Event

� Recovery Operation

� Post Recovery Run Option

11 22

Recovery Scenarios

Am

are

ndra

Kum

ar

Koth

uru

114

Page 115: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

3344

Recovery Scenarios

Am

are

ndra

Kum

ar

Koth

uru

115

55 66

Page 116: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

77 88

Recovery Scenarios

Am

are

ndra

Kum

ar

Koth

uru

116

99 1010

Page 117: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

1111 1212

Recovery Scenarios

Am

are

ndra

Kum

ar

Koth

uru

• Click on Save button and save the recovery scenario with the extension .qrs

• Using this wizard, tester can able to create multiple types of recovery scenarios as per functionality and execute test scripts without sudden failures.

• Suddenly If any failures happened at the time of execution, automatically appropriate recovery scenario would be triggered.

117

Page 118: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

VBScript On Error Statement

• Enables error-handling. Two Types available for error handling using On Error statement

� On Error Resume Next

� If you don't use an On Error Resume Next statement, any run-time error that occurs isfatal; that is, an error message is displayed and execution stops.

� On Error Resume Next causes execution to continue with the statement immediatelyfollowing the statement that caused the run-time error, or with the statement immediatelyfollowing the most recent call out of the procedure/script containing the On Error ResumeNext statement.

Error handling

Am

are

ndra

Kum

ar

Koth

uru

Next statement.

� This allows execution to continue despite a run-time error. You can then build the error-handling routine inline within the procedure.

� An On Error Resume Next statement becomes inactive when another procedure iscalled, so you should execute an On Error Resume Next statement in each called routineif you want inline error-handling within that routine

� On Error Goto Handler

� If exception error exists while execution, based on the handler mentioned in On ErrorGoto Handler, execution control goes to line where the handler is located in theprocedure/script and continues its execution process from that line.

� In VB Script, “On Error Goto 0” statement only can work but not with any other handlers.“On Error Goto 0” statement is used to disable the error handling.

118

Page 119: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Err.Number - This property returns a non-zero value if any error exists while executing the script/procedure.

It returns zero(0) of no error exists.

• Err.Description – This provides the error description like type of error and what field this error belongs to.

• Err.Clear – Clears the existing error information

E.g. 1

On Error Resume Next

Browser(“name:=Google”).Page(“title:=Google”).WebEdit(“name:=q”).Set “amarendra”

Browser(“name:=Google”).Page(“title:=Google”).WebButton(“name:=Google Search”).Click

If Err.Number <> 0 Then

Error handling

Am

are

ndra

Kum

ar

Koth

uru

119

Reporter.ReportEvent micFail, “Expection error “ & Err.Number & “ with the description “ & Err.Description & occred.”, “Error Exists while executing the script”

Err.Clear ‘clear the error info

End If

E.g. 2

On Error Resume Next

Browser("Google").Page("Google").WebEdit("q").Set "amarendra“ ‘enables error handling, no popups displayed

On Error Goto 0

Browser("Google").Page("Google").WebButton("sasa").Click ‘disables error handling, so pop up be will displayed

If Err.Number <> 0 ThenReporter.ReportEvent micPass, Err.Number & " " & Err.Description, ""

Err.Clear

End If

Page 120: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

File System Handling

Am

are

ndra

Kum

ar

Koth

uru

120

File System Handling

Page 121: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

• Using CreateObject VB Scripting method, tester can able to handle file systems

Syntax: Set fso = CreateObject(Scripting.FileSystemObject”)

• Several fso methods and properties available to handle Windows file system.

Methods:

CreateTextFile CreateFolder CopyFile CopyFolder

File System Handling

Am

are

ndra

Kum

ar

Koth

uru

CreateTextFile CreateFolder CopyFile CopyFolder

FileExists FolderExists DeleteFile DeleteFolder

OpenTextFile GetFile GetFolder MoveFile

MoveFolder Delete Move Copy etc..

Properties:

Size DateCreated Name Path

Drive Files SubFolders etc…

121

Page 122: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

E.g. 1) Get the file sizeSet objFSO = CreateObject("Scripting.FileSystemObject")If fso.FileExists(str_Path_FileName) Then

Set txtfile = objFSO.GetFile(“C:\test1123.txt”)File_Size = txtfile.Size & " bytes"

ElseReporter.reportEvent micPass “file does not exist”, “failed”

End If

E.g. 2) Creating Text file and write data into text file and read data from text file

File System Handling

Am

are

ndra

Kum

ar

Koth

uru

122

E.g. 2) Creating Text file and write data into text file and read data from text fileConst ForReading = 1,ForWriting= 2,ForAppending = 8strFilePath = Environment("Env_TestData_TextFile")Set objFSO = CreateObject("Scripting.FileSystemObject")If Not objFSO.FileExists(strFilePath) Then

Set objTextFile = objFSO.CreateTextFile(strFilePath, true)objTextFile.WriteLine RandomNumber(1000,20000)objTextFile.Close

End IfSet objTextFile = objGetFile.OpenAsTextStream(ForReading,-2)Do Until objTextFile.AtEndOfStream

strNextLine = objTextFile.ReadlineLoopobjTextFile.Close

Page 123: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Database Handling

Am

are

ndra

Kum

ar

Koth

uru

123

Database Handling

Page 124: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Using ADODB model, QTP(VB Scripting) can able to handle any type of database. ADO (ActiveX DataObject) is a programming interface to access data in a database. ADO is automatically installed withMicrosoft IIS.

ADO ObjectsObject DescriptionConnection Enables exchange of data.Command Embodies an SQL statement.

Database Handling

Am

are

ndra

Kum

ar

Koth

uru

124

Parameter Embodies a parameter of an SQL statement.Recordset Enables navigation and manipulation of data.Field Embodies a column of a Recordset object.Error Embodies an error on a connection.Property Embodies a characteristic of an ADO object.

ADO CollectionErrors All the Error objects created in response to a single failure on a connection.Parameters All the Parameter objects associated with a Command object.Fields All the Field objects associated with a Recordset object.Properties All the Property objects associated with a Connection, Command,

Recordset or Field object.

Page 125: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Connection String using SQL Server AuthenticationconnectString = "DRIVER=(Driver name); SERVER=(Server name); DATABASE=(database name); UID=(username); PWD=(password)"E.g.: var_ConnectionString = "DRIVER=SQL Server; SERVER=FCP12992; DATABASE=pubs; UID=sa; PWD=;" ‘Connection String for MS Access or Excel fileobjConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=“C:\testExcel.xls;" & "Extended Properties=""text; HDR=YES;FMT=Delimited"""

Sample Code ‘specify connection stringvar_ConnectionString = "DRIVER=SQL Server; SERVER=FCP12992; DATABASE=pubs; UID=sa;

Database Handling

Am

are

ndra

Kum

ar

Koth

uru

125

var_ConnectionString = "DRIVER=SQL Server; SERVER=FCP12992; DATABASE=pubs; UID=sa; PWD=;“strSqlQuery = "select * from employee“ ‘prepare sql querySet objConnection = CreateObject ("ADODB.Connection") ‘create db connection objectobjConnection.open var_ConnectionString ‘open the connection using connection string Set objRecordSet = CreateObject ("ADODB.RecordSet") ‘create record set objectobjRecordSet.open strSqlQuery , objConnection ‘execute sql queryDo Until objRecordSet.EOF ‘run the loop to read data from recordset until end of file

msgbox objRecordSet.Fields.Item("emp_id")objRecordSet.MoveNext 'fetch the next record from Recordset

LoopobjRecordSet.Close ‘close the record setobjConnection.Close close the db connectionSet objRecordSet = NothingSet objConnection = Nothing

Page 126: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Questions???

Am

are

ndra

Kum

ar

Koth

uru

126

Questions???

Page 127: Thomson reuters qtp training presentation

Am

are

ndra

Kum

ar

Koth

uru

Thank YouThank You

Am

are

ndra

Kum

ar

Koth

uru

127

Amarendra Kumar KothuruMobile Number: +91 9620111557

E-Mail: [email protected]@gmail.com

Amarendra Kumar KothuruMobile Number: +91 9620111557

E-Mail: [email protected]@gmail.com

Thank YouThank You