0% found this document useful (0 votes)
69 views122 pages

QTP Automation Testing Overview

This document provides information about Quick Test Professional (QTP) and Unified Functional Testing (UFT) automation testing tools. It discusses when automation testing is needed compared to manual testing, the benefits of automation, and how QTP can be used to create test cases and scripts. Key aspects of QTP covered include object identification, the object repository, object properties, and sample scripting for common objects like buttons, text boxes, and drop-down lists.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views122 pages

QTP Automation Testing Overview

This document provides information about Quick Test Professional (QTP) and Unified Functional Testing (UFT) automation testing tools. It discusses when automation testing is needed compared to manual testing, the benefits of automation, and how QTP can be used to create test cases and scripts. Key aspects of QTP covered include object identification, the object repository, object properties, and sample scripting for common objects like buttons, text boxes, and drop-down lists.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

QUICK TEST PROFESSIONAL(QTP)

UNIFIED FUNCTIONAL TESTING(UFT)

By DURGASOFT

10/26/11 Durgasoft
Automation Testing:
This is the process of testing the application by taking help of any tool is called
automation testing.

Ways of Testing:
[Link] Testing
[Link] Testing

When we need to go for automation testing:


Whenever we are having number of test cases and need to execute repeatedly, then it
require automation testing to overcome below drawbacks of the manual testing.

More resources are required


More time is required
No accuracy
No repeatability
No reusability
More budget is required
Test team may get bored and tiredness

The pre-requisite for automation is application should be stable like more than 70%. (it
may vary based on the company)
10/26/11 Durgasoft
So automation testing is not the replacement for manual testing.
To overcome all the drawbacks of manual testing, just it is a continuation to the manual
testing.

Why we need to go for automation:


Once application is stable then we can continue generating the instructions with the help
of any tool.
By using tool or automation will give below advantages:

Required less time


Less no. of resources are required
Accuracy
Repeatability
Reusability
In the long span of time, budget also gets reduced.

How to work with automation testing:

QTP
Application TC’s pass
Test Partner
TC’s TC’s fail
Winrunner
1
2
10/26/11
3 Instructions
Durgasoft
About QTP

QTP is a graphical user interface functional regression testing tool

Vendor for QTP is mercury interactive and later it was undertaken by the HP in 2006.

Scripting language required for QTP is VB Script .


Note: It also supports Java Script.

QTP is used for perform GUI and regression testing.

QTP supports only windows operating system all versions except window 97.

QTP supports applications like java, .net, web, windows, siebel, SAP, ERP, mainframes,
cobol, flex and powerbuilder applications.

QTP supports databases like oracle, SQL server, sybase, mybase, mysql………

QTP supported environments are windows, client-server, web and distributed

The latest version of QTP is 11.0.

10/26/11 Durgasoft
Different Versions of QTP are 5.5,6.0,6.5,8.0,8.2,9.0, 9.2, 9.5, 10.0,
11.0

11.0 - Released in 2010


10.0 - Released in 2009
9.5 - Released in 2007
9.2 - Released in 2007
9.0 - Released in 2006
8.2 - Released in 2005
8.0 - Released in 2004
6.5 - Released in 2003
6.0 - Released in 2002
5.5 - First release. Released in 2001

10/26/11 Durgasoft
Browsers supporting QTP are IE ( all versions ), FireFox 3.5 and QTP 11.0 version is
supporting safari also.

Note: Firefox 4.0 will be supported by the QTP but we need to install corresponding
patch 6.11.3

ADD-IN Manager:
It is a interface between QTP tool and different applications.

By using this window we can tune, different type of applications will get recognize by
QTP.

Each type of application will be having specific add-in which we need to get it from the
HP and it is licenced.

Default add-ins supported by QTP are VB, ActiveX and Web.

For any other type of application we need to install corresponding add-in then
automatically, add-in name will be displayed in add-in manager window.

What are all the add-ins we have selected based on that QTP is going to allow for
generating the instructions or identifying the application.
10/26/11 Durgasoft
Applications
Net Add-in manager Support
Web VB By
VB
Java ActiveX QTP
Oracle apps Web
SAP Java
PeopleSoft
Siebel
Terminal Emulators

Licenses:

1. Seat License: It can be used in the single system and also it is not possible to share it to
the other systems.(Mapped with single system and it is not sharable)

2. Concurrent License: This license can be used by the ‘n’ number of persons
simultaneously and also this can be transferrable to other systems.

10/26/11 Durgasoft
QTP Installation Procedure:
Way 1:
1. Install from [Link] ( Trial version for 14 days.)
Format is required for every installation. To overcome the same
we need to download QTP [Link] from [Link] site and
remove all your registry files and Install again without format also as it will work
fine.

Way 2: (Permanent License)


1. Install QTP 9.2 with [Link](It will become permanent license)
2. Uninstall QTP from Control Panel(Don’t use above QTP
[Link])
3. On top of QTP 9.2, Install QTP 10.0 then it will become Permanent
License.

NOTE: Trial for 14 days pop up is not displaying then confirm it is Permanent
Version only.

10/26/11 Durgasoft
10/26/11 Durgasoft
Standard Class Names:

Controls Windows Web Java

Button Winbutton Webbutton Javabutton


Text field Winedit Webedit Javaedit
Label Static WebElement Label
Dropdown box Wincombobox Webcombobox Javacombobox
Check box Wincheckbox Webcheckbox Javacheckbox
Radio button Winradiobutton Webradiobutton Javaradiobutton
Links ----------- Links JavaLink
Dialog Dialog ------------ Javadialog
Browser ------------- Browser JavaBrowser
Menu WinMenu - JavaMenu

10/26/11 Durgasoft
Object Repository:
QTP is required objects or controls properties information for recognizing the objects/
controls for performing one test case navigation. QTP contains a object repository
which is used for maintaining all the object property information for recognizing the
object.
By default it takes care of all the properties required for identification.

Options:

1. Add objects to local: It is used for adding the application objects along with
properties.

2. Highlight in Application: It used for justifying added objects are getting recognized by
QTP tool

3. Navigation for Object Repository:

resource  object repository

10/26/11 Durgasoft
Object Spy:
It is the feature used for viewing the object properties hold by the controls
available in our application.
Object spy display the objects property names and their property values, but
where as object repository is used for storing the objects, mandatory properties
for recognizing the objects.

It is used for verify object status like enabled, focused and visible…etc.

10/26/11 Durgasoft
Types of Objects:

There are 2 types of objects available in any application


1. Test Objects:
Objects which are static(Constant).
These Objects all Properties and their values are not going to change in runtime.

Ex: Labels,Menus….

2. Runtime Objects:
Any Object property values are getting changed in runtime then those all objects are
Runtime Objects.
Any property value may get changed based on operation performed on our applcation for
these objects.

Ex: Button,text field,Drop down box, checkbox,radiobutton…..

Getroproperty:
It is used for fetching the runtime object property value.
Objects may have n no of properties, Whenever we require to fetch any runtime property
value then we can fetch using this property.
10/26/11 Durgasoft
QTP Script

1)Button:

Syntax:
(Parent window standard type)(parent window object name).(child standard
type)(child object name).operation

Ex:
Dialog("Login").WinButton("OK").Click
Dialog("Login").WinButton("Help").Click
Dialog("Login").WinButton("Cancel").Click

Msgbox Dialog("Login").WinButton("OK").GetROProperty("enabled")
Msgbox Dialog("Login").WinButton("OK").GetROProperty("focused")
Msgbox Dialog("Login").WinButton("OK").GetROProperty("visible")

10/26/11 Durgasoft
2. Text Box
1. enter/clear
2. enabled/disabled
3. existence
4. verifying entered data
[Link]
[Link]
7. length and width
Ex:

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


