Professional Documents
Culture Documents
twdt;7~s~
r:
I'!
\j
Course Material
'1.1
I .
.,
'
,.
'
i-
.~r'L___
j::,_
~
[
1. _
~-----
i:
g___
l;
\l
t!;
I~
r-~
~~
~~===
~ r -
.~ r -
Ib:
Live Tech
Since 2004, LiveTech is involved in training on Software Testing Tools Projects for over 8
years. It was established with a motive to promote software testing practice and competency by
providing training to aspirants seeking career in software testing. It is the first Institute of its kind
that started Project Testing in Hyderabad. Since 2004 LiveTech has successfully skilled 50000+
professionals in Software Testing.
i
I
'f--
LiveTech is a leader in creating not only skilled professionals but also enhance their
employability through real time project implementation training in Software Testing. The
programs are designed by industry experts and backed by certifications recognized globally.
Module 1:
Module 2:
Module 3:
Module 4:
Module 2:
Real Time Manual Testing (Test Design)
1.
Project Management Plan
2.
Requirement Specifications
3.
Test Plan
4.
Test Scenarios
5.
Test Cases
6.
Checklist for; Web application testing
Page 1 of 118
,-.-
L-
~LiveTech
6!'tfyttstiiJOS<JfBri<>DJ
'""'
L
I
J
r
I
~
~
~
~
~~
"~
__
...
l.i
~1
";
Page 2 of 118
1. Tool Evaluation
2.
3.
4.
5.
6.
-Stage 1
-Stage 2
I
-Stage 3
;_:.._
,-.-
,-,-
Page 3 of 118
a .
~
fi
For developing Automation Scripts and framework we need to know below Concepts:
I. Retesting and Regression testing
2. Test Automation fundamentals
3. Automation Testing Tools
4. Recording and Run modes
5. Object Oriented Programming
> Object Repository
- (Folder I)
6. Descriptive Programming
7. Synchronization
8. VB Script
> Conditional Statements
> Built-In functions
-(Folder 2)
> User defined functions
> QTP Sample Script with Template
9. Data Driven Testing- Parameterization
-(Folder 3)
I. Data Table
-(Folder 4)
2. Environment
3. Random Number
4. Data base
5. Text files
6. Excel files
I 0. Actions
11. Checkpoints
12. Recovery Scenarios
-(Folder 5)
13. QuickTest Script Editor
14. Test Batch Runner
15. Automation Object Model (AOM)
-(Folder 6)
16. Web Programming (Web Scripts Development)
-(Folder 7)
17. Test Results and Test Log
-(Folder 8)
18. Automation Frameworks Implementation
I. Linear Framework
2. Modular Framework
3. Data Driven Framework
4. Keyword Driven Framework
5. Hybrid Framework
19. HP Quality Center- Test Management
1. Site Administrator Job
2. Quality Center Users Job
1--
,,
-~-
.,
51 ~~:a e-t:P~~e
D Environment
f!Jl Library
~::;;3 Recovery
~ Repository
~3 Test Dat-3
ell TestLoQ .
20. Others
~Test.Run
tes~ script:
fi:i:ll
-"- -
Page 4 of 118
.* Livelech
Ij
l
II
1
I
A standalone Test Environment, including a Test Database, such that the test cases are
able to be repeated each time there are modifications made to the application.
If your current testing process does not include the above points, you are never going to be able
to make any Effective use of an automated test tool.
> The real use and purpose of automated test tools is to automate regression testing.
> This means that you must have or must develop a database of detailed test cases that are
repeatable, and this suite of tests is run every time there is a change to the application to
ensure that the change does not produce unintended consequences (errors).
r An "automated test script" is a program.
> Automated Script development, to be effective, must be subject to the same rules and
standards that are applied to software development.
'r An "automated test Suite" is a database of all detailed Automation Test Cases.
\Vhy we go for Automation?
Probfems in Manual Testing
,- No Reusability
,- More Resources required
> Time con~uming
;.- Budget is high
> Human Errors causes poor quality
> Simultaneous actions are not possible (Parallel)
\Vhat is Automation Testing?
~---
r Tes1ing an application with third Party Software help or Automation Tool is called
>
Automation Testing.
(or)
Comerting manual Test cases into Automation Scripts (in form of code) is called
Automation Testing.
Page 5 of 118
----
--
J--
Tool Evaluation
In my current project, Automation tool is evaluated based on below project features:
1. Multiple Browser Support
2. Java applications support
3. Ease ofUse
4. Multiple Operating Systems
5. Ajax support
6. Web Applications support
7. UI Tests
8. Scripting
9. Record and Play back
10. Object recognition capability
11. Data driven testing
12. Customization of recorded code as per our requirements
13. Synchronization issues
.14. Test suite creation
15. Ivlaintenance of scripts when features modified
16. Central Object Repository
17. APls availability
18. Database verification
19. Vend or support
20. Frameworks Creation
21. Tool Performance
r--
Based on initial evaluation on above Project scenarios, the above information is captured.
QTP and Selenium tools are finalized after evaluation other tools from both commercial and
open source.
Client/Management is finalized QTP Tool to automate my Current Project.
Page 6 of 118
'
~-
~
w
Introduction to HP QTP
~
~
~
~
~
Inserting checkpoints
Page? ofll8
i~-
-* liveTech
QTP - Licenses
Two types oflicenses
1. Seat License
-Single User
2. Concurrent License -Multiple Users
1. Seat License
A permanent seat license that is specific to the computer on which it is installed.
2. Concurrent License
A network-based concurrent license that can be used by multiple QuickTest users.
Add-in Manager
Default Add-ins
ActiveX
Visual Basic
Web
Available Add-ins
Java
.Net
SAP
etc: ..
Title bar
Menu bar
Toolbars
Document
tabs
Test Flow
pane
~<eyv~ord
View
Expert
View tab
Data Table - - - ; ! - - - - - - - - -
._-_
Page 8 of 118
r--
Ig-
il
~-------
1
i
Browser("Google").Page("Google").WebEdit("q").Set "Venkat"
"""'
;;;:iiii::-&rJi.i'
fC:;;;:;;:c-:
,c~l,;~~~,~s{~~fi:~;ttb~tfii~~ki%;0f:'(t;;;~~~s~2.rfi.~> 11:;;&r:+tii10\i?1'l'z.it1HA~~~1~!l~~;t~~~J:~t'11'%0frL~';ii.%it.'011~~; .
f+ii!~~F:;;;~:;~~~~$~1[~~;::::Ejil~::a~
i~Wl/g:~~]tl~~*~ii,;iiif~~~"@.-~.:~.'fF.jfki~.:~w&t~*4t~w;~;t~"R~f~Ji~ltitm"~J::~~(i~
:T>tpemicT~inlhe''Mask.EdBox"ActiveXobiecl
:rnicT.o:b
jType
1~?S:Jt~Jt~~tt"f:1{~i,i~~;;;&1f~\,,~,_;<-A~tw;rt~~-t:t:~--::~;,!~:~~~f~~~::!~:t~~~,:~~~~~:~\~~.1li~~tis
)Select
;t.osAngeSes"
-~-~~:1-~>:~:tt~i~ltt~~:~:~::r~~ftfit~~~4t:r -~i',~\~~+lm~;~~-~-~i~l&~ift~~:tt~=~-~~~1/i~ttqf;tv;~}:r~m~~-?&l~JB::\:
Click
; Set
:"mefcu-y"
<.'r}~-::mt1fl~(~{tf-~:~f:;~}1S~;~J}?.k~i'i
Chck
'
:;-
Page 9 of 118
~=--===-=
,
--- -
5. Data Table
} It is used to store the data and parameterize that data to the test script
} There are two Sheets by default. They are
(1) Global
(2) Action!
} In one data table we will have 256 Sheets. Out of 256 sheets, one sheet is Global and
remaining 255 sheets are Action Sheets
} Global Sheet related to all the tests.
} . Action Sheet related to co~-~~p()pdin,.g; Acti()n OD,:ly~
:,,
; i;
t----
6. Active Screen
Provides a snapshot of your application as it appeare~ when you performed a certain step during
the recording session.
Advantages:
} Easy to insert Check Points I Output values.
} Easy to add objects to all object repository.
} Easy to insert steps.
} Easy to understand script by observing images in active screen area.
7. Debug Viewer
} It is used for viewing, modifying or setting the current values of variables or objects during
Test execution break with the help of three tabs--- Watch, Variables and Command
8. Missing Resources Pane
} Whenever we open a test, the files which are associated with that test are missed I moved then
Missing Resources Pane will be opened automatically and displays the information about that
missed file.
} The Missing Resources pane may list any of the following types of missing resources:
Missing Action Name
~vfissing Object Repository
. Repository Parameters
Missing Environment Variable
Missing Library
~---
:=----=--:----
Page 10 of 118
'-
>>>-
~----
Object:
>-
3. Events
> These are what can be done to an object. This is used by programmers to determine what an
object does in response to an action you perform. It is however unused in QTP.
Window I Obiect
Class/Script
Main Window
Window("Window Name")
Sub Window
S.No
3
4
5
6
WinEdit("EditBox Name")
ro.
vOffib 0 B OX
:3:
jcombol
, ...............
.
. Menu
Radio Button " ~;~ Button
WinComboBox("ComboBox Name")
WinMenu("Menu")
WinRadioButton("Radio Button Name")
WinButton("Button Name")
E-
Page 11 of 118
'
~
~
S.No
Class/Script
!Browser
Browser("Browser Name")
Page
Frame
Frame("Frame Name")
wink
Link("Link Name")
~dit Box
WebEdit("EditBox Name")
!List Box
Menu
WebMenu("Menu")
Radio Button
9
10
CheckBox
Button
WebButton("Button Name")
Script
Operations
!Active Window
.Activate
.Set "Text"
.Set
.Set "On/Off'
.Click
.Close
10
.Closealltabs
1. Windows Based
In which window.On what object.What operation is done.
Syntax:
Window("Window_Name").Object("Object_Name").Operation/Method.
2. WebBased
In which browser.in which page.on what object.what operntion is done. (or)
In which browser.in wl">..ich page.in w}ljch frame.on what 0bject.what operation is done.
Syntax:
Browser("Browser_Name").Page("Page_Name").Object( object_Name"). Operation/Method.
r----
Page 12 of 118
Q-.-
~
~
I==
E
Sample scripts for windows application
Test Scenario 1:
1. Activate window
,
. ,
2 Enter Agent Name as' admm1
Enter Password as "mercury"
Click on
, I
3:
Script
~-
-15'ialog("Login").Actlvate
,
. ,
Dialo "Login").WinEdit("Agent Name:").~;t adllli?, 1
D ..I g(("Login").WinEdit("Password:").Set mercury
Ia og
"OK") .Cl"lC k
Dialog("Login").WmButton(
Test Scenario 2:
1 Activate window
,
2. Enter Employee Name as "Appa Rao
3. Select Employee No. as EOOI
4: Enter Employee Salary as 10000
5. Click on [Submit]
.E~fl~-:~~:m.,,,
;=~rl
_
1;. ...:..=':,.-_. "'-__.___
><>
>
.s~_i'j'>
Script:
'
w;~do
( "
te.,r l~ee.
tv'h bw
') . AcJi'vote..
"
J ..s-et
1--.-
Page 13 of 118
Test Scenario 3:
I. Activate Window.
2. Enter Patient Name as "Abc"
3. Select Ward No. as "I7"
. ,
4. Select Referral Doctor as "Dr.Armth
s. Select Cough Radio Button ON
6. Bill Check Box ON
7. Click on [Ok]
8. Enter X-Ray cost as "200"
9. Enter Blood Test as "300"
I o. Enter Bed Bill as "500"
Il. Click on
...!
'
X-Ray.
Blood Test
BedBill:
'
'
''
I
Ok
Test Scenario 4:
it--
'
Click on [Ok]
Script:
u;nd.,._, ( '' Ml mp t
E-
').
D,'a.J.~J ( "
:=-------=--=-----
Page 14 of 11 8
r---
L__
~. l-JVeTech
fil'tryUslilgs.kti.Ja
Script:
s~ s~ cth' I ~4_)}
\\
,exp lure~
HUVJCUJ
!I
http: II
(,\JWW.
Lt o- ftC .
, /
(0'
R-e.> un e
I/'
h 'IY)S
li vo. "
iJ
l1a.t <>m:t
,,
t"/
,,
,,
J;
. ~I?Lt+-kn (1'
LV<[l'n
11J.
~c_l_c__
i'J. ~cl-' 1
~I',
I)
ut...k._ (_ l L LC[J
CLt
I )
Test Scenario~: , .
f d . Login of current Project.
Verify Functionality o a mm
I. O~Y)
.2.
EfZPP'r0(_ +1-pp/.t'co.h'Cir) .
EWe.v CLtS+arrer
3 t'c.Jev fb$~Yd
4 clJcK
5
0!
U.serOV
tt
08
11
Pmc u
Pft1c 11
[ S\.t br..J t]
clic.l 0! , 1 G:L1
-6 Sa.fe.d-
t:J pe_
oo
~ cJ..iu..
CYJ
Cstt!:A.ti:J
S c)_; c1<_
<11')
~ c.uJ
1 .
If'J!::J
~--
l.\S0Jel
pa..s.su..l:ll:l
SllbN'.t-
=
L---
L_
~ tivez,a.nl!~
sus+enJtth I
\\ exp lure~
I<Mh
ll
:...:!
. ~GOo I Er<.p
I_;
f \. f" fYJC ,3 0
t')
h(o ' )
::J
I)
'
''
t1b.i Br 1. F rcuv.-e (
i \
tr
11
S<.tl?rw't
C ru..~,c_
C.. Oe;_~'(s
.)'
PMc''
11
c_)_,'cl:_
;J rLJ ~<- (
lt
~cL.~ prCJlJ<'fe
~b~ s r l
'j
''
p~
{j . JJ'cJ.r;,__
'0 .
Lc.._t_ (
1'
L'ZJ
CJLtT
t:).
of. f.,(e
'I
d<&._
'i:: i!'
!: .
i
Test Scenario 3:
Verify Google Search.
Sl:J ,s.~ U
fi I iluY)
11
'
B-vo.;.\S 0- (_ n
bra..u.Je'fC 1 ~a~Jff
'
1---eAc~
) s~
t....!E.b e-ch't l 1'q; /)J.
J) (J~tl
1
11
fa
11 _).
Lue.IE'ch- G_ac(jte
L ,_{!_
T-e cJ,
c t.r
\I
!Jec-v~
cJ o J le
1
1
)
tr
Li ve._-,e-L.VJn t'.I
r
- b '_ J~
.s-e.a.~J... El}
/ GU
<...J'.......
D.u./c_
8---1'
c l0 7l' Afl ~~
'
to...
~ -
Page16of118
18
~liveTech
Fivtly tulillll soflrtioos
Object Identification
How QTP learns objects in application?
Stores Object as Test Object, Determining the class it fits.
1. Mandatory properties
2. Assistive properties
3. Ordinal identifier
4. Smart Identification
1. Mandatory properties:
While recording, for each test object class, QTP learns a list of mandatory properties to Uniquely
identify the object.
2. Assistive properties:
If not sufficient, QTP adds assistive properties until is has compiled a unique description.
3. Ordinal identifier:
If no assistive properties are available or if not sufficient, QTP adds a special an ordinal
identifier types as index, location and creation time of the objects are used to create a unique
identification
'
4. Smart Identification:
If Quick Test is unable to find any object that matches the learned object description, or if it
finds more than one object that fits the description, then Quick Test ignores the learned
description, and uses the smart identification mechanism to try to identify the object.
A Smart Identification definition can help QuickTest identify an object, if it is present, even
when the recorded description fails due to changes in one or more property values
rr- -
Identification
I
f
'-.~
q
'
-c---li
[i
Page 17 ofll8
~llvelech
fivtfy W/iofl
..fiiiWos
Types of Objects
There are two types of object
Test Object:
}- Objects in Object Repository are Test Objects.
}- Test Objects are helps to QTP to identify and check the object during the run session.
Run-Time Objects:
}- Objects which are in Script are Run-Time Objects.
}- It is the actual object in your web site or application on which methods are performed
during the run session.
Object Repository
::
Navigation:
Name:
i(iii;i Agent Name:
:''
: mm Pa~sword:
Class:
Dialog
Repository:
1.-L-oca-.-,---------,_...;..;......._--.,_
fr
Comment
Page 18 of 118
t-r:
modify them as needed. You can open shared object repositories both from the file system.
,
Navigation:
Go to Resources Menu -7 Object Repository Manager
.. ~
1-
Nome
~~)i;j~j;\'~~"'@)-~j~~f:t~~i
nt~tivecloss
: SysListView32
Type.Vl!lue
;None
~,t~1~jj!~ti:~ ,:~~'.;~\Jit-~,G~tJ;~~41g;:~J;~~1t{t%~.
;:lM~~)~~~s ', ./~;,:J:(:~~b; ~;:~~;~:' :J,h:;;:')l~%-~i$:1~1
Enoble
Smorlldentificot...:~--
-..
Comment
:~
,-~,_;
Page 19 of118
f--
,~--
(Or)
Second Best Method:
l. Object Repository creation for Project - while navigating to Object Repository and Add
Objects to Local
2. Export these repository into Local folder (Project\Object Repository)
3. Write manual scripts for Current project
4. Associate Repository to all Scripts, while navigating to Resources Menu and click on
associate repositories and add Repository
5. Run the scripts and observe results (All scripts are used single repository)
Page 20 of 118
~
f;
~liveTech
Object Spy
1. It is used to view object properties and Operations.
2. Displays
);>
);>
Operations
Native Operations (Run Time Operations)
Test object Operations
Navigation: Tools -7 Ob'ect
);>
t~
test objec1
hierarchy tree
object proper1ies
selected prop.arty,
or operation
lOrt
18
Page 21 of118
Mr.Venkat (Sr. Test Manager)
~--~
1. Start Recording
}
2. Learn Object (Storing object in Object Repository)
3. Script Generation
4. Catch Entry in Object Repository
(Object Properties in Object Repository)
(match the properties in AUT)
5. Identify Object in AUT
During Recording
During RUN
I
I
Navigation:
1. Resources~ Open. Object Repository~ Click on Add Object Icon~ Show Object with
Hand Icon ~ Click on [Ok]
2. Select Option [Select Object Only, Default Object Types, All Object Types, Selected Object
Types] . .
3. Click ori [OK]
4. Export these repository to Local Framework Folder
What is the extension ofthe Shared Repository?
.tsr (Test Shared Repository)
- - Ii
_~:_
11
r-;
Page 22 of 118
r)
It takes lot of time for identifying the object, when the object is changing dynamically during Run
time.
If the object Repository size increase then the execution speed will be decrease.
Descriptive Programming
Definition
~
~
~
1
Jject
I
.,,_
If we specify description of the object in the program it self that can be called as Descriptive
Programming.
Using Descriptive Programming we can execute test script without objects in Object Repository.
We can execute the test script without Object Repository.
I
I
Advantages:
~
~
~
Fast execution.
Easy to identify the objects.
We can prepare Script without having build.
Disadvantages:
~
""
It takes lot of time to design test Script -Time consuming for test script design
1. Specifving the properties and its values directly in the statement (script)
Syntax I Code:
Browser ("PJ :=Value", "P2:=Value", .... ). Poge ("P1:=Value", "P2:=Value", .... ).Object.
("P1 :=Value". "P2:=Value", .... ).Operation I Method.
Example 1:
Prepare descriptive Programming for "Logir;t" Operation in Flight
Reservation
SystemUtil.Run "C:\Program Files\HP\QuickTest
Professiona1\samp1es\flight\app\tlight4a.exe"
. Di<llog("text:=Login").\VinEdit("attached text:=Agent Name:").Set "Venkat"
Dialog("text:=Login").\VinEdit("attached text:=Password:").Set "mercury"
Dialog("text:=Login").WinButton("text:=OK").Click
:11
Window("text:=Flight Reservation").Close
Example 2:
Prepare descriptive Programming for "admin login" Operation of project.
,-,-
ory
~an
118
Page 23 of 118
=
~~-
r .
f
nn
Example 3:
'Prepare Descriptive Programming for Google Search
Bravser (''
~cu-o< : "
BrwJ.sec('' ))c..,e;
"
I{ CkJ,Jie
1';, DdsJe
:)
0eb
ll
L'Cte
:>c
l'eL~-J,
2. Description Object
To create Description Object we can follow below syntax.
Syntax I Code:
Set Object Name== Description.Create
Object Name ("Property Name"). Value= "Property Value"
Example 1:
~liveTech
Example 2: Using description object, prepare descriptive Programming for "admin Login"
Operation of current project.
S 9!-
s.V:. r~
CX2.SC"I;ph{ly) . cr-fbJe.
bfO .:::=
::
0e3Cn'p-h'~ . c~
sci
Or)Q :::
sci-
pwd. -=
,.
D<ZSGrlpJ-ic() C'rWk
fy2,5Cn-plit?J. ~reJe.
V-
:sel-
bmAc:K
I])J
Ad:L
( ( lr) c.JY) e_
(/
ll
.)
ll
'h::vr'x:
iJ
I0C.u
p /'Y) (_ L/
Nebhll#-cr] (_ ~t)
Lild:...
li(LS~d. If
brol ttdd
l \ Y)GVnt' If
/
t\Ne_w ~
' I(
Example 3:Prepare Descriptive Programming for Google Search Using Description Object
Run Modes
Two Run modes
1. Nonnal- We can set timeout
2. Fast
Tools -> 0 ions -> Run
:-::
.c'
Genf!u.,l
T eMt A ecognilion
Folder$
Active S croen
li!IID
:-;
~eb
P.,g~/Ftcrn.,.
Run
Run modo
r-.
:.
Screen Capl....,re
Windo.....,s Applrc~crns
:
Adv.enced
i;
"
I'
.-,-
-----------------------,
1-
miKiseconds
Fest
---- ....
Options
Advonced
Jctrl .. Alt
F5
Page 25 of 11 8
w - --
~- -
.*liveTech
!it-tlj Jtsling so{JJIJ~)D$
Synchronization
>-
>
When you run tests, your application may not always respond with the same speed.
For example, it might take a few seconds:
'
For a progress bar to reach I 00%.
For a status message to appear.
For a button to become enabled.
For a window or POP UP message to open.
You can handle these anticipated timing problems by synchronizing your test to ensure thn
QuickTest waits until your application is ready before performing a certain step.
I
' ''
1. Synchronization Point
>
Instructs Quick Test to stop the test until the object property achieves the value you specify
(or until a specified timeout is exceeded).
> We can use this option to give waiting time to the tool based on specific object property
value.
Syntax:
Window("Window Name").Object("Object Name").WaitProperty "Property Name'', "Property
Value", Timeout in Milliseconds.
Web Application
> Browser ("Home Page").Page ("Home Page").WebButton("Submit"). WaitPrope11y
"visible", true, I 0000
Navigation:
1. Place the cursor in your required place of test script
2. Click on Start recording
3. Go to Insert Menu and click on Synchronization Point
4. Show object with Hand Icon and Click [Ok]
5. Select property Name (Enable) and Enter Property Value (True)
6. Set timeout in Milliseconds, Click [Ok] and Stop Recording.
Note:
1 Second= 1000 Milliseconds
~ While recording select Insert> Synchronization Point
S~lecting
the object
-~-
I~
Page 26 of 11 8
that
3. Increase timeout
);;>
>
);;>
The amount of time QuickTest waits for objects to appear or for a browser to navigate to a
specified page is insufficient, we can increase the default amount of time that QuickTest
waits for a Web page to load.
QTP maintain "20" Seconds as default object synchronization Time out.
Default time out is not sufficient, then we will increase Timeout in settings.
Navigation:
File Menu-> Settings-> Run Tab-> Change Object Synchronization time out-> Click on [Ok].
Transactions
:ny
:,;
t[!
Ending Transactions
Choose Insert > End Transaction
i: , -,_~----
Page 27 of 118
--------
--'1
..
~LiveTech
N'tfJ
IUiilrJI schtiau
VB Script
Purpose
When the tools provided by QTP are not sufficient to test an application, VBScript coding can b':
used.
~ VBScript was created as a web programming language by Microsoft and licensed by many companic;i
for use in their tools.
I. Checkpoints
-Check
2. Synchronization points
-Wait
3. Output values
- Retrieve information
4. Parameterization
- Data configuration
5. VBScript
-Adds programmable logic (For verifying Expected Result)
Last
option
Very powerful
What is VBScript?
~ It is a scripting language
~ It is a lightweight programming language
~ It is a light version of Microsoft's programming language Visual Basic
Diff b/w Programming and Scripting:
Programming
Scripting
~) SelfExecutable
2) Requires a Host
3) Compiled or Interpreted
3) Interpreted
!4) Complex
!4) Easy
Pnge 28 of 118
'~
~liveTech
firefy ltshnflSll{llti<'US
:an be
Declaring Variables
);> Variables can be declared by using Dim (or) Public (or) Private Statements.
);> Dim Statement - available to all procedures within the script.
);> Public Statement -available to all procedures in all scripts.
);> Private Statement - available only to the script in which they are declared.
'anies
e_ ______ _
-1
r.
i1
,-,::
VBSc'ript Constants
: ;. . Constants in VBScript can be created using the Const statement.
> Declares constants for use in place of literal values.
Example
Canst MyString = "This is my string."
Canst MyAge = 49
,_,1_
Array Variables
> Assign More than one value to a single variable. Can create a variable that can contain a series of
values called an array variable.
.-"
Page 29 of 118
f ---
'
:i
Description
Addition
Subtraction
String concatenation
Multiplication
Division
Exponentiation
Comparison Operators
Description
Equality
Inequality
Less than
Greater than
Less than or equal to
Greater than or equal to
Logical Operators
Description
Logical negation
Logical conjunction
Logical disjunction
Symbol
+
&
1\
Symbol
=
<>
<
>
<=
>=
Symbol
Not
And
Or
VBScript Input
InputBoxO:
It displays a dialog box containing a label, text box for entering data, (OK] and [Cancel]
Ex: a= lnputBox ("Enter the value")
Page 30 of 118
~liveTech
m'tfy
ltslifl wt.ti...
VBScript Output
MsgBoxO: It displays a dialog box containing a message and buttons.
Ex: MsgBox ("This is the value")
dim name
name= "John"
box" value of the variable name:" &name
[Jiiiii!!!ii!--
Conditional Statements
1. If Statement
~ If...Then ... Else statement
~ If...Then ... Eise If statement
~ Nested If statement
2. For...Next
~ For To ... Next
~ For each ... Next
3. While
~ While ... Wend
~ Do - Loop ... While
~ Do- Loop ... Until
4. Select Case statement
1. If Statement
You should use the if ... then .. Else .. Statement if you want to
~ Execute some code if a condition is true
~ Select one of two blocks of code to execute
Ex:
l.l
ELSE
statements
-:~-
END IF
:J=-:~-
Ex:
i = InputBox ("Enter the value")
ifi < 10 then
MsgBox ("Good morning!")
else
MsgBox ("Have a nice day!")
end if
Page 31 of 118
IF Condition] THEN
statements
ELSEIF Condition2 THEN
statements
ELSE
statements
ENDIF
ENDIF
1.3 Nested If statement
..
IF Condition! THEN
IF Condition2 THEN
statements
else
statements
ENDIF
ENDIF
'
Ex:
i = InputBox("Enter the value")
ifi < 20 then
ifi < 10 then
MsgBox("Good morning!")
else
MsgBox ("Have a nice day!")
end if
end if
2. For ...Next
Uses a counter to run statements a specified number of times.
Repeats a group of statements a specified number of times.
2.1 For To ... Next
For counter= start To end [Step step}
[statements]
Next
,
__u,_ _
Ex 1:
Tota/=0
For i=O to 5 step 1
Total =total+]
riJ
";
Next
-~-
Next
I
Page 32 of 118
Ex:
dim names(2)
names(O) ="Testing"
names(l) ="Java"
names(2) = "J2EE"
for each i in names
MsgBox(i)
next
3.Wbile
);>
);>
Wend
Ex:
i=l
While i < 5
MsgBox(i)
i=i+ 1
Wend
Syntax:
Do
statement
Ex:
i=l
Do
MsgBox(i)
i=i+l
Loop While i < 5
Ex:
i=l
Do
MsgBox(i)
i=i+l
Loop Until i = 5
.-8
Page 33 of 118
END SELECT
Ex:
I:
!:
-''-
Page 34 of 118
:;,_
[___
t_ _
~
.* liveTech
fiNfyltstinO"'{Juim
(1)
II
II
Left
We can use this function to get a specified number of characters from the left side of a string.
Syntax: left (String, number)
Ex: x="sairam"
msgbox left(x,3)
2. Right
~
.
We can use this function to get a specified number of characters from the right side of a string.
\r
IC_,;~.... JI"
3.Len
We can use this function to find length of a string
Syntax: len (String)
Ex: x="sairam" msgbox len(x)
4.Mid
We can use this function to get a specified number of characters from the given string.
Syntax:
r:J_-j_
-----
'
5. LTrim
We can use this function to remove spaces from the left side of a string.
Syntax:
Ex: x="
msgbox ltrim(x)
ltrim (String)
Sai"
6. RTrim
We can use this :function to remove spaces from the right side of a string.
Syntax:
rtrim (String)
Ex: x="Sai
"
msgbox rtrim(x)
7. Trim
We can use this function to remove spaces from both the sides of a string.
Syntax:
trim (String)
Ex: x=" Sai
"
msgbox trim(x)
Page 35 of 118
18
~tlveTech
litfy
Us~Ult! scfuh'ons
8. UCase
~...
'..
We can use this function to convert Lower Case into Upper Case
Syntax:
ucase (String)
Ex: x="sairam" msgbox ucase(x)
.
.....
. .
... .
5AlR""'
.. .............. .. .
.
...
't lc&""":j
. 'HC'"':'tttf:k ._"
9. LCase
We can use this function to convert Upper Case into Lower Case
Syntax:
lease (String)
Ex: x="SAIRAM"
msgbox lcase(x)
10. Strreverse
We can use this function to reverse the string.
Syntax:
strreverse (String)
Ex: x="SAIRAM"
msgbox strreverse(x)
:I
11. Strcomp
We can use this function to compare two strings
Syntax:
strcomp (String}, String2, Compare)
0
Binary Comparison
Ex:
x=''SAIRAM''
. i
. !
Y="sairam"
If strcomp(x,y,O)=O then
lr--oic""-~t
. . . -r~r----
~
F
;-
Page 36 of 118
F-
15. Split
It is used to return "0" Zero Based one dimensional array containing a specified no. of substrings.
Syntax: Split (expression, delimiter)
Ex: s="lndia is a great country"
India
msgbox arr(l)
msgbox arr(2)
is
msgbox arr(3)
great
= country
Msgbox arr(4)
16. Join
It is used to return a string created by joining a specified no. of substrings contained in an array.
Syntax: join (list, delimiter)
Ex: s="India is a great country"
arr=split(s, " ")
msgbox arr(O)
msgbox arr(l)
India
lS
msgbox arr(2)
msgbox arr(3)
great
msgbox arr(4)
country
msgboxjoin(arr," ")
Note
How to add two variables values.
a="Sai"
b="Ram"
msgbox a&space(lO)&b
17. Space
It is used to create a specific No of spaces
Syntax: space (Number)
18.Rem
It is used to insert comment.
Syntax: rem statement
19. Date
It is used to return current system date.
Syntax: msgbox date
11}9}2008
20. Time
It is used to return cirrrent system time.
Syntax: msgbox time
,.-;-
! tf9tzooa tt:1t:~ AM
21. Now
Syntax: msgbox now
~~tax::~~~~:=~yname(weekday(
18
date))
'!
~~=~
Page 37 of 118
Procedures
VB Script has two kinds of procedures
1. Functions (Function Procedure)
2. Procedure (Sub Procedure)
1. Function Procedures:
Perform action & Returns the outputNalue
Syntax:
Function function name()
statements
function name = a+b
End function
Function returns the value with function name.
2. Sub Procedures:
Perform action & doesn't return the output/Value
Syntax:
public sub procedure_name( arguments)
statemets
End sub
Function LRbra:ry
II
>
>
>
I
i
Page 38
of 118
_r:_
.-~:
~liveTech
fi<tfyiiSiillflu>Wti.. s
Navigation:
1. File Menu -7 Settings
Click Ok.
(Or)
2. How to associate library file during Runtime
Syntax: execute file "Path of file"
Example 1:
Public Function addition (x,y)
z=x+y
addition == z
End Function
Save as .vbs file in Notepad and Associate this to Function library.
'*********************************************************************************
'Calling the above function in Script
a=lO
b=20
c=addition (a,b)
msgbox c
Example 2:
Public Function Login (Usemame, Password)
IS'
for
Save ~;ts .vbs file in Notepad and Associate this to Function library.
'*********************************************************************************
'Calling the above function in Script
Result==Login("Venkat","mercury")
11
msgbox Result
r;
o-.-
to the!~
~
![
!
'
I
I
118
Page39of118
~liveTech
lktfyltslillfiS<16tti<J
QTPMethods
In QTP mainly we used below methods to automate web application
1. GetVisibleText
2. GetROProperty
3. GetTOProperty
4. GetltemsCoW1t
5. Getltem
6. GetContent
1. GetVisibleText
We can use this method to capture visible text.
Code:
Variable=Window("Window Name").Obj ect("Object Name").GetVisibleText()
2. GetROProperty
>- We can use this method to capture run time property value into variables.
>- We can use this methud to. capture object property "from the application"
Code:
Variable= Browser("Browser Name").Page("Page Name").Object("Object Name").GetROProperty
("Property Name")
3. GetTOProperty
>- We can use this method to capture text object value into variable. Or
>- We can use this method to capture object property value from the object Repository.
Code
Variable = Browser(''Browser Name").Page("Page Name"). Object("Object Name"). GetTOProperty
("Property Name")
Difference between GctVisibleText and GetROProperty:
"' GetVisibletext enables to capture the static text displayed in the specified area.
~
GetROproperty will retrieve the dynamically changing text during run-time.
4. GetitemsCount
We can use this method to count number of items in the Combo box/List Box.
5. Getltem
We can use this method to get a specified item from the Combo Box
6. GetContent
We can use this method to get content of the Combo Box.
!
i
f
r
I;
II
Page 40 of 1i8
.*liveTech
- ..... ?.
2. Print
It is used to display your specified message in Quick Test Print log.
Syntax:
Print "Message"
3. Msgbox
It is used to display specified message in Dialog box
Syntax:
msgbox (''Enter the value")
Ex:
a=lO
b=20
If b=a+ 10 Then
msgbox "b is equal to a"
print "b is equal to a"
reporter.ReportEvent micPass, "b is equal to a", "Test is Pass"
else
msgbox ''b is not eqaul to a"
print "b is not equal to a"
reporter.ReportEvent micFail, "b is not equal to a", "Test is fail"
End If
-~:-
I
I
I'
i
I
i
18
!J.se~
Name:
Password:
..
ophun
Cancel
toX-fL'c.'t.
0 ;/Y) shr053
DtJL:_j ( ''Lc~"''')
D'oJ~Jc ''Log10i).
D cJ.2j
Sh~
cL
lI
Adiva.i--e_
/:J;YJ-e_M
c\
n:,~ (Lea'"'}
UtSe.r
(I I
\'
If
sh "'OJ :::
\I
IJ;"hHOJ
1 v L1. e
IJ
fVC.-1/VJe
,,
LI
-f{\0..4
[ ~~ e d / u.s ev S au Kon.-<.c-1:
"'' res+
(s p~
11
,_
.. _
l.
t-
r------
Page 42 of 118 .,
L_,_
'E
QTP Script
Test Scenario 2:
Book a flight ticket and Verify the booking stored
1. Open the Login window
'************************Variable Declaration***********************************
Option Explicit
Dim strtempContent, OrdNo,OrdNo 1
'***********************Functional Scenario*************************************
' Open the Login \Vindow
System util.Run ".C:\Pro gram FiIesIHP\QuickTest Professional\sampleslfl igh t\appIflight4a. exe"
' Verify login window existence
ii - , ,
If dialog("Login").Exist Then
Reporter.ReportEvent micPass ,"Verifying the Login Dialog","Login Dialog is
displayed"
else
Reporter.ReponEvent micFail ,"Verifying the Login Dialog","Login Dialog is Not
displayed"
'2nd If
Page 43 of 118
18
;----
~
~
rr
'
-*liveTech
'
'l.
i:
firtfjttstinnsoftttic,ru
1
1
l:
,
'I
~
~
---
Page 44 of 118
..
r;- --
*liveTech
linfy wlinn ..r.h~m
1:
,.-
,-.-
~------
Page 45 of 118
'~
Test Scenario 3:
1. Enter Input 1 & Input 2 Values
2. Click on [OK]
3. Check Result
'"' MUlTIPLY
il)puJ box (
i"'{Ju~ hox (_ u
f..J:VJda.,.J (_
l\
rf\4./-1-ip!J
Sl-p
tl
fuJ.ey
[
1hpq tl
~ f nputJ. ~
r).
~~neJ...;~: ('\lr>p<ftl
rJ. s~t
tr--
)c
\I
rr
M~l+i Pt}
IV.
w;~\! ~
II ('J
k.
!J
j.
diJ.._
-Ll
\1
""-t/ h. pi_J
1) h o\e./_;f:
(_" Ce S 4. lt ':)- Ce d
t;
__
i
-
, :-
,...--
'
!f----
'
~
n
~~
-~-
,,
'
- "- -
~-
..
~~
...
>>-
Parameter types:
1. Data table
}
2. Environment variable
Standard Parameter types
3. Random number
4. Database
5. Text files
6. Excel files
1. Data table
>>>-
QTP enables you to create and run tests, which are driven by data stored in table
It is used to store the data and parameterize that data to the test script
There are two Sheets by default. (1) Global (2) Action 1
In one data table we will have 256 Sheets. Out of 256 sheets, one sheet is Global and
remaining 255 sheets are Action Sheets.
Two types ofData table
1. Design Time Data Table
2. Run Time Data Table
>
>-
I Difference between Design Time Data Table & Run Time D'1ta Table
Test
. -----.
--------n{es~------------------------
...
. -
- ............ ....
.,
:----"'""
_______ ..
"
I - ------ - - --$()\lJC~s.-
.,
rd.~s-1ii1-t1i11e-nat<1tal1le.-----
-- ---
>
>
>
When you test your application, you may want to check how it performs the same operations
with multiple sets of data.
For example,
Suppose you want to check how your application responds to ten separate sets of data. You
could record ten separate tests, each with its own set of data.
_,_
Alternatively,
>
8
You could create a data-driven test with a loop that runs ten times.
t----
Page 47 of 118
L
~
Mn
~liveTech
Parameterize a Step
~
In the Keyword View, click in the Value cell of the step and then click the parameterization
ICOn.
: JmAgentName:
-:-
,Set
IMJMI!t ...
Results
~
~
After running a test, we can view a report of major events that occurred during the test run.
If any iteration is failed report it as a defect using Quality Center 10.0 I Bugzilla 3.2.
~---
i!
I
r
We can use this method to "add" one new sheet to the run time data table.
Syntax: datatable.AddSheet ("Sheet_Name")
Ex
: datatable.AddSheet ("input")
[:;
I
!
2. Delete :
We can use this method to "delete" one specified sheet from the Run Time Data tablP.
Syntax: datatable.DeleteSheet (Sheet_ID)
Ex
: datatable.DeleteSheet (3)
3. GetSheetCount :
i
'
--
r~
lr
r--
We can use this method to count number of sheets in the run time data table.
Syntax: datatable.GetSheetCount
Ex
: msgbox datatable.GetSheetCount
iJ
~'I'
~
4. GetRowCount:
We can use this method to count number of rows in the 1st sheet of the Run tii"e data table.
r----
Page 48 of 118
L-
L___
~liveTech
finfy
sdltions
ltsfiiR
Syntax: datatable.GetRowCount
Ex
: msgbox datatable. GetRowCount
ation
un.
18
5. GetSheet:
We can use this method to return a specified sheet from the Run Time data table.
Syntax : datatable.GetSheet(SheetiD)
Ex
: msgbox datatable.GetSheet(l).GetRowCount
' I--
6. Value:
We can use this method to set or get value of cell in the specified parameter and the current row
of the Run time data table.
To get data
Syntax:
Variable= datatable.Value(Parameter_Name, Sheet_Name)
or
Variable= datatable(Parameter_Name, Sheet_Name)
To set data:
Syntax:
datatable.Value(Parameter_Name, Sheet_Name) =Value I variable
or
datatable(Parameter_Name, Sheet_Name) =Value I variable
Ex:
a=datatable.Value (1, 1)
b=datatable. Value (2, 1)
c=cint( a)+cint(b)
datatable. Value (3, 1) = c
7. SetCurrentRow
We can use this method to take a specified row as current row in the Run Time Datatable (By
default it is 1st Row of 1st Sheet)
Syntax: datatable.SetCurrentRow(Row Number)
Ex: s="sairam"
datatable.SetCurrentRow (3)
datatable. Value (1, 1) = s
8. SetNextRow
We can use this method to take the row a~er the current Row as New Current Row in the Run
time data table.
Syntax; data table. SetN extRow
Ex: s="sairam"
datatable.SetCurrentRow (3)
datatable.SetNextRow
datatable.Value (1,1) = s
9. SetPrevRow
We can use this method to take the row before the current Row as New Current Row in the Run
time data table.
Syntax: datatable.SetPrevRow
Page 49 of 118
r----..,
r---
f--
I!
r-~
f-----
r----
f[
I-
~liveTech
fU,tfyltstiiJoS<!Illti..s
Ex: s="sairam"
I
datatable.SetCurrentRow (3)
datatable.SetPrevRow
datatable.Value (1,1) = s
10. Import
We can use this method to import Microsoft Excel File to the Runtime Data Table (Including all
sheets)
Syntax: datatable.Import "Path of File"
Ex
: datatable.Import "F:\Inputdata.xls"
f
lmportSheet
!
We can use this method to import a specified sheet of Microsoft Excel Sheet to the Runtime Data
table.
Syntax : datatable.ImportSheet "Path of File", "Source Sheet", "Destination Sheet"
'
Ex
: datatable.ImportSheet "F:\Inputdata.xls",3,1
t
11. Export
[
. !
We can use this method to export a copy of Run Time Data table to another location (Including '
i
all sheets)
.1
Syntax : datatable.Export "Path of File"
{
Ex
: datatable.Export "F:\Outputdata.xls"
i
t-
l
!
~~~
We can use this method to export a copy specified sheet of Run Time Data table to the
existing or new Excel File.
Syntax: datatable.ExportSheet "Path of File", "Sheet Name I Source Sheet"
Ex
: datatable.ExportSheet "F:\Outputdata.xls", 2
I
[
l
''
Page 50 of 118
_r;_
t-ti
_,_
!=
f
f
I
(
l
f
Option Explicit
Dim RowCount, i
Datatable.AddSheet "Input"
Datatable.ImportSheet "C:\QTP_ Examples\WBMS\Frameworks\Test Data\Login.xls", 1, "Input"
-. __
~-
all
RowCount= Datatable.GetSheet("Input").GetRowCount
lata
I!
II
Datatable.SetCurrentRow(i)
l'
I
I
'
ne
f:
i
r--~
I,-,-
Next
Test Scenario2:
Conduct Data Driven Test on for Flight Reservation calculation test using Runtime Data
table.
Option Explicit
Dim RowCount,i,OrdNo,Tickets,Price,Prc,Total,Tot
'-~-
r---F.--
Datatable.AddSheet "Input"
Datatable.AddSheet "Output"
Datatable.GetSheet("Output").AddParameter "OrderNumber",""
Datatable.GetSheet("Output").AddParameter "Tickets",""
,.___ _
r-=--~~
Page 51 of 118
i---
~liveTech
fkelj lesli!1
wftin.
Datatable.GetSheet("Output").AddParameter "Price",""
Datatable. GetSheet("Output").AddParameter "Total",""
Datatable. Get~heet("Output") .AddParameter "TestResult",""
Datatable.ImportSheet "C:\QTP_Exflmples\WBMS\Frameworks\Test
Data\Input.xls","Sheetl ","Input"
RowCount= Datatable. GetSheet("Input"). GetRowCount
For i=l to RowCount Step 1
Datatable.SetCurrentRow(i)
OrdNo=Datatable.Value("OrderNumbers","Input")
Window(" Flight Reservation") .Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order... "
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No. ").Set "ON"
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set OrdNo
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
~---
II
(
~-----
Next
'Export Results to TestLog folder
Datatable.ExportSheet "C:\QTP_Examples\ WBMS\F rameworks\Test
Lo g\CalculationResult.xls", "Output"
~
~
,.
r--
Page 52 of 118
L__
t==-
II
f
I
I
Test Scenario 3:
Verify Flight Reservation Orders
Option Explicit
Dim RowCount,i,OrderNumber, OrdN o
I-
Datatable.AddSheet "Input"
Datatable.ImportSheet "C:\QTP_Examples\Test Data\Orders.xls","Input","Input"
RowCount= Datatable. GetSheet("Input "). GetRowCount
I
I
I
I
i
I
j
I
I
I
I
I
I
I
If OrdNo=OrderNumber Then
Reporter.ReportEvent micPass, "Verify Order","Test is Pass"
Datatable.Value("TestResult","Input")="Test is Pass"
else
Reporter.ReportEvent micFail, "Verify Order","Test is Fail"
Datatable.Value("TestResult","Input")="Test is Fail"
End If Next
'Export Results to "TestLog"
Datatable.ExportSheet "C:\QTP _Examples\Test Log\OrderResults.xls", "Input"
t=
r--
Test Scenario 4:
Prepare script for [Update Order] behaviour, When we open an Order [Update Order]
should be disabled. (Conduct data driven test)
Option Explicit
Dim Ro}vCount,i,OrderNumber,strMsg
Datatable.AddSheet "Input"
Datatable.ImportSheet "C:\QTP_ Examp1es\WBMS\Frarrieworks\Test Data\Orders.xls", 1,3
RowCount= Datatable. GetSheet(3 ). GetRowCount
For i=1 to RowCount Step 1
Datatab 1e. SetCurrentRow(i)
OrderNumber=Datatable.Value("OrderNumber",3)
Window("Flight Reservation").WinMenu("Menu").Select "File; Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight-Reservation").Dialog("Open Order").WinEdit("Edit").Set OrderNumber
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
Page 53 of 118
""
Datatable.Value("TestResult",3)="Test is Pass"
else
J--
Datatable.Value("TestResult",3)="Test is Fail"
End If
Next
'Export Results
Datatable.ExportSheet "C:\QTP_Examples\Frameworks\Test Log\UpdateResults.xls", 3
Test Scenario 5:
Create a script for Project Login and taking login credentials from Runtime Data table
r~---
~!--
P:1gc 54 of 118
')
~livelech
Bvtfy ustinoso6t!Wns
2. Environment Variable
II
!
'
[
'
1
f'
r
f
f
f
(
I
!
i
}
f
f
i
I
J
!
1. Built-in-variable
It represents the information about the Test and the system in which the test is running.
Ex:
1. Environment.Value ("OS") (It will display Operating System)
2. Environment.Value ("OSVersion") (It will display operating system version)
3. Environment.Value ("LocalHostName") (It will display Local Host Name)
4. Environment. Value ("Test Name") (It will display Test Name)
Click on Add(+)
~ Enter variable name and value and click on [Ok]
Retrieving variables using Keyword View:
1. Go to Keyword view and Select value configurations window
2. Select Parameter as "Environment"
3. Select Name and Value and click on [Ok]
Method 2:
1. External Variables will be present in the ".xml" file and we can associate this 'xml' file to the
test to use those variables in any action of that test.
2. To create 'xml' file with required variables we can prepare script likes as below.
3. Open Notepad ->Prepare script like as below -> Save the file with '.xml' extension.
<Environment>
<Variable>
<Name>usemame</N arne>
<Value>pmc<N alue>
<Nariable>
<Variable>
<N ame>password</N arne>
<Value>pmc<N alue>
<N ariable>
</Environment>
_:\_
Navigation:
_
1. File-> Settings-> Environment 0 Variable type (User Defined One) 0 Select 'Load variables
and Values from external file" 0 Browse and Select .xml file and click on [Ok]
(or)
2. How to associate .xml file during Runtime Syntax
Environment.LoadFromFile "Path ofXML file''
[
rr- -----:1
ati-~
"-~
--
~----
Page 55 of 118
r=-----1
~liveTech
liury ttsliiJI Sd!tW.
Test Scenario 1:
Create a script for Project Login and taking login credentials (URL, Username and
Password) from Environment variables.
1. Create an XML file with values ofURL,Username and Password.
2. Associate XML file to QTP test
Systemutil.Run Environment.Value("StrURL")
Browser("PMC Inc. ").Page("PMC Inc. ").WebEdit("Userld").Set Enviromnent. Value("Userld")
Browser("PMC Inc. ").Page("PMC lnc.").WebEdit("Password").Set Environment.Value("Password")
Browser("PMC Inc. ").Page("PMC Inc. ").WebButton("Submit").Click
Browser("PMC Inc.").CloseA11Tabs
Test Scenario 2:
Create a script for Flight Reservation Login and taking login credentials (URL, Username
and Password) from Environment variables.
XML File and Script:
3. Randon1 Number
~"-
---
:=--------
Page 56 of 118
~-
~llveTech
fwtfy
ttsli/Jg sdlili<Js
1
(
II
Syntax:
Set Objectname=CreateObject("Servemame.Classname")
Servemame = ADODB
Classes are:
1. Connection
2. Command
3. Recordset
l'
1. Connection
r
r
'[
ne~d
to
We can use this class to establish a connection to the specified database during Runtime
Syntax:
Set ObjCon = CreateObject("ADODB.Connection")
ObjCon.open "Provider-Provider Name"
Example:
MSAccess
ObjCon.open "Provider-Microsoft.Jet.OLEDB.4.0;Data Source=Path ofDatabase"
'0
)
SOL Server
ObjCon.open "Provider-sqloledb.l; Server=IP Address; uid=Usemame; pwd=xxx;
database=database name"
Oracle
ObjCon.open "Provider=oraoledb.l; Server=xxx;
useriD= U semame(scott); password=xxx( tiger)"
Note:
l
i
i
I
Note:.
To get provider Name
1. Open Notepad ~ Save empty file with .udl extension
2. Open that udl File~ Provider Tab~ Select Provider -7 Next -7 Select Database -7
Test Connection ~ Click Ok -7 Click Ok
3. Open same file in Notepad and copy Provider Name to Script
2. Command
We can use this class to execute specified DML Statements (Insert, Update, Delete) on
connected database.
Code:
Set ObjCom=createObject ("ADODB.Command")
Page 57 of 118
f--~
~
r;
ObjCom.ActiveConnection = conobj
ObjCom.CommandText = "SQL Statement"
ObjCom.Execute
3. Recordset
J
i
We can use this class to execute specified select statement on connected database and
retrieve the results.
Code:
Set ObjRS = createObject ("ADODB.recordset")
ObjRS.open "SQL Statement", conobj
4. Nothing
Noting is a keyword in VB Script, which is used to disassociate an object variable from the
actual object.
Code:
Set objectname = nothing
I
(
I
l
I
I
t-----
.~ ___
Fmu
[L _ _
-
Page 58 of 118
,.
-:
~LiveTech
ustin "''"ti""'
firtfy
Script 2:
How to set multiple records into database table by taking the data from Excel file
Option Explicit
Dim ObjCon,ObjCom, RowCount,i,Uname,Pwd
Set ObjCon=CreateObject("ADODB.Connection")
ObjCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\QTP_ Examples\WBMS\Others\SampleDB.mdb;Persist Security Info= False"
Set ObjCom=CreateObject("ADODB.Command")
Obj Com.ActiveConnection=Obj Con
Datatable.AddSheet "Input"
Datatable.ImportSheet "C:\QTP_ Examples\WBMS\Frameworks\Test
Data\Login.xls","Sheetl ","Input"
RowCount=Datatable.GetSheet("lnput").GetRowCount
For i=1 to RowCount Step 1
Datatable.SetCurrentRow(i)
Uname=Datatable.Value(" AgentN arne", "Input")
Pwd=Datatable.Value("Password","Input")
ObjCom.CommandText ="Insert into Login values("'&Uname&'","'&Pwd&"')"
ObjCom.Execute
Next
ObjCon.Close
Set QbjCom=--nothing
Set ObjCon=nothing
Script 3:
'How to get data from the dat:1b:1sc table
'
;,
:!
'"
:, :\
l :;
Option Explicit
Dim ObjCon,ObjRs,Var
Set ObjCon=CreateObject("ADODB.Conncction")
ObjCon.Open "Providcr==l\1:::osotUet.OLEDB.4.0:D:It~l
Source=C:\QTP _Examples\\VBMS\Others\SnmplcDB .mclb;Pcrsist Security Info= False"
Set ObjRs=CreateObject("ADODB.Recordset")
!!
~--
i~
j
I~
1-.-
Page 59 of 118
c.:_--=-=-='
~
In-
'
,. ....:-.-c
~ ~
Script 4:
Verify Login using data from Data base
Option Explicit
Dim ObjCon,ObjRs,Uname,Pwd
Set ObjCon=CreateObject("ADODB.Connection")
ObjCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\QTP_ Examples\WBMS\Others\SampleDB.mdb;Persist Security Info=False"
Set ObjRs=CreateObject("ADODB.Recordset")
ObjRs.Open "Select* from Login", ObjCon
ObjRs.MoveFirst
While not ObjRs.EOF
Unnme=ObjRs("Usernnmc")
Pwcl=ObjRs(" Password")
Sy~~t cmut i I. Run "C: \I; tu g1;1 ::1 Fi lcs\11 P\Ql! i ck'T'csl 11 mtession:ll\!l ight\app\!l ight4a.cxc"
Di;llog("L,;gitl").WiJ:Lclit("A:;t~'ll !'\:::11c:").Sc:t Ln:!t~ic:
Di:tlog(" l.ugin"). Wint:-:di!("P:tss\'..-oJci:") . .:.;Ll Jlwd
D i :1l ~ '!;/'' L~:_~_i 1: ").\Vi:: ~j lil :, '11( "0 K ").CI i ~.k
11.\Vindo\'.'("lTgilt l~csct\:lliun").!:xiq
Ti1C'i1
"-,;'
.;
else
Rcportcr.Rcp.~t[>-'L'lll micF:1i!,
"V c1 i l\:
L\):.;in","Tc:st is Fail".
.
i.
Page 60 of 118
"--"--
I,
I
I
I
I.-
I
~
Script 5:
I
'
L__
'~
l~
t_
~~
i'
~-
Page 61 of 118
f --
Script 6:
Oracle Example- Project Data
Option Explicit
Dim ObjCon,ObjRS
Set ObjCon=CreateObject("ADODB.Connection")
ObjCon.Open "Provider=MSDASQL.l ;Password=wbms;Persist Security Info=True;User
ID=wbms;Data Source=wbms"
Set ObjRS=CreateObject("ADODB.RecordSet")
ObjRS.Open "Select* from user_tbi",ObjCon
ObjRS.MoveFirst
While not ObjRS.EOF
msgbox ObjRS("UNAME")
ObjRS.MoveNext
Wend
ObjCon.Close
Set ObjRS=nothing
Set ObjCon=nothing
r
r-- -
i!
tL__
'
F----=-=--=--:
t__ -- -
Page 62 of 118
!'
om-
l
5. File System Object (FSO)(Text Files)
>~
r,.J,
Syntax:
1 't:
~
,j-:
To Create a folder:
'~
ObjFSO.createFolder("C:\LiveTech")
To Create a file:
ObjFSO.createTextFile("C:\LiveTech\Testing.txt")
To close the Opened file (Which we are opened for writing the Data)
objFSOl.Close
Script 1:
How to Create Folders, Files and Test Data
II
I
I
Flat File:
Some times we are conducting data driven testing depending on multiple test data from "Text" files .
To manipulate flat file content for testing we can prepare script like as below .
Set fso = createobject("Scrpiting.filesystemobject")
Set f=fso.opentextfile ("Path of text file", mode[Read-1, Write-2, Append-S])
while f.atEndOfline == false
s==f. readline
. t---
r:
............ sets
:r ,
Page 63 of 118
~-:__:____
.~.~
f ...
Wend
fclose
Script 2:
Login using Data from Text File:
'Create a text file with values of password and save into C:\
Option Explicit
Dim ObjFSO,ObjRD,User
Set ObjFSO = createobject("Scripting.filesystemobject")
Set ObjRD=ObjFSO.Opentextfile ("C:\LiveTech\Testing.txt",l)
While ObjRD.atEndOfline =false
User=ObjRD.readline
Systemutil.Run "C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login'').WinEdit("Agent Name:").Set User
Dia1og("Login").WinEdit("Password:").Set User
Dialog("Login "). WinButtofl("OK ").Click
Window("Flight Reservation").Close
Wend
ObjRD.close
Set ObjRD=nothing
Set ObjFSO=nothing
L
"
1. GetitemsCount()
2. Getltem()
3. GetContent()
r:
1. GetltemsCqunt
We can use this method to count number of items in the Combo bo:x/List Box.
2. Get!t'ml
We can use this method to get a specified item from the Combo Box
3. GetContent
We can use this method to get content of the Compo Box.
~
~
--
i_ _
~'
o:..:=.::.:
Script 3:
Example for GetltemsCount(), Getltem() and GetContent()
Option Explicit
Dim Itemscount, Item_Flyfrom,Contect-Flyfrom
Itemscount_Flyfrom=window("Flight Reservation").WinComboBox("Fly From:").GetltemsCount()
Item_Flyfrom=window("Flight Reservation").WinComboBox("Fly From:").Getltem(l)
Content_Flyfrom=window("Fl ight Reservation") .WinComboBox("Fly From:"). GetContent()
print ltemscount_Flyfrom
print ltem_Flyfrom
print Content_Flyfrom
Script 4.
How to count number of items in the Fly From Combo Box and bow to display their name one by
one.
Option Explicit
Dim ltemCount,i,ItemVal
ltemCount=Window("Flight Reservation").WinComboBox("Fly From:").GetltemsCount()
For i=O to ItemCount-1 Step 1
ItemVal=window("Flight Reservation").WinComboBox("Fly From:").Getltem(i)
Print ItemVal
Next
Script 5:
How to display FlyFrom Combo Box items one by one into Notepad Option Explicit
Option Explicit
Dim ObjFSO,Obj\VL,ltemCount,i, ItemVal
Set ObjFSO=CreateObject(''Scripting.FileSystemObject")
Set ObjWL=ObjFSO.OpenTextFile("C:\LiveTech\FlyFrom.txt",2)
ltemCount=Window("Flight Reservation").WinComboBox("Fly From:").GetltemsCount()
For i=O to ItemCount-1 Step 1
ItemVal=window("Flight Reservation"). WinComboBox("Fly From:").Getltem(i)
ObjWL.Writeline ItemVal
Next
ObjWL.Close
,-_,'
~
Set ObjWL=nothing
Set ObjFSO=nothing
Page 65 of 118
Mr.Venkat (Sr. Test Manager)
~~~-
r=
ij
Script 6:
How to display Flyfrom Combo box items one by one into Runtime Data table and the same data
table export to Excel Sheet
Option Explicit
Dim ObjFSO,ObjWL,ItemCount,i, ItemVal
Datatable.AddSheet "Output"
Datatable. GetSheet("Output").AddParameter "FlyFrom", ""
ItemCount=Window("Flight Reservation").WinComboBox("Fly From:").GetitemsCount()
For i=O to ItemCount-1 Step 1
Datatable. SetCurrentRow(i+ 1)
Item Val=window("Flight Reservation").WinComboBox("Fly From: ").Getltem(i)
Datatable. Value("FlyFrom", "Output")=Item Val
Next
Datatable.ExportSheet "C:\QTP_Examples\ WBMS\Frameworks\Test Log\FlightLocation.xls" ,"Output"
Script 7:
How to verify update Order behavior in the Flight reservation application and how to pass multiple
values from the text me - File System Object(Text Files)
Option Explicit
Dim fso,f,s,arr,strStatus
Set fso=CreateObject("Scripting.filesystemobject")
set f=fso.OpenTextFile("E:\Records.txt", I)
::
C<
~------
tr,
-:-
\Vend
f. Close
Set fso=nothing
Page 66 of 118
~liveTech
finry
"'''ti"
ttsrinn
6. Excel Files
Excel Object:
This is one of the objects provided by the VB Script.
)> We can create Excel files, Workbooks, Sheets and Colors in our Machine.
Syntax:
Set Object Name= Createobject ("Excel.application")
Set objExcel=Createobject ("Excel.application")
)>
Script 1:
How to create below excel file and how to save in framework folder
A
I B
_1_ l11pt1t 1 J!.~p~~1?
_1_ -~
;
c
Result
-----t
- +- _ _ _- ~- _ _ _ _ _ -+ t
,_ _ _ ___
':J
=t-?Ue
ol<J [xcel_-v,..sble_
c~ c~u 1 , f~. c
.
chJcS~'
Lc;eJ
1..: , ~~
CAJ ,s "'t'et-..
!npu-1::
Lt
1J
or .:-::. v bBilte_
O~/ ce___LU_ ~
i
l/
ll
L_
~;
eel t;.(
J- ~ npuc ...:L ;
al:JJ s h-e.e-. - I
c~ G0
ce)lr
(_
l0
o~ ceLJ3
111
1,
" - "-
r (_
bg l u_ e_
f?t;Julf:-'1
:: ObjtSLrecl . cclls
L '/ 0.)
..----~--------
r,
r10
S&
obj J.-..J~ =-
oQ}t-J(3 .. s~.s
dhj[:x-cel_. Ach'veJ..Jovkbook.
u
c \ \ 1-3JE \ t;Gpp(YJ(___
11
-,.-
=------
Page 67 of 118
Script 2:
How to validate Update Order behavior and set results into excel file
Set objExcel=Createobject ("Excel.application")
objExcel. Visible=True
objExcel. Workbooks.Add
set objSheet=objExcel.ActiveSheet
objSheet.cells(l, 1)="Status"
set c1=objSheet.cells(1,1)
c 1.font.color=vbblue
Window(" Flight Reservation"). WinMenu("Menu"). Select "File; Open Order..."
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No. ").Set "ON"
Window("Flight Reservation").Dialog("Open Order"). WinEdit("Edit_2").Set "2"
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
strMsg = Window(''Flight Reservation").WinButton("Update
Order"). GetROProperty("Enabled ")
If strMsg="False" Then
Reporter.ReportEvent micPass,"Update is disabled ","Test is Pass"
obj Sheet.cells(2, 1)="Update is disabled "
Set c2=objSheet.cells(2,1)
c2.font.color=vbgreen
else
Reporter.ReportEvent micFail,"Update is Enabled","Test is Fail"
objSheet.cells(2,1)="Update is Enabled"
Set c2=obj Sheet.cells(2, 1)
c2. font.color=vbred
End If
set objWbook=objExcel.ActiveWorkbook
objWbook.SaveAs "E:\Venkat.xls"
objExcel. Quit
Set objExcel=nothing
Script 2:
How to validate Update Order behavior and pass data from excel file
Set objExcel=Createobject("Excel.application")
objExcel. Visible=True
set objBook=objExcel.Workbooks.Open("E:\Demo.xls")
set objsheet=objBook.ActiveSheet
-"-
"
Var=objsheet.Cells(i, I)
Window("Flight Reservation").Activate
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order. .. "
r-- ------
Page 68 of 118
-~~
rr
I~
~
L
~
r:
~r~
~
-~i-
:=---
Page 69 of 118
Mr.Venkat (Sr. Test Manager)
;;
L_
----,.-
5
~:!-~
J,,,;
_,....;;r.-~.. -"-
.f?.ri?o'i--';;-.-, ...
~~ced~~!!JPBJ
1
:-t
<
(1)
pcJ-o- 6 c.8
Doln-l<>bie. - [R.or [
----------'7\
.[V)\I(y-cn~ .)(:~
S Lr;pt;
~ t~tV ~-l:l
~WE':
Pa.._Jo,.,
5oct chi 10
Te;,q {r l..e.J
occ~,,J-o,~,
-~
.-
.L Ll.rc.hO?
<AoD'3
6!}
1
C
CD
hcl'flsJ\
jftl
1 me.H.,_O<k, -
="""""'
s~/c,eJshe<icfaeJ: e=o cu4Js~f!.o'j
c.et vak.e;Set- v..we; exp.,&s"-tJ
>-:l
s-et
Pcvv~,r "ru
~
"'
oo.- ( vcJ.ce
~
..:;,
_1
S k'"'-la..av.,.
[ "
'i""'-c/
u Oo5 e
(Uri
r1fJ
:.. I
~J
-.- PY<IJ>'J
'Mmbe,- [ Rn (s 14,1-,
e.nv:'rD0oY>e.;J
-~
"'1
v~ ("" '?J
ti
.>. e
<lhJ'lso
?k .5_',1.S<Ie"l obje ctj {t -.-e~ bo I Jn../(reaJe TeA !J,'J-e} t.Jn'tcl;nidf'<Z<J T-fA/, bileA~d (,,
et'
(c)l.r->1 ' ) (
c
I
I)/- ,_L
(1)
_; // r-ou: ,
-...)
0
0
>-+,
~
00
/A c../-,v
&.Ju-f
c6/c:;r
hcoly' 5c~.to1J~~ ~
F,i~"f"?,~;-;
~nT!"mrrr
,"'~"~,,~~=""'"~""-""""T-~--~~n-lrr 1
r r
nm
~liveTech
fi<tlj
Wlinfl sofuti,,.,
Actions
Actions
> Action is a set of one or more script statements to perfonn a specific .task (or) Set of meaningful
Statements.
> It is a module which contains set of Script statements for a specific functionality of an Application
and it is integrated with Local Repository and Local Datasheet.
> When we select new test in QTP, by default "Action 1" will be available on QTP Test Pane which is
visible, but internally one more Action is maintained by QTP called "Action 0" in which the
execution is started and ended [just iike void main() inC Language].
> We can insert maximum of255 Actions in one single Test.
I
f
Benefits of Actions
> It increases Readability i.e. instead of reading the total script, we can read Action by Action.
> Debugging is very easy, i.e. we can find logical errors in the Script.
> Makes code Reusable.
> Scripts are easy to maintain.
> Scripts are efficient.
> Saves Development time.
Types of Actions
Three types of actions
1. Non-reusable action
An action that can be used only in the test in which it was created, and only once.
2. Reusable action
An action that can be called multiple times by the test in which it was created (the local test) as well
as by other tests.
3. External action
A reusable action called in another test.
External actions are read-only in the calling test. They can be modified only in the test in which they
were created.
Creating New Actions
1. Go to Insert menu> Click on call to New Action and observe Insert call to New Action dialog box
2. Enter Action name and description and Select Reusable Action if you want to make the action
reusable.
3. Decide where to insert the action and select "At the end of the test" or "After the current step" and
Click [OK]
Inserting Actions
You can insert an Existing Action in 2 ways
Page 71 of 118
-.,-
[------~~
t---
~liveTech
iktfy llslioR
sditti.>aJ
In the Select an action box, select the action you WMt to insert from the list
Specify where to insert the action: At the end or after the current step and click on [OK]
The action is inserted into the test as a call to the original action
'*********************************************************************************
5.
Save the file as "ActiohTemplate.mst"(mst=module script template) in QTP -> "dat" folder.
Note:
1) ActionTemplate.mst is the standard name.
2) Double Quotes are important then only the Template can be seen for every action in QTP TestPane.
tt--
'
~.-
Page 72 of 118
~liveTech
t{y
fit
IWinB !ofti<>D!
CHECK POINTS
Types of Check Points:
1. Standard Check Point
2. Bit Map Check Point
3. Database Check Point
4. Text Check Point
5. Text Area Check Point
6. Page Check Point (For Web Pages only)
7. Table Checkpoint (Web Table)
8. Image Check Point
9. XML Check Point
10. Accessibility Check Point
1) Standard Check Point
We can use this check point to verify the property of an object.
E x: v enry
r u1pjda t e o r d er
Step Name
Step-1
Step-2
Step-3
Step description
Activate Window
Open Record
Perform change
Expected result
Disable
Disable
Enable
Actual
Status
Navigation
Start Recording 0 Click on "Ok" 0 Activate Window (Flight 4a.exe) 0 File Menu 0
Click on Open Order 0 Select Order No. 0 Enter No. 0 Click on Ok [] Perform any
chang~q Click Update Orde.rO Stop RecordingO K~th~application (Flight4a.exe) in base
state 0 Identify positions in the Test Script to insert Check Points [After Activate window;
after open order; after perform change] 0 Stmi Recording 0 {Inse1i Menu 0 Check Points
0 Click on
Standard Check Point} {or F12} 0 show object []with 0 Click Ok 0 Enter Name of the
Check Point 0 Select Property with expected value (Enable-True= Enable; Enable-False=
Disable)O Click Ok 0 Stop Recording after insertion of all Check points at relevant places
0 Click Run DAnalyze results manually.
Ex:l
Window("Flight Reservation") .Activate
Window("Flight Reservation").WinButton("Update Order"). Check CheckPoint("CP _1 ")
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order. .. ''
Window("Flight Reservation'').WinButton("Update Order").Check CheckPoint("CP _2")
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set
"ON" Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set "30"
Window("Flight Reservation") .Dialog(" Open Order"). WinButton(" 0 K ").Click
Window("Flight Reservation").WinRadioButton("Economy").Set
Window("Flight Reservation").WinButton("Update Order").Check CheckPoint("CP_3")
Window("Flight Reservation").WinButton("Update Order"). Click
,
~
r---lr-
[-I!
,-:_11
Page 73 of 118
rc
i--------
.* liveTe.ch
filefy ltstinn so{n!WaJ
wait (10)
If Window("Flight Reservation").ActiveX("Threed Panel Control").GetROProperty("text")
="Update Done ... " Then
msgbox ("Test is pass")
else
msgbox ("Test is fail")
End If
. . . r:..,-- .
- t
----~-~--
- . ---------
=----
Page 74 of 118
L__
E ---.-:-
Step I After Current Step) 0 Click on Ok 0 Cdse current application (Flight 4a) 0 Open
another application (Flight 4b) 0 Click run to analyze results manually.
.~~~~~tl~-- . ..~==-::~==
....eo-----i
q:
'
,;;;r:
:-:.~'.'~. -~-illlU==~ ___ j
~
'f"~t:;':"S;,,;;;;oc<i''=~l
'.)
....
...
Actua
1 Data
Expected Value
==Fail
= ! Pass'
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:
r
-.'
"
E:------
~
-.~
,';
~
.f
Navigation
:----
Page 75 of 118
:=--------
C=
~----,--
Insert Menu 0 Check Point 0 Database Check Point 0 Select "Specify SQL Statement
Manually" 0 Next 0 Create 0 Machine Data source (Select Data source) 0 Select DSN
(QT_FLIGHT32) 0 Click Ok 0 SQL Statement (Enter your specified SQL Statement Ex:.
select * from orders) 0 Finish 0 Change the Check Point Name 0 Click Ok 0 Open
Frontend (perform any db operation like insert, delete, update) 0 Click Run 0 Analyze
results manually.
To Create New DSN
*) First of all you create One database in MS Access with specified table.
Navigation
Insert Menu 0 Check Point 0 Click on Database Check Point D Select "Specify SQL
Statement Manually" 0 Next 0 Create 0 Machine Data source (Select Data source) 0 New
0 Select type of data source (User
[Single user] I System Data Source
[multiple users]) 0 Next 0 Select a
Regular Expression.
Driver (Microsoft Access Driver) 0
[A-Z] [a-z] [0-9]*
Select database 0 Click Ok 0 Enter
[A-Z] [a-z] [] [A-Z] [a-z]* [A-Z]
Data Source Name with description 0
[a-z]*
Click Ok 0 Click Ok D Take your
specified statement (Table) Ex:. select *
from orders) 0 Finish 0 Click Ok.
Note Database Check Point insertion is not possible through Active Screen.
4) Text Check Point
We can use this checkpoint to conduct test on text present on the object.
Navigation
Start Recording 0 Insert Menu J Check Point 0 Click on Text Check Point
1E Select object with hand icon C Clhk CJ Ok J Enter Name of the Check Point 0 Enter
your expected Text in 'Constant' [_i Select ~vfatching [(I) Match Case (2) Ignore Spaces (3)
Exact Match (4) Text Not displayed] [' Click on Ok
1E Stop Recording 0 Click run to analyze re3.1lts manually.
How to ins~rt check point through Active Screen
Start Recording 0 Activate WindoYv :- Stop Recording [ Click on Active
Screen Icon
ight click on object which object text :,;ou want to check 0 Select insert
Text Check Point 0 Click Ok -:= Enter Checkpoint Name J Expected text fill in 'constant' 0
Select Matching [(1) Match Case (2) Ignore Spaces (3) Exact Match (4) Text Not displayed]
0 Select Insert Statement (Before I After Cunent step) ~j Click Ok 0 Click nm to analyze
results manually.
1!--
r------ci
t-
f
-r.g_
Navigation
Page 76 of 118
~UH~--
.*liveTech
fit=dyltslin1Js,,fJJril'llj
Start Recording 0 Insert Menu 0 Check Point 0 Click on Text Area Check Point 0
Select the area specified to check 0 Click Ok 0 Enter Name of the Check Point 0
Enter your ~xpected Text in 'Constant' or
click on to~e Regular expression 0 Select type of Matching [(1) Match Case (2)
Ignore Spaces (3) Exact Match (4) Text Not displayed] q Click on O~q Stop
Recordingq Click run to analyze result.srnanually.
Note: Text Area Checkpoint is not possible through Active Screen.
L_
Ii
Note:
For Web Table
Browser("Browser Text Object Name").Page("Page Name").WebTable("Table
Name"). Check CheckPoint("Check Point Name")
For Page Check Point
Text
Object
Browser("Browser
CheckPoint("Check Point Name")
~"-,.-
Name").Page("Page
P.
Name'').Check
.or---
'
:
!!
,-,-
Page 77 of 118
~liveTech
sofntions
10)
Il----
Navigation
Tools Menu D Options. D Web Tab D Advanced D Select I Check in the check point
[ActiveX Check, Alt Property Check, Applet Check, Frame Titles Check, Multimedia Links
check, Server-side Image Check, Tables Check] D Ok D Ok D Start recording 0 Insert
Menu D Check Point 0 Click on Accessibility Check Point 0 Show Web Page with Hand
Icon 0
Click 0
Ok q Enter Name of the Checkpoi11tO Click Ol<O Stop
Recordingq Rupq Analyze Results manually.
Note
Page Checkpoint, Table Checkpoint, Image Checkpoint, Accessibility Checkpoint, XML
Checkpoint are applicable for Web Pages only.
it-----
Page 78 of 118
~liveTech
To recover from unexpected events and errors that are occurred in the test envirorunent
during run session, we can use Recovery Scenario Manager.
~ For good recovery, error must be known the occurrence is unknown.
There are four types of events such as
1. Application Crash
2. Popup Window
3. Test Run Error
4. Object State
1. Application Crash
An open application fails during Test Run.
Navigation
);> Resources Menu ->Recovery Scenario Manager
);> Click New Scenario-> Next ->Select "Application Crash" as Trigger event->Next
);> Select "selected executable application"->Next ->Next ->Select Recovery Operation
[Keyboard, Mouse Operation, Close Application Process, function Call, Restart,
Microsoft Windows]
);> Next ->Ifyou want to check Add another operation else uncheck->Next->Next->Enter
Scenario Name->Next->Finish ->Close
);> Save the scenario in specified location with ' .qrs"
);> qrs stands for "QuickTest Recovery Scenario".
Result:
Trigger Event:
Application crash
/
Recovery Operations:
Restart Microsoft Windows
Post-Recovery Test Run Options:
Restart current test run
2. Popup Window
~ To handle unwanted POP UP's.
);> An open application fails during Test Run.
Navigation
);> .Resources Menu ->Recovery Scenario Manager ->Click New Scenario-> Next ->Select
"Popup Window" as Trigger event->Next
);> Cljck on Hand Icon->ShO\v unwanted window with Hand icon ->Next ->Select function
call as Recovery Operation ->Next [Open Notepad ->Sc:ve empty file with .vbs
extension]
~ Browse the .vbs fie path ->Next ->Uncheck Add another Recovery Operation ->Next->
Select Post-Recovery Test Run Option [Repeat current step and continue] ->Next ->Enter
Scenario Name ->Next ->Finish
);> Save the scenario in specified location with ".qrs"
~ Record required Recovery Operation (Click [OK] , Click [Cancel] on POP UP) take the
script into function
);> Save the library file ->Click Run
Page 79 of 118
..... ?>:.
~--
f-=----=--=----=
~
t--
~
I,
~liveTech
firefy wlinn solittiou
3. Test Run Error
A step in your test does not run successfully then Test Run Error can be raised.
Navigation
~ Select Next 0 New 0 Recovery Scenario Manager 0 Resources Menu 0 select any
error Next 0 "Testrunerror Window'; as Trigger event 0 o Next Select function call as
Recovery Operation 0 Next 0 Next 0 D 0 Browse the Save empty file with .vbs
extension] 0 [Open Notepad 0 Next Uncheck Add another Recovery Operation 0 Next
0 .vbs fie path 0
~ Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run,
Stop the Test Run] Select Option DFinish Next [J Enter Scenario Name 0 Next 0 0
~ Record required Recovery Operation Save the scenario with ".qrs" 0 [Click ok, Click
Cancel] take the script into function
? Click Run Save the library file 0
4. Object State
The property values of an object in your application match specified values. You can specify
, property values for each object in the hierarchy.
Navigation
>- Resources Menu 0 Recovery Scenario Manager D New 0 Next 0 Select "Object state
\Vindow" as Trigger event 0 Next 0 Click on Hand Icon 0 Show object with hand icon
0 Next 0 Next->select object property with value (enabled ,false)->click next 0 Select
function call as Recovery Operation [] Next [Open Notepad 0 Save empty file with .vbs
extension] fJ Browse the .vbs fie path c:: Next 0 Uncheck Add another Recovery
Operation D Next 0
;;;, Select Post-Recovery Test Run Option [Repeat current step and continue, Proceed to
Next step, Proceed to Next Action, Proceed to next test iteration, Restart current test run,
Stop the Test Run] 0 Next [j Enter Scenario Name 0 Next 0 Select Option DFinish
> Save the scenario with .qrs" ~~ Record required Recovery Operation [Click ok, Click
Cancel] take the script into function
;- Save the library file iJ Click Run
Output Values
~
It is a step in which one or more values are captured at a specific point in the test.
> En3blcs to choose which property values to output
Types of Output Values
Standard Output values
a
Text Output values
Text area outpur value
Database output value
XML output value
While Recording
Choose Insert> Output Value. (Or) Insert Output Value button on the toolbar
\Vhile editing your test
Right-click on the object in the Active Screen and choose Insert Output Value. (or) right-click
the step and choose Insert Output Value.
111
~-----
Page 80 of 118
.''r
,.
if!
I
Regular Expressions
Whenever the object text is changing dynamically at run time, we can use regular
expresswns.
If property value is changing during each run session, use regular expressions when defining
or parameterizing property values
In standard checkpoint the expected value of an object's property can be set as a regular
expression so that an object with a varying value can be verified
Example: When creating a standard checkpoint to verify the property values of an object, you
can set the expected value of an object's property as a regular expression so that an object with a
varying value can be verified
Virtual Objects
>>-
Virtual objects enables to record and run tests on objects that are not normally recognized by
Quick Test.
QTP'is failed to recognized application object, Go for Virtual Object.
Page 81 of 118
~
f--
---
At liveTech
>-
~--
~---=----
Page 82 of 118
,_:_
L
~
>
>>
The QuickTest Script Editor is a tool that enables you to open and edit multiple test scripts
and function libraries simultaneously.
You can also create new function libraries.
You can modify the script of a test, but you cannot create new tests, associate or remove
associated function libraries, or change information such as existing test names, test settings,
parameterization, or Data Table values.
~--
Navigation:
Start> Programs >QuickTestProfessional > Tools> QuickTest Script Editor.
El
L .. ~. Reb.Jrntbrnc
i -~ copy of Fltgt"I:O'der
!... ~ RebJrroH::>rne [Action:,)
ft"ID
Rc;;~Expcs~i:m
?7t-rr.--.~""' er('\Nelcom(l:
IAorcury Tours
Display area
-.;;r-----------
Resources
pane
t..~1ercuryTours
er('VieloJme: tr1ercuryrours
Flow pane
The QuickTest Script Editor window contains the following key elements:
Flow Pane:
~ Displays the flow of the action calls for each ofthe open tests.
Resources Pane:
~ Displays the open tests, its local actions and any function libraries associated with each
test, as well as a list of all currently open function libraries.
Display area:
~ Displays a window for each of the open tests and function libraries.
Page 83 of 118
;,
~.-
.r----
~---
r~
I--
._~~
Page 84 of 1 IS
!l' i
~liveTech
fiNly Wlinfl scfulions
Automation Framework
~
~
~
Automation Frame work is nothing but an Automation planning for the project which is
prepared by Test Lead.
It helps to control the automation .project in a better way.
In my current project, we are using "Hybrid framework" which is prepared by my Test
Lead (But, we customized the framework as per our project needs).
Page 85 of 118
.-"
,-.- -
a-'~
Navigation:
Record required repeatable operations 0 Save them in a specific location as reusable action 0
Prepare script for scenarios using those reusable actions 0 Save them 0 Take the help of Test
Batch Runner Tool to execute group of tests sequentially.
J-
16.
17.
18.
19.
20.
21.
22.
23.
24.
-Stage 2
r1
_.
~r---
f
!~
~.,
-Stage 3
"
b_;_
r,-
1. Tool Evaluation
> In first stage we evaluated commercial and open source test automation tools (QTP and
Selenium)
> After initial evaluation with our project 25 features, we finalized QTP
2. Analyzing the Test cases
.
> In Second stage, we analyzed arid understanding project test cases
> Getting Knowledge Transfer from manual Test Engineers
;;---
Page 86 of 118
'
I
~
II
l
-':_I
'****************************************************************************
Function Login(Byval strUrl,Byval strUid, Byval strPwd)
Page 87 of 118
f---
-*liveTech
L
f ..
fkefy tiiiisflliiiIW.,
Systemutil.Run strUrl
Dialog("Login ").Activate
Dialog("Login").WinEdit("Agent Name:").Set strUid
Dialog("Login").WinEdit("Password:").Set strPwd
Dialog("Login").WinButton("OK").Click
l---
'****************************Insert Order*************************************
'Function Name
:Insert Order
'Function Description
: It is used to verify Order
'Parameters
: dtDate,strFly_From,strFly_To,intTof, strName, intTic
'Date Created
: 23-Mar-2012
'Created by
: Venkat
'*****************************************************************************
Function Insert_Order(Byval dtDate,Byval strFly_From,Byval strFly_To,Byval intTof,Byval
strName,Byval intTic)
Window("Flight Reservation").WinMenu("Menu").Select "File;New Order"
Window("Flight Reservation'').WinObject("Date of Flight:"). Type dtDate
Window("Flight Reservation").WinComboBox("Fly From: ").Select strFly_From
Window("Flight Reservation").WinComboBox("Fly To:").Select strFly_To
Window("Flight Reservation").WinButton("FLIGHT").Click
Window("Flight Reservation").Dialog("Flights Table"). WinList("From").Select intTof
Window("Flight Reservation").Dialog("Flights Table").\VinButton("OK").Click
Window("Flight Reservation'').WinEdit("Name: ").Set strName
Window(" Flight Reservation"). WinEdit("Tickets: ").Set intTic
Window("Flight Reservation").WinButton("Insert Order").Click
wait(IO)
strMsg = Window("Flight" Reservation"). WinObject("Insert Done").GetROProperty("text")
If strMsg="Insert Done... " Then
Reporter.ReportEvent micPass,"InsertOrder","Insert Order Done Successfully"
Insert Order="Pass"
Else
Reporter.ReportEvent micFail,"InsertOrder","Insert Order Failed"
Insert Order="Fail"
Page 88 of 118
8..__._
..
I;
~
~
II
i
~
~:~-
,.
I
I
'
1
I
I
~
;;---
.* liveTech
fiNly ltJiiniJ JOf#Mnl
I
I
I
l
I
j
End If
End Function
'**************************** Update_Order ***********************************
'Function N arne
: Update_Order
'Function Description
: It is used to very Update Order
'Parameters
: intOrder,strName
'Date Created
: 23-Mar-2012
'Created by
: Venkat
'****************************************************************************
Function Update_Order(Byval intOrder,Byval strName)
Window("Flight Reservation").WinMenu("Menu").Select "File;Open Order... "
Window(" Flight Reservation ").Dialog("Open Order"). WinCheckBox("Order No. ").Set ON
Window("Flight Reservation").Dialog("Open Order").WinEdit("Edit").Set intOrder
Window("Flight Reservation ").Dialog("Open Order"). WinButton("OK"). Click
Window("Flight Reservation"). WinEditC'Name:").Set strName
Window("Flight Reservation"). WinButton("Update Order"). Click
strMsg = Window("Flight Reservation").WinObject("Undate Order").GetROProperty("text")
If strMsg="Update Done... " Then
Reporter.ReportEvent micPass,"Update Order","Update done successfully"
Update_Order="Pass"
Else
Reporter.ReportEvent micFail,"Update Order","Update Failed"
Update_Order="Fail"
End If
End Function
'**************************Close_App*****************************************
'Function Name
: Close_App
'Function Description
: It is used to Close the application
'Parameters
:- NA'Date Created
: 23-Mar-2012
'Created by
: Venkat
'*****************************************************************************
Function Close_App()
Window("Flight Reservation").Close
If not Window("Flight Reservation ").Exist(l 0) Then
Reporter.ReportEvent micPass, "Close app", "Application closed
successfully"
Close~App="Pass"
Else
Reporter.ReportEvent micFail,"Close app","Application not closed"
Close_App="Fail"
End If
End Function
'*****************************************************************************
4. Library
~.
f.
tr
J'
!:!.________
I ~r
~
'
:-:.~-
IT
Page 89 of 118
.~
All four functions copy into Notepad and Save it as .vbs extension
);> Copy the functions file into "Library" folder
Object Repository
);> Object Repository creation for application
);> Go to Resources~ Object Repository~ Add Objects to Local
);> Export these repository into "Object Repository" folder
Environment
);> Environmental variable creation
);> File~ Settings~ Environment~ User defined~ Add~ Enter Name as uri~
Enter Value as "uri of application"~ [OK]
);> Export user-defined environment variables to an XML file into "Environment"
folder
Recovery Scenario
);> Resources ~ Recovery Scenario Manager~ New Scenario icon ~Next ~
Select event
);> Save recovery Scenarios into "Recovery Scenario" folder
Test Data
);> Create input.xls file and save it into "Test Data" folder
);> Create three worksheets
1.
Module
2.
Test Cases
3.
Test Steps
1. Module
);>
5.
6.
7.
8.
Moduleld
IModuleNarne ModuleExe ;
M1
!Admin
Y
-l
~----------+-------------~-------------1
M2
!Customer
N ......_____________.
L--.-.-----------'-------------'-----'"
2. Test Cases
3. Test Steps:
lin
:uo
iCa
~~q~=~?.l..J!-:lP99!~_Qr9~r
Page 90 of118
t ---
I
I
~liveTech
filot/jltstillJisdltWiu
9. Test Script
10. Write Driver script
11. All files need to associate with script
)> Library
File ~Settings ~Resources ~Add
)> Environment Variable
File ~Settings~ Environment ~User Defined~ Load
)> Recovery Scenario
File ~Settings ~Recovery ~Add
)> Repository
Resources ~Associate Repository ~Add
Driver Script
*****************************************************************************
Project Code
: LT- 333
1
Project Name
: Flight Application
1
Created By
: Venkat
1
Date Created
: 24-Jan-2011
1
Test case Name
: Flight Application Home page
1
Test case Objective : Verify Login, Insert Order and Update Order
1
Expected Result
: Ordets should be Inserted and updated successfully
'**********************************Variable Declaration*************************
Option Explicit
Dim Mcount, Mexe, Moduleid, Moduleid1, Tcount, res, Keyword, Tscount Tcid, Tcid1, i,j, k
**********************Functional Scenario**************************************
'Adding sheet to runtime Data Table
Datatable.AddSheet ("Module")
Datatable.AddSheet("Testcase")
Datatable.AddSheet C1Teststep")
'Importing Sheets from an External Excel File
Datatable.ImportSheet "C:\Flightresrvation\Testdata\Input. xis", 1, "Module"
Datatable.lmportSheet "C :\Flightresrvati on\Testdata\Input.xls" ,2, "Testcase"
Datatable.ImportSheet "C:\Flightresrvation\Testdata\lnput.xls",~,"Teststep"
Mcount=DataTable.GetSheet("Module").GetRowCount
For i= 1 to Mcount step 1
Datatable.SetCurrentRow(i)
1
. :\
. ~
I
I
Ifucase(Mexe)="Y" Then
Moduleid=Datatable. Value(1, "Module")
Tcount=Datatable. GetSheet("Testcases"). GetRowCount
For j=l to Tcount step 1
Datatable.SetCurrentRow (j).
T~=DataTable.Value(3,"Testcases 11 )
Moduleid1 =DataTable.Value(4, "Testcases")
i'
I"
r'
~.
B -,-
~! ~
Page 91 of 118
r--
Keyword=Datatable.Value(3,"Teststeps")
Select Case Keyword
Case "In"
res= Login( environment. Value("url "), "venkat", "mercury")
Datatable.Value(4, "Teststeps")=res
Case "ca"
res=Close app()
Datatable.Value(4,"Teststeps")=res
Case "ins"
res=insert_order("090911 ","Denver","London",l,"John Gun","2")
Datatable. Value(4, "Teststeps")=res
Case "uo"
res=Update_Order("2","John Nithu")
Datatable. Value(4, "Teststeps")=res
End Select
End If
Next
End If
Next
End If
Next
I-
"~
Teststeps
tcOl ts1
tc01 ts2
tc02 ts1
tc02 ts2
tc2 ts3
tc03 ts1
tc03 ts2
tc03 ts3
1Function
Name
iLogin
!Close App
!Login
!Insert Oder
!Close App
iLoqin
\Update Order
\Close App
K~ord
In
ca
In
ins
lea
In
uo
ca.
:Result
'Pass
!Pass
Pass
'Pass
!Pass
:Pass
.Pass
Pass
,.,~
'Testcaseld ;
'
'tc01
i
I
:tc01
I
tc02
t
tc02
tc02
i
I
tc03
i
tc03
tc03
---
:_____ ____
Page 92 of 118
:~
--
5I
fl ,~tpi~~;
10 Environment
IQ library
~Recovery
~::;, Repository
Q Test Data
fO'Test Log,'
ra;a Tes~'Scrfpt:
2. Object Repository
~ Object Repository creation for application
~, Go to Resources -7 Object Repository -7 Add Objects to Local
~ Export these repository into "Object Repository" folder
3. Environment
~ Environmental variable creation
~ File -7 Settings -7 Environment -7 User defined -7 Add -7 Enter Name as uri -7
Enter Value as "url of application" ,-7 [OK]
~ Export user-defined environment variables to an XML file into "Environment"
folder
4. Recovery Scenario
~ Resources -7 Recovery Scenario Manager -7 New Scenario tcon -7 Next -7
Select event
~ , Save recovery Scenarios into "Recovery Scenario" folder
5. Test Data
> Create input.xls file and save it into "Test Data" folder
6. Test Script
~ Write Driver script
~ All files need to associate with script
1. Environment
:File-7 Settings-7 Environment-7 User Defined -7 Load
2. Recovery Scenario: File -7Settings -7 Recovery -7 Add
3. Repository:
Resources -7 Associate Repository -7 Add
*****************************************************************************
1
Project Code
: LT 333
Project Name
: Flight Application
1
Created By
: Venkat
1
Date Created
: 23-Mar-2012
1
Test case Name
:Flight Application
1
Test case Objective: Verify Calculation Test
1
Expected Result
: Calculation must be happen as per FRS
1
~----
11
,-,~
I*****************************************************************************
Mr.Venkat (Sr. Test Manager)
Page 93 of 118
[
~
l==
_I_
Option explicit
Dim Row_Count,i,Order_ Number,Tic,Price,Prc, Total, Tot
DataTable.AddSheet ("Input")
DataTable.AddSheet("Output")
DataTable.GetSheet("Output").AddParameter "Tickts",""
DataTable.GetSheet("Output").AddParameter "Price",""
DataTable.GetSheet("Output").AddParameter "Total",""
DataTable.GetSheet("Output").AddParameter "Results",""
DataTable.ImportSheet "D:\\Testdata.xls",l, "Input"
Row_ Count=Datatable.GetSheet("Input").GetRowCount
f
J
Next
Datatable.ExportSheet "D:\OutputSheet.xls","Output"
*****************************************************************************
7. Test Run
)>
8. Execution:
lt------
Go to Test Data Folder, In "input.xls" sheet mark to "Y" (yes) of the Module, Test cases
which are need to execute in current build
- )> Go to Test Run Folder and click on AOM.vbs file
)> Observe Test log Folder for results
)>
-'-
~---
Page 94 of 118
L_ __ _
'~
Script 3:
How to close all the browsers
Set objDesc=Description. Create
objDesc.Add "micclass","Browser"
set objColl=Desktop.ChildObjects(objDesc)
1-
,r
msgbox objColl.count
For i=O to objColl.count-1 step 1
BrN ame=objColl( i). GetropropertyC'name")
Msgbox BrName
objColl(i).close
"
tf-----
c!
Next
Script 4:
'How to close all t.b.e browsers except our specified browser
Option explicit
Dim objDesc,objColl,BrName,i
Set objDesc=Description.Create
objDesc.Add "micclass ","Browser"
Set objColl=::::Desktop.ChildObjects(objDesc)
For i=O to objColl.count-1 step 1
BrN ame=objColl(i). GetRoProperty("name")
IfBrName="Google" Then
'Dont do anything
Else
~7
Page 95 of 1 1
f7
objColl(i).close
End If
Next
Script 5:
How to close all items in Desktop except QTP
Set objDesc =Description. Create
objDesc("micClass").Value ="Browser"
Set objBrs = Desktop.ChildObjects(objDesc)
Fori = 0 to objBrs.count-1
strBrName=objBrs(i).GetROProp~rty("name")
Script 6:
How to count number of links in a specified web page
Set oDesc=Description.Create
oDesc.Add "micclass", "Link"
Set objColl=Browser("title:=Google").Page("title:=Google").ChildObjects(oDesc)
For i=O to objColl.Count-1 step 1
LinkName=objColl(i).GetRoProperty("name")
Print LinkName
Next
Script 7:
'How to count no of links in a specified web page and how to display their names one by
one into notepad
Option explicit
Dim objDes,opjColl,objFso,objf,i,link_name
Set objDes =description.Create
objDes.Add "micclass","Link"
Set objFso=createobject("scripting.tilesystemobject")
s.et objf=objFso.CreateTextFile("D:\linknames.txt")
. set objColl=Browser("title:=. *").Page("title:=. *").ChildObjects(objDes)
For i=O to objColl.count-1 step 1
link_name=objColl(i).getroproperty("name")
objf.WriteLine link name
Next
objf.Close
Set objFso=nothing
o--
"-----
t-~----
Page 96 of 118
r-
~:~
I
j
rt
Script 8:
How to Set link names one by on into Excel
Option explicit
Dim objExcel,objSheet,objWbook,objCell,i,Link_Name,objColl,objDesc
Set objExcel=CreateObject("Excel.application")
objExcel. Visible=True
objExcel. W orkbooks.Add
Set objSheet=objExcel.ActiveSheet
objSheet.cells(l, l)="LinkNames"
Set objCell=objSheet.cells( 1,1)
objCell.Font.color=Vbblue
Set objDesc=Descrip.tion.Create
objDesc.Add "micclass", "Link"
Set objColl=Browser("title:=. *").page("title:=. * '').ChildObjects(objDesc)
For i=O to objColl.count-1 step 1
Script 9:
How do we validate links in web page and how to display link names with status in excel
Set objExcel=Createobject("excel.application")
objExcel.Visible=True
objExcel. Workbooks.Add
set objSheet=objExcel.ActiveSheet
objSheet.Cells(1,l)="LinkName"
objSheet.Cells(1,2)="Expected URL"
objSheet.Cells(1,3)="Actual URL"
objSheet.Cells(1,4)="Status"
Set objDesc=Description.Create
objDesc("micclass "). value="Link"
set objLinks=Browser("title:=. *").page("title:=. *").childobjects( objDesc)
msgbox objLinks.count
,-,2------
Page 97 of 118
\1
~
~liveTech
s..ry
II
ttslilfl sof>tW.J
Browser("title:=. *").Sync
strActUrl=Browser("title:=. *").GetROProperty("url")
If instr(l ,strActUrl,strExpUrl,l )>OThen
Reporter.ReportEvent micPass, "Link Vaidation ","Succeed"
objSheet.Cells(i+2,l)=strLinkName
objSheet.Cells(i+2,2)=strExpUrl
objSheet.Cells(i+2,3)=strActUrl
obj Sheet. Cells(i+2,4 )="Pass"
Set C4=objSheet.Cells(i+2,4)
C4.Font.color=vbGreen
Else
Reporter.ReportEvent micFail,"Link Vaidation","Failed"
objSheet.Cells(i+2, I )=strLinkName
objSheet.Cells(i+2,2)=strExpUrl
objSheet.Cells(i+2,3)=strActUrl
objSheet.Cells(i+2,4)="Fail"
Set C4=objSheet.Cells(i+2,4)
C4.Font.color=vbRed
End If
Browser("title:=. *").Back
Next
set objWbook=obj Ex eel. ActiveWorkbook
objWbook.SaveAs "C:\OutPutdata.xls"
t----
II
objExcel.Quit
Set objExcel=nothing
r-,,
_,,-
~---
Page 98 of 118
r-'~
tl
HP Quality Center
THREE WAYS TO REPORT DEFECTS USING QUALITY CENTER:
1. Using Test Results window, Go to Tools and Click on 'Add Defect'
2. QTP submit defect for each failed step- QTP is connected to QC we have to Select option (Go to toolsL1
OptionsO RunO Select the "Submit a defect to Quality Center for each failed step")
3. Login into Quality Center and report the defect
I
Ij
I
II
INTRODUCTION:
Quality Center is a Test Management tool from HP (Mercury Interactive)
It is a web based application
FOLLOWING ACTIVITIES ARE PERFORMED IN QAULITY CENTER:
1. Is a repository(Requirements, Test Cases, Test Results and Defects)
'
~:
j.
,-.-
Page 99 of 118
~LiveTech
wlino sofh""
liufy
A) NEW REQUIREMENT:
New requirement is to create a parent or sibling to the existing requirement
Navigation:
REQUIREMENTS --> NEW REQUIREMENT
Can create the Requirements and also is used to map the Requirements to the Test Cases to perform Traceability
Matrix to ensure the amount of coverage in Test Execution with respect tot he Requirements
Navigation:
VIEW ->> REQUIREMENTS COVERAGE
MAPPING THE REQUIREMENTS:
Select the requirement, and select "select tests", the Test Plan tab is displayed on the right hand side of the screen,
navigate and select the Test Case(s) and click on left arrow.
NOTE: We can have one or more Test Cases or Test Scripts to a given requirement.
D) COVERAGE ANALYSIS:
Is to analyze the Requirements post execution, the status of the requirement is displayed with complete analysis with
the graphs and the numbers.
REQUIREMENTS GENERAL Y CAN HAVE DIFFERENT STATUS:
A) NOTCOVERED:
Is a default status of the requirement, when a requirement is created and no Test Case is associated.
B) PASSED:
When all the Test Cases associated with the requirement are executed and have the status as passed
C) FAILED:
When at least one Test Case is ended in a failed status for a given requirement
D) NOR RUN:
-~~-
~----
-~
-:-
~llveTech
fiulj ttsthJn i<>lti
NAVIGATION TO CREATE A TEST CASE:
TESTS -->NEW TEST
Specify the name of the Test Case and specify the Test Case description and in the design steps create the steps for
Test Cases (Step Name, Step Description and Expected Result)
NOTE: Creating Test Cases from Quality Center is not preferred as the server (QC)
might get slowed
down and might crash, hence the Test Case design is preferred in
external sources like MS Excel and MS
Word documents.
UPLOADING TEST CASES FROM MS EXCEL:
Specify the folder path in the excel document to which the Test Case have to be
uploaded, every folder should be preceded with a backslash (\)
EX: \INSURANCE\HEALTHINSURANCE
Select the Test Cases and go to Tools and select "Export to Quality Center".
Following are the steps:
STEPl: Enter the QC URL and click next
HTTP://SERVERN AME/QCBIN
STEP2: Enter the User name and Password and click next
Navigation:
FILE--> QUALITY CENTER CONNECTION
STEPI: Enter the URL and click Connect
STEP2: Enter the User Name and Password and click Authenticate
STEP3: Select the Domain and Project and click Login
After the connection is established, we can see the tests to "Test Plan" tab of quality
open the tests from Quality Center for enhancements for execution.
center or we can
3. TEST LAB:
f--
i-
~--
Test
can be done in 2
NOTE: To ailow Quality Center to launch quick the following configuration has to be done in QTP:
Navigation:
TOOLS--> OPTIONS--> RUN--> ALLOW OTHER HP PRODUCTS TO RUN TESTS AND COMPONENTS.
4. DEFECTS:
Is to store and track the Defects that are reported in the Test Execution process done in
Defects reported from test lab are also stored in the Defects tab.
We can also report Defects from the Defects tab, but this is done there is no related test case for the
defect identified.
GENERATING REPORTS AND GRAPHS:
We can generate reports and graphs in Quality Center for the Requirements, Test Results and the Defects.
Navigation:
ANALYSIS -->REPORTS and
ANALYSIS--> GRAPHS
~---
~!CWW'T'P'"II!A
IWniBIIIIII~"'QP
N'tMI
m:ultll
WM
~IOO.Ia!~'<f!:G!.'-"'iO!il:a~lfJ;i.Ur.ii!.IJIWW'~~IIIIIIIIIICIIill!!isr"PPJ.W?!HM'i
~-~~~
[-HP
--------~~~
__ _____
3:
'""!
,.__
<
(1J
sa~
!:?..
_.-...
C/)
flc&u nJ ob
""'
CQ c use.(
(1J
-3:
(/)
P:>
::l
ere~
&Q.B
A-nn
,2.
j: 1<-.S
Te..s+ P k&t
'Dc.>-p p ,
'?J
F.,-- o.rne
Wcvt:..
c~CY)
g.
~CMh
.T.st- Lob
nokt.b~e
-Poe.Pd
r>evec~s
Pl
--r-r,. rlr 11
'-
e-1-c
'Y
r'C.s
US';:J
T-e.s+
r~s1
CO-d'~
t-es+-~
Ub~
wr'\-0
1'.8-t-
Lob
~
-?c~
~u~
x..e..u....*=
yes!- CO.d~
Qapat
Hl
~+
i 6.
'
.f rG4v-e_
,()e,bec_Jj
'?J
lt.s I '-'::)
T e .s+ ~
\JJ- ~
c..ts;~ res+~
F x.-e Whi7V)
G-Jo{/'--
j.
G~r-oJ,~
iapCT(h
s; l.YI'(Jd.S
~Ufh ~
Pe,b-ecb
i0
u.s
CA....S
(.{j,':J
I~ TEJ+
oe-&cC)
Tc:..--b
f.s,b
~~.
\- oe,fe.cl--
'-
0
"""l
',
t2p~W--,;'-j,_,.-/
I D~cl-- ~';J~'
I.;.)
00
'
Ex: -e c.uJ-ion
.__;' /1'
&elf,yP
~u~rern~
<i. Deje-c..+
'
Oe,fec)-
<
--
"Tt:.s-1-
o~c.K. vp
sk CO->~~r-~~
'"d
V~-S
s Ul.A.lct
T-est
rnu...p P :':3
- ._ .t
"1'
fdck o..u.d.
IO
r=
u...J.~~
~0; le-#'1Jl.k
w; H,
1Y1a...i~1..~ce_
Limr..t<.S~
~~
4 l"-'FV+ 3:::::>
f:t
~---
s e.& I f'R._-5,
A--0 o
3 A-00
M,'flllll9fW!ISftijjlii-
C'D
. l
U<.Sevs
Pr cH v c.Jf' /
:-==::\
l~t~c.~
,T~
L A-DO
F)-S~ijD {JYojecJ:s
lllillillllliiiiEtt"'!
gppr
*....c
,-
~A-DD
rr~ecJ:s
CrEcJ--C
P:>
(JQ
~~~---
-----------------
~_
\- 1/Ze 'I)JiJ<M~ ]
.......J
cepIWIC!i!!!I!W4!
\_..
~'
--
--------------
---~---- -~~----------~--
" "'c"'T"~=~~-~~l~ti-~--r-----
rI 1
-~-
nr-~m
To
I<C2ciu ce_
I--
Ep fovt.
! ;
tfy brd._
1'-~u.xrd Dr-:veJ
1:
ffppL U.~
Crc~:>f1
~ up t-l~tJl.,'r;f{
ru.td
1
5. Where can view the results of the Checkpoint?
T~+-
r<,-est.tl t
J,v:nJ;w
6. What is the major difficulty you faced while working with QTP?
! c.vL/Ie 8.-e~h~
1-yc.LM Wotk_.,
No
rrw Q.JJ..d
~; Oe.h4.J fr.flJ-
;}__
CQrP
Sol .
,3
:.S
v, ( i---4&J
ubjE?J
So&e
CtJ...td Cn}q_c}
rYJ(.>AGv-er
'1
No
Resctlt
=-(Jy;LkJ.'c.n ahiec.t;.
HP Suppa/:
L re,.st- La_o__~
sc t_
I SS u E;j .
pyc_:pevJ::t
L~+
ohJ~op4 /
t.l
t'
.Se..tec ~
Q_cmtJ
~
u.JSktner
11
&bJ.CC1
./
l\)c_.-ne. ':)
9. Types of Actions?
j
T!jPEJ
rvOJ 'f{e<J.)~/e_
f------c
f-~
l==
e_:
~livetech
fiufyltJtilrSsof>tW<o
CfeTTo rr,jle~
(\t'J f{o
-m
f'r'F>XJ:t :
o1.l
sct
ra
Obie'*
Prpeli~ c~
Lm"""JoJc
Dv~, ~~
P=i'-(bh'e,j
J..
. .1!.1
'
12. Can you explain the AutomatiOn Process you are following m your comp':iny. -::::1
~{(' e
s \-e.-a~
1" o o I [ \J c-luo-FO() .
c~ +a
a:U{
t)t's h_j
-/-tl C..opj
ftc!,'c> :
oP
}Q.eo. J (}()~
A-d&> :
u.s~
shill obJ~ech
s<U:
obJoheJJ. =
"h,"c.s 1--)e.tt. f)(")
. ow o elet e cooki es
t d
16 H
us' :3
'-<!
1AJ.~u<h'l ob..Jed:
c~ c!~.Jec/;( ~~
,~pup
V05Cnpt' &he.Lt ~
'' rn-es.SOfJ.e_
'f
'
-[im-e. <...t
.5a'Y)JJ
()')I
rru'J..
~ <.JII)c_}, ~
,-,-
,_
~
ji--------
:}
;;
_-,-
i ----- --
I==
l---
.l
u.sed
,1ji.
get
o~ COil)
81 o.bj f\J
seA:
s.&-
d\:ll fx CU
~-
'n
J')
LI \' 4tJaD"
o . CC~V\-.e cJC.n Y
:::
c__)'fu~db.iC: cr
c ~db;"ecl: (_ 1r ft-OoDC!>
--
- A.
cd-ecb.J-ed: [
l\
-:::
COft\Y>1d4d
ttDdiJ8
<.:x~k~e cl- (
C'rGzk~ec.t-
r fx
[lt
(_yt:o-k_ ~ 'e_c):; (
L1
':J
9
l<.e(uvd.Sel-1
az rp
o~'slvt
(QTp
F/t-e<{yJcfc:Mo'b,feo{:J
11)
'
r--
tl
II
~St-~1: ........
~.,o. 4::J.,.~:on
S."2'!V2010. :::OV:U
):01- (:11(0
-'.-
~--
,-,~
Since QTP is integrated with Service Test, you can now test your GUI and non-GUI based apps
in a single run.
--
~--~
4. Record Support
For FireFox is now available.
9. Silverlight Add-in
To test objects in Silverlight 2 and Silverlight 3 applications. [After installation, Silverlight Addin is displayed in the Add-in Manager as a child add-in under the WPF Add-in]
~-
~liveTech
linn
finfy us
sofIW.,
3. Copy a Folder
Dim objFso, myFolder
myFolder=="C:\LiveTech\Qtp"
Set objFso==CreateObject("scripting.FileSystemObject")
objFso.CopyFolder myFolder,"E:abcd"
4. Delete a folder
Dim objFso, myFolder
myFolder=="C:\LiveTech"
Set objFso==CreateObject("scripting.FileSystemObject")
-:~-
objFso.DeleteFolder( myFolder)
2nd
IL_____
~
Pagel09ofll8
Mr.Venkat (Sr. Test Manager)
'
r,____
g
~liveTech
mtfy
soltimu
ltslin!l
If objFso.FolderExists(myFolder) Then
objFso.DeleteFolder( myFolder)
....
End If
t--
j
l
objFso.CreateTextFile ("C:\LiveTechQtp2.doc")
objFso.CreateTextFile ("C:\LiveTechQtp3.xls")
.-:-
objFso.CreateTextFile ("C:\LiveTechQtp4.pdf')
Note: We can Create other files also, but they act as Text/Flat Files
-~
Page 11 0 of 118
-~-
~liveTech
IW<fl tUn"'"'"""'
Its
i----
myFile3="C:\LiveTechQtp3 .xis"
myFile4="C:\LiveTechQtp4.pdf'
Set objFso=CreateObject("scripting.FileSystemObject")
IfNot objFso.FileExists(myFilel) Then
objFso.CreateTextFile (myFile1)
End If
If Not objFso.FileExists(myFile2) Then
objFso.CreateTextFile (myFile2)
Endlf
If Not objFso.FileExists(myFile3) Then
objFso.CreateTextFile (myFile3)
End If
If Not objFso.FileExists(myFile4) Then
objFso.CreateTextFile (myFile4)
End If
Page 111 of l 18
Mr.Venkat (Sr. Test Manager)
l - ------
g.._____
~liveTech
ktfylulioflwlltti.Jo,
e;
Set objFso=Nothing
Jj
Set objFso=CreateObject("scripting.FileSystemObject")
Set myFile=objFso.OpenTextFile("C:\LiveTechQtp2.txt", I) 'I for Read, 2 for Write and 8 for Append
!t
j
Do Until myFile.AtEndOfStream=True
I
I
I
myChar=myFile.ReadLine
Msgbox myChar
Loop
I
I
myFile.Close
Set objFso=Nothing
11. Data Driven Testing by fetching Test data directly from a Text file.
'************************************************************************************
*
'Test Requirement: Data Driven Testing by fetching Test data directly from a Text file.
'Author: xyz
'Date of Creation: 24-08-2010
'Pre-requasites:
'abcd.txt (Test Data File)
'Test Flow:
'Create File System object
'Open the file with Read mode and store reference into a variable
;:;-
..
'Login Operation
'Form Looping and pass Parameters
'
F
I
'************************************************************************************
*
~-
myFile.SkipLine
!
l
Ii
myLine=myFile.ReadLine
I
1
myFieid=Split(myLine," ,")
~~
,~~
Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:= Agent Name:").Set myField(O)
Dialog("text:=Login").WinEdit("attached text:=Password:").Set my Field( 1)
Wait 2
Dia1og("text:=Login").WinButton("text:=OK").Click
I~
I
I
I
l
u
Window("text:=Flight Reservation").Close
Loop
myFile.Close
Set objFso=Nothing
a=lO: b=20
iI
I
I
,-,-
Result=a+b
Set objFso=CreateObject("scripting.FileSystemObject")
Set myFile=objFso.OpenTextFile("C:\LiveTechQtp3.txt",2) '1 for Read, 2 for Write and 8 for Append
myFile.WriteLine "Addition of a, b is: "&Result
'
myFile.Close
Set objFso=Nothing
L _____ _
-~t_ ______ _
r--
~liveTech
tiNfyltslilflsdllima
14. Check if the File Exists or not? If Exists delete the File
Dim objFso
Set objFso=CreateObject("scripting.FileSystemObject")
t-
16. Capture Customer Names from 1 to 10 Orders in FR and export to a Text File
*****************************************************************
I
'
II
I
g
'Open the text file in write mode using File system object
'Login Operation
I
I
'*****************************************************************
t--
c=
~liveTech
wt.n;,s
ftulj ttslilln
Set objFso=CreateObject("scripting.FilesystemObject")
Set myFile=objFso.OpenTextFile("C:\LiveTechQtp.txt",2)
myFile.WriteLine "Customer Names"
l---
myFile.WriteLine "---"
IfNot Window("Flight Reservation").Exist(3) Then
SystemUtil.Run "C:Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe","","C:Program Files\HP\QuickTest
Professional\samples \flight\app", "open"
Dialog("Login").Activate
Dialog("Login"). WinEdit("Agent Name: ").Set "LiveTech"
Dialog("Login").WinEdit("Password:").SetSecure "4c9e05a626f9b6471971 fb 15474e791 b28cc ledO"
Dialog("Login").WinButton("OK").Click
Endlf
For Order_Number= 1 to 10 step 1
Window(" f) ight Reservation ").Activate
Window("Flight Reservation").WinButton("Button'").Click
Window("Flight Reservation").Dialog("Open Order'"). WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation").Dialog("Open Order''). WinEdit("Edit'').Set Order_Number
"- ' :~
c,
wait 2
Customer_Name = Window(''Flight Reservation"). WinEdit(''Name:'').GetVisibleText()
myFile. WriteLine Customer_Name
Next
~.-
Set objFso=Nothing
'
--
17. how to verify update Order behaviour in the Flight reservation application and how'to pass
multiple values from the textfile
~-----
Option explicit
Dim fso,f,s,arr,strStatus
Set fso=CreateObj ect(" Scripting. filesystemobj ect")
set f=fso.OpenTextFile("E:\Records.txt", l)
While not f.AtEndOfStream
s=f.ReadLine
an=split(s," ")
Window("Flight Reservation'').WinMenu("Menu").Select "File;Open Order ... "
Window("Flight Reservation").Dialog("Open Order").WinCheckBox("Order No.").Set "ON"
Window("Flight Reservation ").Dialog("Open Order"). WinEdit("Edit").Set arr( 1)
Window("Flight Reservation").Dialog("Open Order").WinButton("OK").Click
strStatus = Window("Flight Reservation").WinButton("Update Order").GetROProperty("Enabled")
If strStatus="False" Then
Reporter.ReportEvent micPass,"Update is Disabled","Test is pass"
Else
Reporter.ReportEvent micFail, "Update is Enabled", "Test id failed"
End If
Wend
f. Close
Set fso=nothing
*****************************************************************************
Set objFlyFrom =Description. Create
objFlyFrom("Class Name"). value= "wincomboBox"
objFlyFrom("attached text").value ="Fly From:"
Set objFlyTo =Description. Create
~liveTech
firtfy wlino '"'""""'
l----
'Set objwin=Description.Create
..
v-.._
else
fi---
I
rl
Next
-rJ-
Next
'*****************************************************************************
I
I
.----
I
Mr.Venkat (Sr. Test Manager)
r--
~
L__
J
1 ...,
[;
-l)
1
A S .s u
c, c..it
~ OuY~
.3 .
f\ c__l-if)
1'\._(_{N
r() (JE'rt
f,'"'\2
h' -Q,J
b.
~~;c'
"e
~
~
F.
~-,-
~------
._
L_
;;__:___:_:_::_
~
. !
~-lab Ie I"-jlalsh~
tt \
\sf'.(Ler\ L,v' H
~ <.<: >< Ls ~1
l< P ,-\ l
C i-f LAJJ \
J, ''-'- "f ~t
fZo<.J ecu.l:
+-o
For ,:.::. f
. ' CCLVLt:_
._ J
L-..,
s''-t'
l-
y- c_....._,
u f2rle pc:Je.
~~)- w ~--~~-e~ (
t,
~~).
A-EJeL...-i NcJI1e :
t t
d.i~
/2Qpvrk:; l&.rx1rf:e.~...reJ
d.cJc:ef<>b [-c'
,
1
,: ' ~
l>cl9
\..o-..._)
(_ U () k._
N-l..Cp,---e,-~
V.:-Lc"{_ (
t l.fe.*.
Sek
sd
IJ . c1_tde._
l.~' ~":j
rf'-N_/ b
'_;
v"-.L..e_
c~~ ir
l\
fc~(J
ocJuJccJJ--e . \[ 0-...~
'
(t~p~~~ r 11 -~J-4JJa!_}
La:r'c,. /~
II
Dw-lz.Jc-bfE
1"-
J-eua.
f=-i-;s
-5
i ~~ c::(~ 1j ~
!l
-kf(#-
~~~
11
{Jc>-5.J /i
I .\ r 1
1 tJ ,, ~
1
lr)
L
r Ltc.)'t_rt ~c)Hie-n-;:t, j Oe~
'
(I
cFc<-l.(/
(_ \\ ,f-c-;4- ~ l) t~) r (
.I
e-,'
t.rf:Jv?,J
\t f 'L.p
Lc'J-{4..;
![
J-cA- ;.5
i
~~(It
s -,:e.; (
fJQ>cT
1
t >cf c.-'f t
{)o-tcz
f-est (~.
'
:_ _____ _
'--L -
r~
1-
>'.
l~
Li
I;
t'i-
!1
,,
--
q
f~.;--
i'-
--
~-c,.-_--
'
(f)
(JJ
c~{'_
l~J Co
~
mo~rejr~J-s~QS
fD 14
ob S--M..re__
TeJ.t-
TCCJ .-1-
~n Fut~
LCj
OU--tl
(Ftr- ~tt l 0 ~
()o.Lbfl'.
c)_{clc._
UVJ
\I
~,
Vi.u'r
fir-e_
L1
~
11
~
~
~
~
Li
-:f
r~
b-------
"~
~-
[T---
Tuk-tvrew q;ue.sf-r(ns
ma.nuo.l--re.s.~~
OY)
,___,
CLtSbev-
v ~-w
flrt:Jf:'~e.
fd."-t f-rotJ.'te
-
ch~e
pc~-~ J
~ f~
-'-;:> lo.pJ<,p
spe.c.fi~
--") c,-J.e..
pnce_
cyuc.~
r~~ rY1ade__
.~Lirr~
t=J
DefO\+~ ~~.
f4> ~e
~
~'-,shc:-hUJ.
O::.iH .(j\.b -Q. -
liclb.._
A-.i...v~
'""-.
__n_~~
!'\....<.._~
I
s-~o
~~tiD
------
~Pi
~-
~
~
....
~
ff
h,.oJ &
braD6er
pm(
i~
c..
J pc'!Je_(," p rnc
nc.
j . Puge L" Pm c
"c . j
1
'.)
P* (' pr>n c_
1N
.~t (''
~ u.h h4~
("
Re.~ <"
Swb";ej did:_
t{
.b /'C:tcJS<?r L"
r p<Y)(_ Ih. (. . J
o)
))
1'/;-.p <(} e.l!'<f\lwPc"':3e_t.,l
~ J F '~"-(_'. c {.)0h/J. '6
. h6 ""'
I
1
(_ '
b.,ause,r (" p JY1 c :r~ C . .") pOj'e. (I' ~j F rc.vo,e( " CDedails ;r)
upcbJ-ecdo=:~
---------
pc_.s.s 0-Lyd
1\..o.D-vc_:J
~~~e "
TY7v~:J:
-~~ee_Jd_
pc~~,J_
fcuno.r 9)
~~q\
ih~l
--~--~-----.
-6-1
I/ .
fh'*Ce
-t;:Lf- ~~ k
.y,'ew
UYuW_ cvc::b--
\jie.....l ~
CV'-'~~
Qe~-' 'fv-Dt8~/
v~Lw
~~
~('J~
v~d..Jc ~:Jk
8
ll <6-
t\J}
(-lhJo)
~td
po1-)
(bLf
~~~,
.~.-j~'
~~~-I.
~cLeJ-
(i<h&/
~~v-L_D
9fL~
t=-.c<.+--f\1
s-
f?BT
't
tr:
u[__
I'VI.scSL<je
IOI~:i @
Fr~
)~~t~
.-GJ
p"~c5v=f'F- \
S, r.f"
'
efl1c I:J
tl\..
p.e#PJ/ f :>
{Jtp~ho ~
.
OJ
L'~v-i
rf,