Dialog("Login").WinEdit("Agent Name:").Set "“
Dialog("Login").WinEdit("Agent Name:").GetROProperty("enabled") ----> True/False
Dialog("Login").WinEdit("Agent Name:").Exist ---> True/False
Dialog("Login").WinEdit("Agent Name:").GetROProperty("text") ---> Get entered value
Dialog("Login").WinEdit("Agent Name:").GetROProperty("visible") ---> True/False
Dialog("Login").WinEdit("Agent Name:").GetROProperty("focused") ---> True/False
Dialog("Login").WinEdit("Agent Name:").GetROProperty("length")
Dialog("Login").WinEdit("Agent Name:").GetROProperty("width")

10/26/11 Durgasoft
3. List Box/combobox

1. Select item name/index


2. Get All items / Get Content
3. Get current selected item
4. Get item count
5. enabled
6. Focused
7. visible
8. Exist

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


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

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("all


items")
msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetContent

msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetROProperty("text")


msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetSelection

10/26/11 Durgasoft
msgbox Window("Flight Reservation").WinComboBox("Fly From:").GetItemsCount

msgbox Window("Flight Reservation").WinComboBox("Fly


From:").GetROProperty("enabled")
msgbox Window("Flight Reservation").WinComboBox("Fly
From:").GetROProperty("focused")
msgbox Window("Flight Reservation").WinComboBox("Fly
From:").GetROProperty("visible")
msgbox Window("Flight Reservation").WinComboBox("Fly From:").Exist

Note: Above all methods will be same for list box in both WINDOWS or WEB
applications.

10/26/11 Durgasoft
4. CheckBox

1. Select
2. deselect
3. enabled
4. exist
5. checked or not
6. focused

window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set


"ON"
window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer Name").Set
"OFF"
window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer
Name").GetROProperty("enabled")
Msgbox window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer
Name").Exist
msgbox window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer
Name").GetROProperty("checked")
msgbox window("Flight Reservation").Dialog("Open Order").WinCheckBox("Customer
Name").GetROProperty("focused")

10/26/11 Durgasoft
5. Radio Button:

1. set radio button


2. Verify Checked
3. Exist
4. visible
5. enabled

Window("Flight Reservation").WinRadioButton("First").Set
msgbox
Window("FlightReservation").WinRadioButton("First").GetROProperty("checked") --->
ON/OFF
msgbox Window("Flight Reservation").WinRadioButton("First").Exist
msgbox Window("Flight Reservation").WinRadioButton("First").GetROProperty("visible")
msgbox
Window("FlightReservation").WinRadioButton("First").GetROProperty("enabled")

10/26/11 Durgasoft
6. Menu:
[Link]
[Link]

msgbox Window("Flight Reservation").WinMenu("Menu").Exist

Window("Flight Reservation").WinMenu("Menu").Select "File;New Order“


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

10/26/11 Durgasoft
7. Browser:

1. open
2. exist
3. close
4. Full Screen
5. Refresh
6. maximize/ minimize
7. activate
Ex:
[Link] “[Link]”, “URL”
Msgbox browser (“orange hrm”). Exist
Browser (“orange hrm”). Close
Browser (“orange hrm”). Fullscreen
Browser (“orange hrm”). refresh

Strhwnd = browser (“orange hrm”). Getroporperty (“hwnd”)


Window (“hwnd:=“&strhwnd). Maximize
Window (“hwnd:=“&strhwnd). Minimize
Window (“hwnd:=“&strhwnd). Activate

10/26/11 Durgasoft
8. ACTIVEX:

1. Type
2. Enabled
3. visible
4. Retrieve activex field value

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


msgbox Window("Flight
Reservation").ActiveX("MaskEdBox").GetROProperty("enabled")
msgbox Window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("visible")
msgbox Window("Flight Reservation").ActiveX("MaskEdBox").GetROProperty("text")

10/26/11 v
9. Page:
1. exist
Browser (“orange hrm”). Page (“orange hrm”).Exist

10. Frame:
1. exist
Browser (“orange hrm”). Page (“orange hrm”).Frame(“Orange hrm”).Exist

11. Link:
1. click
2. exist

Browser (“orange hrm”). Page (“orange hrm”). Link (“change password”). Click
Msgbox Browser (“orange hrm”). Page (“orange hrm”). Link (“change
password”). Exist

10/26/11 Durgasoft
12. Web Table:
1. rows
2. columns
3. data of each cell
4. exist

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”).


Webtable (“quality center”). Getroproperty (“rows”)
Msgbox Browser (“mercury quality center”). Page (“mercury quality center”).
Webtable (“quality center”). Rowcount

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”).


Webtable (“quality center”). Getroproperty (“cols”)

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”).


Webtable (“quality center”). Getcelldata (3, 1)

Msgbox Browser (“mercury quality center”). Page (“mercury quality center”).


Webtable (“quality center”).Exist

Set OBJ = browser("Untitled Page").Page("Untitled


Page").WebTable("TestId").ChildItem(4,3,"Link",0)
[Link]
10/26/11 Durgasoft
Utility Statement:
It is used for opening the application or executing the exe’s.
We need to specify type of browser as a first argument to the utility statement along with
path as second argument for opening the web application with specific browser.
Whenever we need to work with windows application, then we need to specify exe file
path.

[Link] “browser”, “URL”


[Link] “path”

Ex: [Link] "[Link]","[Link]"

10/26/11 Durgasoft
Object Methods:

1. Getroproperty:
It is used for fetching the runtime object property value.
Objects may have n no of properties, Whenever we require to fetch any runtime property
value then we can fetch using this property.

2. Select:
It is used for selecting the particular item from the combo box ,drop down list box and also
selecting items in Menu.

3. Click:
It is used for clicking on the button, link.

4. Set:
It is used for set the data into test field and clearing the data.
It is used for check checkbox by providing the arguments ON and OFF.

5. Type:
It is used for type the particular data into text field / ACTIVEX.

6. Maximize:
It is10/26/11
used for maximizing the window or dialog or browser.
Durgasoft
7. Minimize:
It is used for minimizing the window or dialog or browser.

8. Activate:
It is used for activating the dialog or window or browser.

9. Exist:
It is used for checking the control or objects availability. If it is available it will return true,
else false.

10. Close:
It is used for closing the existing window or dialog or browser on our desktop.

10/26/11 Durgasoft
11. Fullscreen:
It is used for fullscreen the browser window.

12. Refresh:
It is used for refreshing the specific browser window.

13. Gettoproperty:
It is used for fetching the test object properties, it means the properties and their values
are constant while developing the instructions and while executing the instructions.

Note: Getropropety is used for fetching the not only runtime object properties but also
test object properties as well.

10/26/11 Durgasoft
VB Script
 It is a light weight programming language
 Microsoft is the vendor for VB Script
 VB Script is used for verification purpose along with QTP.

Note: We can use VB Script for developing the web applications along with
HTML.

Variable:
It is name of the memory location in RAM. By using this name we can keep test data and
we can fetch whenever we require while executing the instructions.
Note: We can update the data in n no of times in Temporary memory using variable name.

strname
venkat
intage

10/26/11 Durgasoft
Naming Restrictions:

Variable names follow the standard rules for naming anything in VBScript.
A variable name should be:

Must begin with an alphabetic character.


Cannot contain an embedded period(.).
Must not exceed 255 characters.
Must be unique in the scope in which it is declared.

NOTE: VBScript has only one data type called a Variant. A Variant is a special kind of data
type that can contain or hold different kinds of information like strings,chars,numerics,date
and decimals…..

10/26/11 Durgasoft
Declaration of Variable:

By using this we can update memory cell name or variables names to the QTP tool.
We have to use the keyword ‘DIM’ ( dimension ) for declaring the variable. It is not
mandatory to declare a variable in VB Script as it is having auto declaration.

DIM strinstname
DIM intage
DIM fltweight

Initializing the Variables:


Assigning the data to the variables.
By using “=“ operator ,we used to assign data to the variables.
NOTE:
1. For strings as we need to use double quotes.
strinstname = “Venkat”
2. For integers and float, no need to use any quotes.
intage = 50
fltweight = 10.5

10/26/11 Durgasoft
Constants:

A constant is a meaningful name that takes the place of a number or string and never
changes.

If at all you don’t want to change value in variable and required same value in entire
script then need to declare as a constant and assign the value.

Declaring constant variables:

Const MyString = "This is my string."

Const MyAge
MyAge = 49

Const CutoffDate = #6-1-97#

10/26/11 Durgasoft
Option Explicit:

It is the statement used for finding the undeclared variables in our instructions. It
will throw an error whenever it finds any variable is not declared.

To overcome the unexpected results with the misspelled variables ,we have to
declare every variable along with option explicit statement.

NOTE: We should need to use Option Explicit as first statement in our script.

‘Ex: ‘Option explicit


Dim strname

Strname = “Venkata Krishna”

msgbox strnam

o/p: empty

10/26/11 Durgasoft
Operators:

1. Arithmetic:
+, -, *, /, %

2. Assignment:
=

3. Logical:
And , Or and Not

[Link]:
<,>,<=,>=,<>

5. Concatenation:
&
Ex: strname1 = “venkat”
strname2 = “krishna”
strfullname = strname1 & “_” & strname2
msgbox strfullname

10/26/11 Output: venkat_krishna Durgasoft


Conditional Statements:
Conditionally executes a group of statements, depending on the value of an
expression(Condition).
These statements are used for verifying the application behaviour based on the actions
done on our application.
NOTE: If condition is True then only it is going to execute set of statements.

There are 2 types


[Link] statement
[Link] case statement

1. If Statement:
This is classified into 3 types
[Link] If End If
[Link] else end if
[Link] if else End If

10/26/11 Durgasoft
1) Simple IF -

Syntax:

1) If (condition) then
……………..Set of stmts
…………..
End if

2) If Else End If

Syntax:
If (condition) then
………………. Set of stmts
……………..
Else
………… Set of stmts
………….
End if

10/26/11 Durgasoft
3) Nested If Else End If
Syntax:
If (condition) then
……….
Else if (condition) then
……………
Else if (condition) then
…………
Else
…………
End if
Ex: Simple If
inti = 10
If inti < 5 then
msgbox “I value is less than 5”
End If
Ex: If Else End If
Inti = 10
If inti< 5 then
msgbox “I value is less than 5”
Else
msgbox “I value is greater than 5”
End If
10/26/11 Durgasoft
EX: Nested If Else
Intvalue = 5
If intvalue < 5 then
msgbox “value is less than 5”
Else if intvalue < 10 then
msgbox “value is less than 10”
Else if intvalue < 15 then
msgbox “value is less than 15”
Else
msgbox “value is more or equal to 15”
End if

Ex:
[Link] “URL”
If dialog (“login”). Exist then
Msgbox “dialog window opened successfully”)
Else
Msgbox (“dialog window not opened”)
End if

10/26/11 Durgasoft
2. Select Case
Executes one of several groups of statements, depending on the value of an expression.

Select expression
Case 1:
………
………
Case 2:
Case 3: ………..
Case N: ……….

Case Else:
…………
End select
Ex:
I = 15
Select case I
Case 1: msgbox “value is 1”
Case 2: msgbox “value is 2”
Case 10: msgbox “value is 10”
Case 15: msgbox “value is 15”
End select
10/26/11 Durgasoft
Looping Statements:
These are used for executing the set of statements repeatedly based on requirement in
our test case.
If we know starting and ending points for executing set of statements like some fixed
number of times then you can use for loop.

For Loop:
Syntax:
For (Start) to (End)
…………..
………….
Next

Ex: for i=10 to 30


I=I+1
msgbox I
next

o/p: 11, 13, 15, 17,…………………….

10/26/11 Durgasoft
Ex:
For i=1 to 100
i= i+4
If i>50 Then
msgbox "He will satisfy with his 50 lacks money"
Exit For
End If
Next

10/26/11 Durgasoft
While Loop

If we don’t know starting and ending points but we have to execute set of
statements repeatedly based on the assignment/Condition, then have to use
while loop.
Note: Do Loop While and Do While Loop are going to execute set of statements
repeatedly till the condition becomes false.

While loop is classified into 5 types


[Link] While Wend
[Link] While Loop
[Link] Loop While
[Link] Loop Until
[Link] Until Loop

Simple While Wend:


It will execute the statements till the condition will become False.

While (condition)
statements
Wend
10/26/11 Durgasoft
Example:
intCount = 0
While(intCount<20)
intCount = intCount +1
Msgbox intCount
Wend

Output: 1,2,3,4,……20

Do While Loop:

Syntax:
do while ( condition )
…………..
………….stmts
loop

10/26/11 Durgasoft
Ex: i=30
Do while (i>20)
i = i-1
msgbox i
Loop
OutPut: 29,28,27……..21,20.

Do Loop While:
Syntax: do
…………….Stmts
loop while ( condition )

Ex: I = 30
do
I=I–1
msgbox I
loop while ( I > 20 )

o/p: 29, 28, 27, ………………….., 21

NOTE: Simple While and Do while loop are both are same. We can use any one based
on our requirement.
10/26/11 Durgasoft
Do Loop Until:

Note: Do Loop until and Do untilLoop are going to execute set of statements repeatedly
till the condition becomes True.

Syntax:
do
…………………
…………………stmts
loop until ( assignment )

Ex:
I = 10
do
I=I+1
Msgbox I
Loop until ( I = 20 )

O/P: 11,12, 13,……………………., 20

10/26/11 Durgasoft
Do Until Loop:

Syntax:
do until ( assignment )
……………
……………….stmts
loop

Ex:
I = 10
do until ( I = 20 )
I=I+1
msgbox I
loop

o/p: 11, 12, 13,……………………, 20

10/26/11 Durgasoft
Functions
It is containing collection of statements used for performing the particular task or
operation.
It can allow us to reuse by passing multiple arguments.
Wherever we need to use same set of statements, we can make a call to function.

Types of Arguments:
Parameters which we are passing to the function is called [Link] are 2 types.

[Link] arguments
[Link] arguments

Input arguments are passed to the function from calling environment and output
arguments are returned from the called environment to the calling environment.

Syntax:
Function ( function name ) { arguments }
……………………
……………………
………………………….
End Function

10/26/11 Durgasoft
I/P: 10,20 I/P: 10,20
Operator: + Operator: -
O/P: 30 O/P: -10

CALCULATOR
I/P: 10,5
I/P:30,3
Operator: *
Operator: /
O/P: 50
O/P: 3

TC:Open,Login into Application


I/P: Username and Password

O/P: User Should logged in and it


should display home page
Function
(Called Environment)

I/P Arguments: Username and Password


O/P Arguments: User Logged in
(Calling Environment)
10/26/11 Durgasoft
Note:
Function is differentiating input and output arguments using byval and byref keywords.
Byval is used for specifying it as a input arguments.
Byref is used for specifying it as a output arguments.

Syntax:
Function ( function name ) [ byval {argument name}, byval {argument name}, …,
byref {argument name}, ……………. ]
………………….
……………………
………………………
End Function
Advantages of working with functions:
[Link]
[Link] time will be saved
[Link] maintenance
[Link]

Creating & Calling Functions:


Identify input and output arguments
Creating function definition.
Call to Function by passing arguments
10/26/11 Durgasoft
Ex:
Call login("suresh","mercury“, blnstatus)
msgbox blnstatus

Function login( byval strname, byval strpwd, byref blnstatus)


[Link] "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\[Link]"
If dialog("Login").Exist Then
dialog("Login").WinEdit("Agent Name:").Set strname
dialog("Login").WinEdit("Password:").Set strpwd
dialog("Login").WinButton("OK").Click
End If
wait 5
If window("Flight Reservation").Exist (5) Then
blnstatus = true
else
blnstatus = false
End If
End Function

10/26/11 Durgasoft
Ex:
blnstatus = login ("suresh","mercury“,)
msgbox blnstatus

Function login( byval strname, byval strpwd)


[Link] "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\[Link]"
If dialog("Login").Exist Then
dialog("Login").WinEdit("Agent Name:").Set strname
dialog("Login").WinEdit("Password:").Set strpwd
dialog("Login").WinButton("OK").Click
End If
wait 5
If window("Flight Reservation").Exist (5) Then
login = true
else
login = false
End If
End Function

Note: From where the function definition will be there, we are calling this as a calling
environment and where which it is called by calling env is called Called Environment.
10/26/11 Durgasoft
How to make a call to function

Syntax:
call functionname ( arguments )
Variable = functionname ( arguments )

Ex:
1) Call login("suresh","mercury“, blnstatus)

2) blnstatus = login ("suresh","mercury“,)


msgbox blnstatus

Creating Libraries:
We have to copy or place all the functions into notepad file and save with .vbs extension
then it will become a vbscript library.
We can place ‘n’ number of functions into one library. ( there is no restrictions for placing
the no. of functions )

NOTE: We can also save function library with extension .QFL(Quick Functionary Library)
and it will works same as .VBS.

10/26/11 Durgasoft
Associating library file to QTP tool:
We have to map library file to the QTP tool so that we can reuse same function in
multiple areas.
We have to attach this library file to below path
File

Settings

Resources

Associate the file to library ( navigate to library path )

Sub Procedures:
Sub Procedure is also a Function but it can not return value.

Syntax: Sub name(arguments)


-------Stmts
End Sub

Call to Sub: Call name(arguments)

Sub addition(a,b)
addition = a+b
End10/26/11
sub Durgasoft
In Built Functions:
1. CDate
2. Date
3. DateAdd
4. DateDiff
5. Now
6. Time
7. WeekDay
8. WeekDayName
9. Month
10. MonthName
11. Year
12. IsDate
13. Left
14. Right
15. Replace
16. strComp
17. strReverse
18. Lcase
19. Ucase
20. Trim

10/26/11 Durgasoft
21. LTRIM
22. RTRIM
23. Len
24. Instr
25. Cstr
26. Cint
27. Mid

'1. CDate --.: Converts text format into Date Format


msgbox Cdate("2000 October 29 ")
msgbox Cdate("October 2000 29")
msgbox Cdate("29 October 2000")
msgbox Cdate("29 2000 October")
msgbox Cdate("2000 29 October")

'[Link] --: Returns the current system date


msgbox date

10/26/11 Durgasoft
3. DateAdd --: Returns a date to which a specified time interval has been added
msgbox DateAdd("m", 1, date()) '----->Addition based on Months
msgbox Dateadd("YYYY",1,date()) '----->Addition based on Years
msgbox Dateadd("q",1,date()) '----->Addition based on Quarters
msgbox Dateadd("d",10,date()) '----->Addition based on Days
msgbox Dateadd("ww",2,date()) '----->Addition based on Weeks

'4. DateDiff --: Returns the number of intervals between two dates
msgbox datediff("m",date,Cdate("19 December 2011")) 'Difference in months
msgbox datediff("YYYY",date,Cdate("19 December 2011")) 'Difference in Years
msgbox datediff("WW",date,Cdate("19 December 2011")) 'Difference in Weeks
msgbox datediff("h",date,Cdate("19 December 2011")) 'Difference in Hours
msgbox datediff("d",date,Cdate("19 December 2011")) 'Difference in Days

'5. Now -----: Returns the current system date and time
Msgbox Now()

'6. Time --> Returns the current system time


Msgbox Time()

'[Link] --: Returns a number that represents the day of the week (between
1 and 7, inclusive)
Msgbox Weekday(date())
10/26/11 Durgasoft
'8. WeekdayName --:Returns the weekday name of a specified day of the week
msgbox weekdayname(weekday(date))

'9. Month --> Returns a number that represents the month of the year
(between 1 and 12, inclusive)
Msgbox Month(Date())

'10. MonthName --> Returns the name of a specified month


Msgbox MonthName(Month(Date()))

'11. Year --: Returns a number that represents the year


Msgbox year(Date())

'12. IsDate ---: Verifying date whether is date or not


Msgbox IsDate("19 March 2012")
Msgbox IsDate("25/10/2020")

'13. Left --: Returns a specified number of characters from the left side of a
string
msgbox Left("Venkata Krishna",7)

10/26/11 Durgasoft
14. Right --: Returns a specified number of characters from the right side of a string
Msgbox Right("Venkata krishna",7)

'15. Replace --: Replaces a specified part of a string with another string a specified
number of times
msgbox Replace(“Durga Software Solutions",“Solutions",“Pvt Ltd")

'16. StrComp --> Compares two strings and returns a value that represents the result
of the comparison
Msgbox strComp("Venkata krishna","Venkata krishna",1) '--> O/P: Zero if both are
same

'17:StrReverse --> Reverses a string


Msgbox strReverse("Venkata Krishna")

'18. Lcase:
It will convert all the uppercase strings into lowercase
Ex:
strname = “KRISHNA”
msgbox lcase (strname)

10/26/11 Durgasoft
19. Ucase:
It will convert all the lowercase strings into uppercase
EX:
strname = “krishna”
msgbox ucase (strname)

20. Trim:
It is used for removing the spaces at the begin and end of the given string.
Ex:
strname = “ KRISHNA ”
msgbox trim (strname)

21. Ltrim:
It is used for removing the spaces only at the beginning of the string.
Ex:
strname = “ KRISHNA”
msgbox ltrim (strname)

22. Rtrim:
It is used for removing the spaces at the end of the string only.
Ex:
strname = “KRISHNA ”
10/26/11
msgbox rtrim (strname) Durgasoft
23. Len:
It is used for finding the length of the given string.
Ex:
strname = “ KRISHNA ”
msgbox len (strname)

24. Instr:
It is used for finding the one string exsistency in another string.
Syntax:
instr ( starting char no, first string, search string )
strfirst = “venkat krishna”
strsecond = “krishna”
msgbox instr ( 1, strfirst, strsecond )
25. Cstr:
It is used for converting any integers or floats into string format
Ex:
msgbox cstr (10)
26. Cint:
It is used for converting any string into integer format.
Ex:
msgbox cint (“10”) + 10

10/26/11 Durgasoft
27. Mid:
It is used for fetching the substring from another string by using the starting char
and after that no. of chars
Ex:
strfirst = “venkat krishna”
msgbox mid (strfirst, 4, 5)

10/26/11 Durgasoft
ACTIONS
Actions are used for reducing the complexity of test script.
A script may have n no of actions.
There are 2 types of actions
[Link]
[Link] (Reusable Action)

Note: Using reusable actions we can get the reusability and also maintenance will be
easier.
We can design tests that are more modular and efficient.

Creating Normal Actions:


Insert

Call to new action

Normal reusable

Note: for converting reusable action into non-reusable action by unchecking reusable
action option.
10/26/11 Durgasoft
Right click on action

Action option

Click on action properties

In action properties uncheck reusable action


Action Properties

Reusable Action

Inserting Reusable Action:

Insert

Call to new reusable action

Action will be added into script

10/26/11 Durgasoft
Creating the External Action:
We can create external action only with reusable action.
We can pass multiple input and output arguments. For fetching the parameter values into
external action. We have to use “parameter” syntax.
Procedure:
[Link] functionality
[Link] script for reusable action along with specify arguments
[Link] reusable action
[Link] reusable action from other location (external action).
Called Environment or External Action Definition:
Struname = parameter (“strusername”)
Strpassword = parameter (“strpwd”)
Strpath = parameter (“strpath”)

[Link] strpath

If dialog(“login”).exist then
dialog(“login”).winedit (“agentname”).set struname
dialog(“login”).winedit (“password”).set strpwd
dialog(“login”).winbutton (“ok”). Click
End if

10/26/11 Durgasoft
If window (“flight reservation”). Exist(10) then
parameter (“blnstatus”) = true
else
parameter (“blnstatus”) = false
End if

Calling Environment or Reusable Action Call

Insert

Call to existing action

Browse to reusable action

Ok

Strflightpath = “url”
Runaction “login [login_ra]”, oneiteration, “suresh”, “mercury”, strflightpath, blnstatus
Msgbox blnstatus

10/26/11 Durgasoft
Call to copy of action

Insert

Call to copy of action

Select of action
Browse

Ok

Click on ok

Note: External actions are in read only mode in the calling environment
We can edit or modify the external action only by opening the reusable action definition.
When we want to edit some part in external action and use for your test case then we can
use call to copy of action. It will allow us to edit or modify in the calling environment.

Runaction “copy of login”, oneiteration, “venkat”, “mercury”, blnstatus


Msgbox blnstatus

10/26/11 Durgasoft
Split:
Using this we can split one action into two actions based on the cursor position
We can split one action into multiple actions by doing split operation.

Note: To reduce the complexity of test script we can split or maintain no of actions.

OBJECT REPOSITORY:
OR is used for maintaining all the objects in central location which is used for identifying
the controls on our application.

Repository is of 2 types
[Link] object repository
[Link] object repository

Local object repository


It is local to the particular script. What are all the updates/changes done on object
repository will be applicable to the same script.
We cannot reuse local objects in other scripts.

Note: if at all the test cases are having different functionalities then we have to use local
object repository and its file extension is mtr(mercury test repository).

10/26/11 Durgasoft
Creating Shared Object Repository:

1. Create from local objects


2. Directly from ORM
Note: shared object repository is the place where it will allow add the objects into
repository and map the same to the ‘n’ number of scripts and it extension is tsr(test
shared repository)
Advantages:
Reusability
Overcome the redundancy/duplication
Maintenance will be easier
Create from local objects:
Open local OR

File

Export local objects

Browse

Ok .tsr (test shared repository)


10/26/11 Durgasoft
Associate Reposirtories:
Resources

Associate repositories

Browse

Available Associate
Action1
Action2 Ok

Open/update SOR:

Resources

Object repository manger (ORM)

File  open  browse to OR path

Open in read only mode

Click on enable editing for modify/update


10/26/11 Durgasoft
Directly from ORM

Resource

Object Repository Manager

Add objects

Save  .tsr

Associate repositories

NOTE: SOR will be in read only mode in all scripts and we can not modify in scripts.
If we want to modify/update then need to open it in ORM and edit the same.

10/26/11 Durgasoft
Descriptive Programming:
We are not going to use OR for developing the instructions.
The properties required for identifying the objects we are going to keep directly in our
instructions.

Application is not available and if at all we want to generate the instructions parallel to
the development phase then by taking all the object properties from development team
and we can able to develop the instructions.

Note:
1) Based on client request we can proceed with descriptive programming.
2) Whenever any object properties are keep on changing based on the input data then
also we can manage using descriptive programming.

Advantages:
Execution will be faster compared to using OR.
Managing the runtime objects which properties are frequently changing.

10/26/11 Durgasoft
Descriptive Programming Instructions

If dialog(“text:=login”, “nativeclass:=#32770”). Exist then


dialog(“text:=login”, “nativeclass:=#32770”). Winedit (“class:=edit”,
“text:=agentname”). set “venkat”
dialog(“text:=login”, “nativeclass:=#32770”). Winedit (“class:=edit”,
“text:=password”). set “mercury”
dialog(“text:=login”, “nativeclass:=#32770”). Winbutton (“class:=button”,
“name:=ok”). Click
End if

2nd way of Description Programming:


Set DC = [Link]()
DC(“text”).value = “Login”
DC(“nativeclass”).value = “#32770”

Dialog(DC). Exist

Runtime Object Handling:

Handling runtime object property values and make qtp to identify and perform action
on it.

10/26/11 Durgasoft
Regular Expressions:

It is used for regularize the property values of the objects. If at all object property value is
getting changed frequently then using OR, It is not possible to identify the object.

If at all changing part is no need to consider for identification then we can ignore change
part of property value by using Regular Expression.

For ignore any part of Property value, just we need to remove change part and replace it
with “.*” then QTP will try to identify the object using non changed part and ignore the rest
of property value.

There are two ways of using RE’s


[Link] in OR
[Link] Descriptive Programming

Login Venkat100
In OR
Venkat make
Name
venkat
100 as .*

10/26/11 ok Durgasoft
1. Directly in OR:
Navigation:

Resources

ORM

class Webedit

properties Click on Button

Value configuration options

…………*

Regular expression
ok

10/26/11 Durgasoft
2. In Descriptive Programming:

We can use regular expressions in DP for recognizing the object by making regularize.
We have to enter .* for the changing part same like OR.

Window (“text:=“, “native class”)


Dialog (“text:= faxorder.*”, “native classs:=#32770”). exist

10/26/11 Durgasoft
Transactions:
For finding the application performance using QTP, we have to use transactions. We have
to insert transactions at some point or step in our script and we have to end at some step
then it will provide script execution time or transaction time will be provided for the
statements between start and end transactions.

Navigation:
insert

start transaction / end transaction

Ex:
[Link] "trans1"

Wait 4

[Link] "trans1"

10/26/11 Durgasoft
Environment Variables:
Based on the environment such as UAT, SIT ,preproduction, production, The environment
data may be changed at any time and we have to change our test data accordingly for our
script execution.

For managing test data effectively when ever Environment is change then we have to use
EV;s.
Test Data :
[Link] URL
[Link] Credentials
[Link] Credentials…
NOTE: For getting reusability and easy maintenance ,EV’s are required.

It is a global file, it means we can access the variable values from all over test pack(All Test
Scripts).
It is a XML file, we can generate XML file from user defined environment variables by
exporting internal environment variables.

Environment variables are 2 types:


[Link]-built
[Link]-defined

10/26/11 Durgasoft
In-built: These are provided by QTP for retrieving the testing or working machine
specifications.
ex: Action name, OS, OS Version, temp directory, etc.,

User-defined: Based on our requirement if at all any data is changing based on the
environment, we can define environment variables in environment tab under resources
option.
Once we exported all the internal EV’s will automatically become external, it means we can
use these variables anywhere in our script.

Navigation:
file

settings

environment
Syntax:
<Environment>
<variable>
<name>………….</name>
<value>…………. </value>
</variable>
</Environment>
10/26/11 Durgasoft
Creating EV(XML) File:
[Link] using QTP
Add required EV’s into user defined EV’s and try to export all those
variables into other location then automatically EV’s will become a Global and we can
reuse this test data in n no of script

[Link] the EV’s file using above syntax with Variable names and Variable values.

NOTE:
If at all we need to use this test data then we need to associate the EV’s file to QTP in
Environment tab under test Settings window.

10/26/11 Durgasoft
Associating Environment Variable File:
file

settings

environment

variable type  (user defined)

check the load variable checkbox

import the created XML file

click on apply

ok

Accessing the environment variable data:


[Link] (“variable name”)

Ex: [Link] (“OS”)  In-built


[Link] (“strusername”)  User-defined
10/26/11 Durgasoft
Data Table:
It is used for maintaining the test data in runtime(While running script),

By using this we can execute our script many no. of times as per records in Data table.
It will maintain the data temporarily while executing, after execution this data will
disappear. We can import and export data from external files(EXCEL).

NOTE:
[Link] can maintain run time test data or export any data as output.
[Link] will allow us to Import and Export data from/To Data Table from other source XLS.
[Link] table is having inbuilt feature to run same script no of times based on records in
Data Table and that will depend on Run Settings.

It is used for retrieving from data table


Syntax:
[Link] (“colname”, datatable type)

Ex:
[Link] (“A”, Global)
[Link](“A”)

10/26/11 Durgasoft
Methods of DataTable:

[Link]: It is used for importing the data from excel (.xls) sheet. It will import all the
sheets data into available datatables in our script.
Syntax: [Link] ( “ excel path” )
Ex: [Link] ("C:\[Link]")

[Link] Sheet: It is used to import specific sheet data into data table.
Syntax: [Link] (“filepath”, “sheet id/name”, “destination id/name”)
Ex: [Link] "C:\[Link]" ,1 ,“Global"

[Link] Sheet: It will add the new sheet into data table
Syntax: [Link] (“name of the sheet”)
Ex: Variable=[Link] ("MySheet").AddParameter("Time", "8:00")

[Link] Sheet: It will delete the existing sheet from the data table
Syntax: [Link] (“sheet id/name”)
Ex: [Link] "MySheet"

[Link]: It is used for exporting the data from our script from all the data tables into
specified location.
Syntax: [Link](“path of file destination”)
Ex: [Link] ("C:\[Link]")
10/26/11 Durgasoft
[Link] Sheet: It is used for exporting the specific datatable data in our script
Syntax: [Link] (“destination path”, “global/action”)
Ex: [Link] "C:\[Link]" ,1

[Link] Current row: It is used for getting the active row from the Global data table.
Syntax: [Link](“sheet name”).getccurrentrow.
Ex: row = [Link]

[Link] Row Count: It will give the rows count of data table
Ex: [Link]  Global Data Table
[Link](name of sheet).getrowcount Local Data Table

[Link] Sheet count: It will give all the sheets count in data table in our script.
Ex: [Link]

[Link] Current Row: It will make the specific row as active row
Ex: [Link] (“row number”)

[Link] Next Row: It will set the immediate next row as active row
Ex: [Link]

[Link] Prev Row: It will set the previous row as active row
ex:10/26/11
[Link] Durgasoft
[Link]: It is used for retrieving and updating the value into the datatable.
Ex: [Link]

[Link] Value: It is used for fetching the formulae of specific field or cell in our data table.
Ex: [Link]

10/26/11 Durgasoft
Debug Viewer Pane:
Debugging: It is the process of executing instructions with the intention of finding script
errors/issues.
This pane is used for doing the debugging process effectively for correcting errors.

Breakpoint:
This point is used for stopping the script execution temporarily in runtime.
Place the cursor where need to insert break point.

Debug

Insert / remove breakpoint option

Note: By using the mouse left button, click on left side to our script statement will insert
the break point.

Debug Viewer Pane option:


Watch: This is used to watch required variable along with their values.

Variables: It will contain all the variables and their data will be displayed, it will allow us
to modify the data as well.
The changed data will get reflected in all the places in our script.
10/26/11 Durgasoft
Command: It will allow us to execute the instructions and we can observe the results.

Debugging Keywords:
Step into: It will take control to the inside of the function/Action and will allow us to
execute all the statements line by line.

Step over: It will skip line by line execution for functions and reusable actions and It will
execute all the instructions and control will stop at immediate next line after
Function/Action call.

Step out: It is used to move control out of function or reusable action.


After step out control will move to the immediate next statement after function call or
reusable action call.

Debug from step: It will perform script execution in debugging mode.

10/26/11 Durgasoft
Object Identification:
Objects will be identified by using QTP based on properties stored in OR.

Object identification is the place where we can manage our properties of all the controls
which are need to add into the object repository for identication.

Here it will display all the controls of all the supported environments.

If at all any control type is not getting recognized using default properties then we can
edit below properties and try to make QTP to recognize the object type.

[Link]
[Link]
[Link] Identifier
a. Location
b. Index
[Link] Filter
[Link] Filter

Navigation: Tools  Object Identification

10/26/11 Durgasoft
Smart Identification:
If at all object is not recognized using default properties such as mandatory and assistive
then based on the selection of smart identification it will use the base filter and optional
filter properties.

Ordinal Identifier:
It is used for uniquely recognize the object using index and location.
1) Index: Whenever few objects are having same properties then QTP will recognize
based on unique no as it is Index.

2) Location: It will use the default coordinates of particular object for reorganization.

Note: 1) Based on the selection of either index or location of specific control, it will use
for recognizing the object.
2) In real time mostly we use to work with index whenever any object is not recognized.

10/26/11 Durgasoft
Automation Object Model:
It is used for automating the manual operations(open QTP,Open Script,Run Script…) on
QTP tool.
By using this we can perform batch executions by creating QTP application reference

Syntax:
'Create an instance of QTP application
Set qtpapp = CreateObject("[Link]")

[Link] 'Launch QTP


[Link] = True 'Make qtp visible
[Link] "E:\QTP Func\QTP Script” 'Open a test
[Link] 'Run the test
[Link] 'Close the QTP and terminate
Set qtpapp = Nothing ‘Clear the object reference

10/26/11 Durgasoft
File System Object:
It is used to work on file system(Machine) such as creating files, folders and delete files,
folders, updating data into file....

It will allow us to perform all the manual operations on file system through script.
All these operations performing with predefined methods provided by file system object
hence we have to create reference for the same.

Set FSO = createobject (“[Link]”)

Methods:
[Link] folder
[Link] Exists
[Link] Text File
[Link] Exists
[Link] data into file
[Link] File
[Link] Folder

10/26/11 Durgasoft
File System Object Methods:

1. Create folder:
[Link]("C:\venkat")

2. Folder Exists:
[Link]("C:\venkat")
3. Create Text File:
[Link]("C:\venkat\[Link]")  CREATE FILE
set FSO1 = [Link]("C:\venkat\[Link]")  PERFORM ACTIONS ON FILE

4. File Exists:
[Link]("C:\venkat\[Link]")
5. Update data into file:
set FSO1 = [Link]("C:\venkat\[Link]")
[Link]("QTP tool is very good automation tool")
[Link]
6. Delete File:
[Link]("C:\venkat\[Link]")
7. Delete Folder:
[Link]("C:\venkat“)

10/26/11 Durgasoft
Script:

Set FSO = CreateObject("[Link]")


[Link]("C:\venkat")

'Folder exists
If [Link]("C:\venkat") then
set FSO1 = [Link]("C:\venkat\[Link]")
[Link]("QTP tool is very good automation tool")
[Link]
End If

If [Link]("C:\venkat\[Link]") Then
[Link]("C:\venkat\[Link]")
End If

If [Link]("C:\venkat") Then
[Link]("C:\venkat")
End If

10/26/11 Durgasoft
Child Objects Method:

It is used for fetch objects count/Objects properties of specified object


type.

Set odesk = [Link]()


odesk("micclass").value = "WinEdit"

set obj = Dialog("Login").ChildObjects(odesk)


msgbox [Link]
msgbox obj(0).getroproperty("attached text")
msgbox obj(1).getroproperty("attached text")

10/26/11 Durgasoft
Send Keys Object:

It sends keyboard strokes to the active window (as if typed on the keyboard).

[Link] "[Link]","[Link]"
Browser("Google").Sync

Browser("Google").Page("Google").WebEdit("q").Set "venkat"
Set obj = CreateObject("[Link]")
[Link] "{BACKSPACE}"
wait 4
For i=0 to 5
[Link] "{DOWN}"
Next
[Link] "{ENTER}"

'[Link]("[Link]")

10/26/11 Durgasoft
Data Base Connections:

When ever we need to check DB data as per our requirement then we can connect to DB
from QTP Tool.

In real time, Usually we can connect to DB for verifying the DB data to UI data and check
whether both are same or not.

We can connect to all data bases by providing specific Driver Name for each DB along with
User name and Password.

10/26/11 Durgasoft
Connect to Access Data Base:

Dim strConnection, conn, rs, strSQL

strConnection = "Driver={Microsoft Access Driver (*.mdb)};" & _


"Dbq=" ....\db\[Link]";Uid=admin;Pwd=password;"

Set conn = CreateObject("[Link]")


[Link] strConnection

Set rs = CreateObject("[Link]")
strSQL = "SELECT * FROM myTable"
[Link] strSQL, conn

[Link]
WHILE NOT [Link]
msgbox rs("myField").value ‘myfield is column name
[Link]
WEND

[Link]
Set rs = Nothing

[Link]
Set conn = Nothing
10/26/11 Durgasoft
Connect to Oracel Data Base:

Dim strConnection, conn, rs, strSQL

strConnection = "Driver={Microsoft ODBC for Oracle};" & _


"Server=OracleServerName;uid=username;pwd=password;"

Set conn = CreateObject("[Link]")


[Link] strConnection

Set rs = CreateObject("[Link]")
strSQL = "SELECT * FROM myTable"
[Link] strSQL, conn

[Link]
WHILE NOT [Link]
msgbox rs("myField").value
[Link]
WEND

[Link]
Set rs = Nothing

[Link]
Set conn = Nothing
10/26/11 Durgasoft
Connect to SQL Server Data Base:

Dim strConnection, conn, rs, strSQL

strConnection = "Driver={sqloledb};Server=SQLServerName;" & _


"Database=DBaseName;Uid=sa;Pwd=password;",'"Authenticationtype=windows"

Set conn = CreateObject("[Link]")


[Link] strConnection

Set rs = CreateObject("[Link]")
strSQL = "SELECT * FROM myTable"
[Link] strSQL, conn

[Link]
WHILE NOT [Link]
msgbox rs("myField").value
[Link]
WEND

[Link]
Set rs = Nothing

[Link]
Set conn = Nothing
10/26/11 Durgasoft
Virtual Objects:
Your application may contain objects that behave like standard objects but are not recognized by
QuickTest then you can define these objects as virtual objects and map them to standard classes
such as a button or a check box.

When ever any object is not recognized by the QTP then Virtual Objects is one option for us.
It will map your un identified object to standard object and it will recognize based on co-ordinates
of the object.

Navigation:
Tools  Virtual Objects  New virtual object
It is used for creating new virtual object.

Tools  Virtual Objects  Virtual Object Manager


It is used for managing created virtual objects and operations like delete and creating new one…

Steps to create virtual object:


[Link] on New virtual object
[Link] Next button on welcome to the virtual object page
[Link] standard class(Button,table,list…..) and click next
[Link] virtual object (Select un identified object)
[Link] Object Configuration
[Link] Virtual Object Name
[Link] on Finish button

10/26/11 Durgasoft
Inserting Virtual Object:
[Link] QTP Tool in recording mode.
[Link]/Perform action on created virtual object
[Link] recorded script and check in OR for virtual object.
[Link] the script and verify operation is performing successfully or not.

10/26/11 Durgasoft
BATCH RUNS:
In real time we are performing all the scripts execution unattendly, it means executing
the script without any user interaction.

We are running the scripts from QC and we can store all the scripts,FL,OR,EV….and it will
provide execution results.

We should not use message box in real time scripting, we can use for output verification
while developing the instructions but we should ensure no message boxes at the time of
storing into QC.

We should use reporter statements for storing the test case pass/fail results into QC,
Based on this Automation Engineer can able to find what are all test cases are passed and
what are all test cases are failed.

10/26/11 Durgasoft
Synchronization:

This is mechanism used for Wait/Control our script execution based on application
behaviour to over come run time errors in our script execution.

1. We can work with sync method with the web applications.


2. In Windows applications, we have to use wait and exist methods.

Note: 1. Exist method will be works for all the controls.


2. Wait Property method will also work like Exist method.

Msgbox dialog(“cannot find server”). Exist (10)


Browser (“cannot find server”). Sync
Wait 100
Dialog(“Login”).WaitProperty “visible”,”True”,100000[Time in Milli Seconds]

Exist method will verify for every second till it reach the specified time,when condition
satisfies in middle then control will go to next statement.(It will not wait whole given time)
And same process will be there with Wait Property as well.

In wait, It will constantly waits for specified number of seconds with irrespective of
application existence/status.
10/26/11 Durgasoft
Reporter Event:

It used for reporting test case step result description to the Results report.

NOTE: We will not use MSGBOX stmts in realtime because manual intervention
is required for every MSGBOX statement and also we should not move ahead
until we click on OK button on it.

Syntax:

[Link] Status,what we are verifying, result description

Example:

[Link] micPass,”Verify Flight Login Window”,”Flight Login window


is opened successfully”

[Link] micFail,”Verify Flight Login Window”,”Flight Login window


is NOT opened”

[Link] micDone,”Verify Flight Login Window”,”Flight Login window


is opened clearly…..”
10/26/11 Durgasoft
Recording Modes:
There are 3 types of recording modes which will allow us to perform actions on our
application and parallely QTP will generate instructions or script for the automation
engineers.

[Link] Recording Mode:


It will record the script based on the actions on our application by adding worked objects
into object repository. It is the default recording mode it will recognize the objects based
on properties stored in object repository.

automation

record

2. Analog Recording Mode:


This is used for recording the script for the actions on our application, it will provide
security to the instructions. It will not show recorded script to the automation engineer,
but it will perform all the recorded operations.
There are 2 types of analog recording level
[Link] relative to the screen
[Link] relative to the window
NOTE: Recording the operations based on mouse movement or keyboard input .
10/26/11 Durgasoft
a) Record relative to the screen:
In record relative to the screen will record the instructions based on the screen
coordinates.
If at all window place is changing on our screen, then it will not perform action recorded.
This will records on multiple windows on our screen

When you record in Analog Recording mode relative to the screen, the script will fail if
your screen resolution or the screen location on which you recorded your analog steps
has changed from the time you recorded.

The analog recording continues to record the movement of the mouse until the mouse
reaches the Quick Test screen to turn off Analog Recording or to stop recording.

b) Record relative to the window:


It will record the instructions or script based on the window coordinates. If at all window
location is changed on our screen, it will not perform all the recorded actions.
This will records on only one window on our screen

Note: If you have selected to record in Analog Recording mode relative to a window, any
operation performed outside the specified window is not recorded while in Analog
Recording mode.

10/26/11 Durgasoft
3. Low Level Recording:
It is used for recording the script based on the actions performing on our application, but
it will recognize the control using their coordinates.
If at all object coordinates or object location is changing then it is not going to perform
the recorded action due to the change in object location.

NOTE: QTP should be in normal recording mode for switch to Analog or Low-level
Recording modes

10/26/11 Durgasoft
Check Point:
It is used for verifying the existency of all the controls.

We can insert check points only in recording mode.

Though object properties available in object repository.


Check point will store required properties into object repository.
Due to this OR size is getting increased it leads to performance issue.

Insert

Checkpoint

(standard, text, bitmap, text area, database,………..)

Output Values:
It is used for exporting the object properties and their values into data table.
We can use these properties for our future references.

insert

output values
Note: we can insert o/p values only in recording mode.
10/26/11 Durgasoft
Check point:

Properties
AUT
OR

Output value:

Datatable
AUT

10/26/11 Durgasoft
Recovery Scenarios:
It is used for handling exceptions or unexpected pop ups given by QTP or Machine.

We need to overcome all exceptions for making batch execution successful with out
having any disturbances in the middle of execution.

There are 3 types of issues we may get in real time environment.


1. QTP script issues (Object may not recognized or syntax errors)
2. Machine dependent pop-ups
3. Application issues

QTP script issues:


If we want to continue our batch execution by over coming all the QTP script issues then
we have to insert statement “on error resume next”

Note: When ever script will be giving any script issues, by using above stmt it will not show
those error pop ups while execution but maintain error descriptions in our results in QC.

Recovery Scenario:
If we want to manage or recover from remaining issues like machine dependent pop-ups,
application unexpected pop-ups then we have to use recovery scenarios by providing
recovery information for making batch execution successfull.
10/26/11 Durgasoft
Below 4 types of issues/errors can be managed by Recovery Scenarios.
1. Pop-up window
2. Object state
3. Test run error
4. Application crash
Navigation:
Resources  Recovery scenario manager
For create above any recovery scenario we have to update below 3 sections
1. Trigger event  It contains type of exception to manage
2. Recovery  It contains type of solution to overcome the exception
3. Post recovery  It contains after recovering from exception, what need to do by QTP

Creating Recovery Scenario:


[Link] recovery scenario manager window
[Link] on New Scenario
[Link] check the information, Click next
[Link] recovery scenario based on type of exception/error (From above 4)
[Link] error information
[Link] Recovery Information
[Link] post recovery information
[Link] on finish
[Link] Recovery Scenario
10/26/11 Durgasoft
Associate Recovery Scenario:
File  Settings  Recovery  Browse the RS Path
Click on Add Scenario Button
Click on Apply Button

2. Creating RS using Function Call:

[Link] empty function library


[Link] Recovery Operations  Browse to created above FL
[Link] new Function Name
[Link] Next
[Link] post recovery information
[Link] Next
[Link] Name for RS and Click Next
[Link] Finish

Updating Recovery Script in our Function in FL and associate:

[Link] above associated FL


[Link] recovery script in above created function and save.
3. Associate RS to Script.

10/26/11 Durgasoft
QTP PANES
QTP is having total 11 panes which we use for developing the effective and enhanced level of
instructions.

[Link] Pane:
It is used for writing the instructions or script by the automation engineer. This pane is
classified into 2 types:

a) Expert View: This is the place where we can enter our instructions in QTP tool and it will
allow us to perform the execution as well.
b) Keyword View: It will display all the expert view statements in the keyword form. It is
used for non-technical persons for maintaining the instructions.
It will show instructions in 4 sections, those are item, operation, value and documentation.

2. Data Table:
It is used for maintaining the test data. It will allow us to import and export data from other
sources (Excel) based on test data requirements.

3. Active Screen:
It is used for display the images of application by placing the cursor in recorded script.
It will show only for recorded script.

10/26/11 Durgasoft
4. Debug Viewer:
Debugging: It is process of resolving the script issues or errors raised while executing the
script. This pane is used for doing the debugging process.
5. Missing Resources:
The Missing Resources pane provides a list of the resources that are specified in your test
but cannot be found. Missing resources can include missing function libraries…….
6. Information Pane:
The Information pane provides a list of syntax errors in your test or function library scripts
7. Available Keywords:
It will display all the associated files to the automation engineer.
Ex: files are libraries, shared object repository, etc.,
8. Process Guidance Pane:
It is used for display QTP help on Process like keyword driven framework…..
9. Resources Pane:
QuickTest displays all the resources associated with a component in the Resources pane.
[Link] Flow:
It will display execution heirarchy in left side pane along with actions list.
11. To Do Pane:
Here we can add/store pending tasks of automation in script.
By seeing this comments, anybody can able to understand what is pending in that script.

10/26/11 Durgasoft
QTP Life Cycle:

1) Develop the basic script


2) Enhance script
recovery scenario
regular expression
Descriptive programming
environment variable
function libraries
reusable actions
shared OR
Transaction, FSO….
3) Debugging Script
4) Perform Batch Run
5) Deliver to Client

10/26/11 Durgasoft
Automation Life Cycle:
Manula TC’s

Dry Run is process used for understanding application


functionality and identify reusable components like
functions and reusable actions for repeated functionalities…

Automation Plan
Start End Hours
Phase 1 Functions 80
Resuable actions
Environments
Phase 2 Intermediate

Phase 3 High

Phase 4 Meduim

Phase 5 Low

10/26/11 Durgasoft
Automation Plan Preparation:
Before automation plan development is start, we have to gather all the manual
application flow, test scenarios and test cases from the manual testing team for that
particular application. On the basis of the collected test cases we carry out a dry
run(executing the test cases without intension of finding errors and only for
understanding functionality) in QTP to identify the complexity of the test cases. And also
we identify the re-usability, Modularity and repeatability in test cases. We categorize the
complexity of the test cases as:

•Complex
•High
•Medium
•Low

During the Dry run we update the complexity of the test cases in “Text case Complexity”
sheet.
For each complexity category we allocate certain man hours to complete test scripts.
After the Dry run is done, we calculate the overall man hours for each sprint and update
the same in “Duration” sheet.

10/26/11 Durgasoft
Once we are done with updating the duration for each sprint, we move to the
Automation Test scheduling.....
In this we allocate the no of days for different phases which for below:

[Link] phase
[Link] Execution phase
[Link] phase

In designing phase we design the automation framework for the application, In


Development Execution phase we automate the reusable actions and start preparing
and executing the each sprint test scripts. After all the sprints are covered, we deploy
the automation test suite in the client site and will give KT to the client team which will
be useful for their maintenance purpose.

10/26/11 Durgasoft
QTP Framework
The process and Folder structure what we are following for automating the manual test
cases is called framework.
Based on the application functionality, we have to choose corresponding process for
automation.

Framework Types:
Linear
Modular
Data Driven
Keyword Driven
Hybrid Framework

Linear Framework:
If at all application functionality is entirely different and there is no scope to reuse and
modularize your functionalities then we have to follow linear framework.
We cannot maintain reusability and modularity.
We can use the features:
Recovery scenario
Regular expression
FSO
Data table
Environment variables, etc., Durgasoft
10/26/11
Ex: linear 100 TC’s
…………. Sequential
………….. Stmts Different
…………………….
…………………….. No modularity, reusability

Modular Framework:
If at all application functionality is having common functionalities which are required in all
the test cases then we have to follow modular framework.
We will get advantages reusability and modularity because here we are having chance to
reuse, some part of navigations, it means we are able to modularize our script.

RA’s 100 TC’s


functions
shared OR 20 – 30 functions
EV’s 10 RA’s

10/26/11 Durgasoft
Data Driven:
If at all application is having functionalities depend on the test data and data need to
drive our script execution then we have to use data driven framework.
Along with this process we can use components functions, reusable actions, shared OR.

functions 100 TC’s


RA’s 80 TC’s common
EV’s data table
shared OR

Keyword Framework:
If at all application is having functionality mostly common and we need to check
application functionality by doing small actions in our application, then we have to use
keyword driven framework.
For all the common functionalities we are maintaining keywords in our library and
update keywords and their required objects details in data table.
By using above keyword and data table, we are fetching each record and performing
the keyword call by using datatable arguments.
From where we are calling keywords and fetching keywords, we can say it as a driver
script.

10/26/11 Durgasoft
Function Library
Driver Script
Function login
Select case keyword
-------
Case 1
---------
CALL FUNCTION….
End function
Case 2
CALL FUNCTION….
Function ………….
Case 3
Select case
CASE FUNCTION……
“winedit”
……………..
…………..
“winbutton” Data table(Test Data)
-------------
----------- Keyword Micpass Object Value
“windropdown”
-------------- Login
End function Click
Set

10/26/11 Durgasoft
Hybrid Framework:
Combination of any of 2 frameworks is called hybrid framework.
In real time we used to work with at least 2 frameworks such as modular and data driven
or Data Driven and keyword driven.

10/26/11 Durgasoft

You might also like