Upload
saikiran40cs
View
237
Download
0
Embed Size (px)
Citation preview
8/14/2019 QTP Complete Reference for CS.doc
1/222
QTP Complete Reference
QTP GuideStep by Step QTP Guide for beginners as well as advanced learners. Itexplains QTP Tool fundamentals and features in detailed manner. It
covers QTP tool window keyelements, QTP test process, ecording and
unning tests,!n"ancing tests, #ebugging Tests, $naly%ing Test esults
and eporting #efects.
It describes QTP important features like Step Generator, Syc"roni%ation,
Parameteri%ation, ecovery scenarios and &b'ect Identification
(onfiguration.
An overview on Test Automation
QTP Basic features
Add-in Manager
Key elements of QTP
Test Pane
QTP Commands
QTP Test Process
Recording Tests
Keyword riven Met!odology
Test "#$ect Model
http://www.gcreddy.com/2010/04/qtp-guide.htmlhttp://www.gcreddy.com/2010/04/overview-on-test-automation.htmlhttp://www.gcreddy.com/2010/03/qtp-basic-features.htmlhttp://www.gcreddy.com/2010/03/qtp-add-ins-info.htmlhttp://www.gcreddy.com/2010/03/qtp-tool-window.htmlhttp://www.gcreddy.com/2010/04/qtp-commands.htmlhttp://www.gcreddy.com/2010/03/qtp-testing-process.htmlhttp://www.gcreddy.com/2010/04/recording-tests.htmlhttp://www.gcreddy.com/2010/04/keyword-driven-methodology.htmlhttp://www.gcreddy.com/2010/04/test-object-model.htmlhttp://www.gcreddy.com/2010/04/qtp-guide.htmlhttp://www.gcreddy.com/2010/04/overview-on-test-automation.htmlhttp://www.gcreddy.com/2010/03/qtp-basic-features.htmlhttp://www.gcreddy.com/2010/03/qtp-add-ins-info.htmlhttp://www.gcreddy.com/2010/03/qtp-tool-window.htmlhttp://www.gcreddy.com/2010/04/qtp-commands.htmlhttp://www.gcreddy.com/2010/03/qtp-testing-process.htmlhttp://www.gcreddy.com/2010/04/recording-tests.htmlhttp://www.gcreddy.com/2010/04/keyword-driven-methodology.htmlhttp://www.gcreddy.com/2010/04/test-object-model.html8/14/2019 QTP Complete Reference for CS.doc
2/222
"#$ect Repository
"#$ect %dentification Configuration
QTP Test Met!ods
#ata Table )et"odsescriptive Programming
&n!ancing Tests
%nserting C!ec'points
%nserting "utput values
Parameteri(ation
)ync!roni(ation
%nserting Transaction Points
)tep Generator
Adding Comments
%nserting *low Control )tatements
e#ugging Tests
Running+&,ecuting Tests
Analy(ing Test Results Reporting
http://www.gcreddy.com/2010/03/object-repository.htmlhttp://www.gcreddy.com/2010/04/object-identification-configuration.htmlhttp://www.gcreddy.com/2010/03/qtp-methods.htmlhttp://www.gcreddy.com/2010/04/qtp-test-methods.htmlhttp://www.gcreddy.com/2010/03/descriptive-programming.htmlhttp://www.gcreddy.com/2010/04/inserting-checkpoints.htmlhttp://www.gcreddy.com/2010/04/inserting-output-values.htmlhttp://www.gcreddy.com/2010/03/parameterization.htmlhttp://www.gcreddy.com/2010/03/synchronization.htmlhttp://www.gcreddy.com/2010/04/inserting-transaction-points.htmlhttp://www.gcreddy.com/2010/04/step-generator.htmlhttp://www.gcreddy.com/2010/04/adding-comments.htmlhttp://www.gcreddy.com/2010/04/debugging-tests.htmlhttp://www.gcreddy.com/2010/04/analyzing-test-results-reporting.htmlhttp://www.gcreddy.com/2010/03/object-repository.htmlhttp://www.gcreddy.com/2010/04/object-identification-configuration.htmlhttp://www.gcreddy.com/2010/03/qtp-methods.htmlhttp://www.gcreddy.com/2010/04/qtp-test-methods.htmlhttp://www.gcreddy.com/2010/03/descriptive-programming.htmlhttp://www.gcreddy.com/2010/04/inserting-checkpoints.htmlhttp://www.gcreddy.com/2010/04/inserting-output-values.htmlhttp://www.gcreddy.com/2010/03/parameterization.htmlhttp://www.gcreddy.com/2010/03/synchronization.htmlhttp://www.gcreddy.com/2010/04/inserting-transaction-points.htmlhttp://www.gcreddy.com/2010/04/step-generator.htmlhttp://www.gcreddy.com/2010/04/adding-comments.htmlhttp://www.gcreddy.com/2010/04/debugging-tests.htmlhttp://www.gcreddy.com/2010/04/analyzing-test-results-reporting.html8/14/2019 QTP Complete Reference for CS.doc
3/222
8/14/2019 QTP Complete Reference for CS.doc
4/222
****************************************
*ile )ystem )cripts
*lat *ile )cripts
ata#ase )cripts-%
ata#ase )cripts-%%
&,cel )cripts
G0% )cripts
1e# )cripts
1e# )cripts -%%
QTP Real-time )cript &,amples
2etwor' Administration
)ystem Administration
Power point )cripts
1ord )cripts
3M4 )cripts
http://www.gcreddy.com/2010/03/file-system-scripts.htmlhttp://www.gcreddy.com/2010/03/flat-file-scripts.htmlhttp://www.gcreddy.com/2010/03/database-scripts.htmlhttp://www.gcreddy.com/2010/04/runningexecuting-tests.htmlhttp://www.gcreddy.com/2010/03/excel-scripts.htmlhttp://www.gcreddy.com/2010/03/qtp-scripts-examples.htmlhttp://www.gcreddy.com/2010/03/web-scripts.htmlhttp://www.gcreddy.com/2010/04/enhancing-tests.htmlhttp://www.gcreddy.com/2010/04/vb-script-keywords.htmlhttp://www.gcreddy.com/2010/04/network-administration.htmlhttp://www.gcreddy.com/2010/04/system-administration.htmlhttp://www.gcreddy.com/2010/04/database-connections.htmlhttp://www.gcreddy.com/2010/03/file-system-scripts.htmlhttp://www.gcreddy.com/2010/03/flat-file-scripts.htmlhttp://www.gcreddy.com/2010/03/database-scripts.htmlhttp://www.gcreddy.com/2010/04/runningexecuting-tests.htmlhttp://www.gcreddy.com/2010/03/excel-scripts.htmlhttp://www.gcreddy.com/2010/03/qtp-scripts-examples.htmlhttp://www.gcreddy.com/2010/03/web-scripts.htmlhttp://www.gcreddy.com/2010/04/enhancing-tests.htmlhttp://www.gcreddy.com/2010/04/vb-script-keywords.htmlhttp://www.gcreddy.com/2010/04/network-administration.htmlhttp://www.gcreddy.com/2010/04/system-administration.htmlhttp://www.gcreddy.com/2010/04/database-connections.html8/14/2019 QTP Complete Reference for CS.doc
5/222
QTP )'ills
&rror /andling in QTP5555555555555555555555555555
.B )cript for QTP
It explains + Script in QTP orientation, It covers all most all + Script
undamentals and eatures.
It describes, +ariables, constants declarations, usage of operators, +
Script flow control statements, Procedures, (oding conventions, egular
!xpressions, ile system &perations, #atabase &perations etc..
****************************************
)cripting 4anguages .s Programming4anguages
.B )cript *undamentals *eatures
Comments
.B )cript .aria#les
.B )cript ata Types
.B )cript "perators
%nput+"utput "perations.B )cript Constants
.B )cript Conditional )tatements
http://www.gcreddy.com/2010/03/qtp-skills.htmlhttp://www.gcreddy.com/2010/01/xml-scripts.htmlhttp://www.gcreddy.com/2010/04/vb-script-for-qtp_05.htmlhttp://www.gcreddy.com/2010/04/scripting-languages-vs-programming.htmlhttp://www.gcreddy.com/2010/04/scripting-languages-vs-programming.htmlhttp://www.gcreddy.com/2010/04/inserting-flow-control-statements.htmlhttp://www.gcreddy.com/2010/04/comments.htmlhttp://www.gcreddy.com/2010/03/vb-script-variables.htmlhttp://www.gcreddy.com/2010/04/vb-script-data-types.htmlhttp://www.gcreddy.com/2010/03/vb-script-operators.htmlhttp://www.gcreddy.com/2010/04/methods.htmlhttp://www.gcreddy.com/2010/04/constants.htmlhttp://www.gcreddy.com/2010/03/conditional-statements.htmlhttp://www.gcreddy.com/2010/03/qtp-skills.htmlhttp://www.gcreddy.com/2010/01/xml-scripts.htmlhttp://www.gcreddy.com/2010/04/vb-script-for-qtp_05.htmlhttp://www.gcreddy.com/2010/04/scripting-languages-vs-programming.htmlhttp://www.gcreddy.com/2010/04/scripting-languages-vs-programming.htmlhttp://www.gcreddy.com/2010/04/inserting-flow-control-statements.htmlhttp://www.gcreddy.com/2010/04/comments.htmlhttp://www.gcreddy.com/2010/03/vb-script-variables.htmlhttp://www.gcreddy.com/2010/04/vb-script-data-types.htmlhttp://www.gcreddy.com/2010/03/vb-script-operators.htmlhttp://www.gcreddy.com/2010/04/methods.htmlhttp://www.gcreddy.com/2010/04/constants.htmlhttp://www.gcreddy.com/2010/03/conditional-statements.html8/14/2019 QTP Complete Reference for CS.doc
6/222
4oop t!roug! Code
.B )cript )tatements
.B )cript Procedures
.B )cript &rrors
.B )cript Built-%n *unctions
0ser efined *unctions
Regular &,pressions
.B )cript Met!ods
.B )cript "#$ects
.B )cript Coding Conventions
.B )cript Classes
.B )cript Keywords
.B )cript synta, rules and guidelines
.B )cript General &,amples
.B )cript General &,amples-%%
.B)cript Glossary******************************************
http://www.gcreddy.com/2010/03/looping-through-code.htmlhttp://www.gcreddy.com/2010/03/vb-script-procedures.htmlhttp://www.gcreddy.com/2010/04/vb-script-errors.htmlhttp://www.gcreddy.com/2010/03/vb-script-functions.htmlhttp://www.gcreddy.com/2010/10/challenges-in-test-automation.htmlhttp://www.gcreddy.com/2010/04/regular-expressions.htmlhttp://www.gcreddy.com/2010/04/vb-script-objects.htmlhttp://www.gcreddy.com/2010/04/vb-script-statements.htmlhttp://www.gcreddy.com/2010/04/vb-script-properties.htmlhttp://www.gcreddy.com/2010/04/vb-script-syntax-rules-and-guidelines.htmlhttp://www.gcreddy.com/2010/03/vb-script-examples.htmlhttp://www.gcreddy.com/2010/04/qtp-job-news.htmlhttp://www.gcreddy.com/2010/03/vb-script-glossary.htmlhttp://www.gcreddy.com/2010/03/vb-script-glossary.htmlhttp://www.gcreddy.com/2010/03/looping-through-code.htmlhttp://www.gcreddy.com/2010/03/vb-script-procedures.htmlhttp://www.gcreddy.com/2010/04/vb-script-errors.htmlhttp://www.gcreddy.com/2010/03/vb-script-functions.htmlhttp://www.gcreddy.com/2010/10/challenges-in-test-automation.htmlhttp://www.gcreddy.com/2010/04/regular-expressions.htmlhttp://www.gcreddy.com/2010/04/vb-script-objects.htmlhttp://www.gcreddy.com/2010/04/vb-script-statements.htmlhttp://www.gcreddy.com/2010/04/vb-script-properties.htmlhttp://www.gcreddy.com/2010/04/vb-script-syntax-rules-and-guidelines.htmlhttp://www.gcreddy.com/2010/03/vb-script-examples.htmlhttp://www.gcreddy.com/2010/04/qtp-job-news.htmlhttp://www.gcreddy.com/2010/03/vb-script-glossary.html8/14/2019 QTP Complete Reference for CS.doc
7/222
QTP *ramewor'T"is section provides concepts on 1ow to implement $utomation
ramework. It explains about $utomation Infrastructure development,
esources creation, #river script creation, Initiali%ation script creation etc.
It describes data driven framework, keyword driven framework and1ybrid framework in detailed manner. It also provides Test estimations,
$pprovals, eporting, &rgani%ing and maintaining frameworks.
**********************************************
QTP %nterview Questions
QTP Model ResumesT"is section provides, esume preparation guidelines for fres"er as
well as experienced. It provides some model QTP esumes for
reference.
QTP 6o# 2ewsT"is section Provides QTP 2ob news weekly. Information can be
collected by !mployers, (onsultants and employees. QTP Professionals
can use t"is information and t"eir resumes directly to !mployer3s and
consultants mail ids.
QTP CertificationT"is section provides 1P QTP (ertification guidelines and modelQuestions, It useful for QTP test professionals for preparing
(ertification exam.
QTP Training ProgramsT"is section provides information on variou QTP Training programs like
QTP asics program for beginners, $dvanced program for working people,
QTP ramework, and + Script for QTP t"at conducted by gcreddy.com
Manual Testing ocumentsT"is section Provides link to our anot"er website gcreddy7net, t"ereyou can get )anual Testing Information like, Software Testing Guide,
)anual Testing Interview 4uestion and answers, Test management
guidelines, Test planning, Test design and ot"er documents.
*******************************************
Quality Center
http://www.gcreddy.com/2010/04/qtp-framework.htmlhttp://www.gcreddy.com/2010/04/qtp-interview-questions.htmlhttp://www.gcreddy.com/2010/04/qtp-model-resumes.htmlhttp://www.gcreddy.com/2010/03/qtp-job-news.htmlhttp://www.gcreddy.com/2010/10/qtp-certification-questions.htmlhttp://www.gcreddy.com/2010/04/qtp-training-programs.htmlhttp://www.gcreddy.net/http://www.gcreddy.com/2010/01/windows-scripts.htmlhttp://www.gcreddy.com/2010/04/qtp-framework.htmlhttp://www.gcreddy.com/2010/04/qtp-interview-questions.htmlhttp://www.gcreddy.com/2010/04/qtp-model-resumes.htmlhttp://www.gcreddy.com/2010/03/qtp-job-news.htmlhttp://www.gcreddy.com/2010/10/qtp-certification-questions.htmlhttp://www.gcreddy.com/2010/04/qtp-training-programs.htmlhttp://www.gcreddy.net/http://www.gcreddy.com/2010/01/windows-scripts.html8/14/2019 QTP Complete Reference for CS.doc
8/222
T"is Section Provides Quality (enter undamentals and features5 Site
$dministration, (reating #omains, Pro'ects, and /sers. (reating
e4uirements, #esigning )anual 6 $utomated Tests, !xecuting )anual
and $utomated Tests and !ntering defects. Sending #efects directly from
QTP esult window.
**********************************************************
4oadRunner T"is section provides 7oadunner tool undamentals and eatures5
+user generator, (ontroller, 7oad Generator, $nalysis and 7oadunner
Interview Questions.
*********************************************************
QTP "t!er TopicsT"is section provides QTP elated articles and ot"er information like,
c"allenges in Test $utomation using QTP, )igrating Test scripts fromold version to 8ew version, QTP trends, en"ancements, 8ew release
information, rowser compatibility issuesetc..
QTP )oftware ownload 4in'
)Q4 )erver Guide
)oftware Testing ocuments#ocuments on /nit Testing, 0eb Testing, Software Testing $rtifacts,
Software Test Process !tc..
QTP Basic Features9 QTP was 7aunc"ed in :;;: .
9 QTP is an "#$ect BasedTesting Tool.
(Object based means; QTP Follows Test Object Model for Performing
Testing operations. Based on either Test Objects or Atomation Objectsor !tilit" Objects onl"# we can atomate test operations$
(%oad&nner is a Protocol based Test Tool$9 QTP is for unctional and egression Testing.
(Basicall" QTP is a Fnctional and &egression Test tool bt we can se itfor little bit 'ompatibilit" Testing and Performance Testing$
http://www.gcreddy.com/2010/04/system-administration.htmlhttp://www.gcreddy.com/2011/06/qtp-1000-software.htmlhttp://www.gcreddy.com/2011/01/sql-server-guide.htmlhttp://gcrit.com/http://www.gcreddy.com/2010/04/system-administration.htmlhttp://www.gcreddy.com/2011/06/qtp-1000-software.htmlhttp://www.gcreddy.com/2011/01/sql-server-guide.htmlhttp://gcrit.com/8/14/2019 QTP Complete Reference for CS.doc
9/222
9 It follows Keyword riven $pproac".
(e"word )ri*en Approach means; e"words# e+ample, 'ommands#fnctions# methods# statements etc.. are sed for creating Test scripts$9 It supports 0indows &perating !nvironment only.
(QTP basicall" depends on !ser -nterface to atomate test operationsand it is not depends on ser*er side interactions# where as %oad&nnerdepends on ser*er side Operations# so P de*eloped %oad&nner for/indows as well as !0-1 *ersions$
9 It supports G/I based
8/14/2019 QTP Complete Reference for CS.doc
10/222
and #ata base operations.
9 It was derived from $stra QuickTest
9 $stra QuickTest
8/14/2019 QTP Complete Reference for CS.doc
11/222
9 J.:- :;;> )ercury Interactive
9 J.D F:;;H 1.P
9 C;.;; F:;;J 2anuary
9 ::7;;
8/14/2019 QTP Complete Reference for CS.doc
12/222
In-1ouse Test )anagement Tools
#efect )anagement Tools
Security
/nit Test tools !tc...
------------------------------------------------------------------------
I= asic eatures of QTP
-------------------------------------------------------------------------
a= QTP Supporting !nvironments
C= /I = QTP (ommands
8/14/2019 QTP Complete Reference for CS.doc
13/222
---------------------------------------------------------------------------
II= QTP Test Process
---------------------------------------------------------------------------
)anual Test Process
8/14/2019 QTP Complete Reference for CS.doc
14/222
----------------------------------------------------------------------------------
III= Test !xecution III$= #ebugging Tests
8/14/2019 QTP Complete Reference for CS.doc
15/222
b= #ynamic programming
ecording Tests
----------------
a= ecording Process b= ecording )odes
i= 8ormal ecording
ii= $nalog ecording
iii= 7ow 7evel ecording
c= unning Process
&b'ect epositoryB
------------------
a= &b'ect and Types of &b'ect
i= un-time &b'ects
ii= Test &b'ect )odel
iii= /tility &b'ects
iv= $utomation &b'ects
b= Types of &b'ect epository
i= 7ocal epository
ii= S"ared epository
c= &perations on &b'ect epository
i= $dding &b'ects
ii= enaming &b'ects
iii= #eleting &b'ects
iv= !xporting 7ocal &b'ects
v= )erging epositories
vi= $ssociating epositories to an $ction
vii= +iew &ptions viii= !xporting &b'ects to @)7AImporting &b'ects from @)7
i@= #efining 8ew Test &b'ects
@= Spying &b'ects
d= &b'ect Identification (onfiguration
8/14/2019 QTP Complete Reference for CS.doc
16/222
i= 8ormal identification
C= )andatory properties
:= $ssistive properties
ii= Smart Identification
8/14/2019 QTP Complete Reference for CS.doc
17/222
d= 1andling #uplicateASimilar &b'ects using Index property
------------------------------------------------------------------------------------------------------
Key &lements of QTP Tool 1indow:> Test Pane8
It is programming interface of QTP, used for creating, editing, viewing
and deleting test scripts.
Test8It is a set of statements or set of one or more actions.
8/14/2019 QTP Complete Reference for CS.doc
18/222
2ote:81ere in test pane Test is same but views are different, if you
perform anymodifications in one view t"ose automatically reflects in
anot"er view.
2ote =8Tec"nical users use expert view and business user use key
word view.
2ote ?8/ser can customi%e Test pane view options.
8avigationB Tools )enuL view optionsL we can use font si%e and
colors etc.
=> Active )creen
It "as an optional element of QTP, it takes snap s"ots of every
statement t"at user performed action or operation on $/T.
It can be used for understanding and editing t"e test easily.
2avigation8+iew menuLactive screen ata Ta#le
http://2.bp.blogspot.com/_V6Tw34aTT_o/TC3Dfa7tHZI/AAAAAAAAAB4/CgH5_kZrA1w/s1600/gcr3.bmp8/14/2019 QTP Complete Reference for CS.doc
19/222
It "as an integrated spread s"eet
testing.
8avigationB+iew menuL#ata table
8/14/2019 QTP Complete Reference for CS.doc
20/222
@> e#ug .iewer
It is used for locating and rectifying or fixing errors.
It can be used for debugging t"e tests by step-by-step execution.
0e use Step into, Step over and Step out commands for debugging. %nformation
T"is pane s"ows syntax errors automatically during saving t"e test.
8avigationB view menuL information
http://2.bp.blogspot.com/_V6Tw34aTT_o/TC3Eslxc5WI/AAAAAAAAACI/hq_5i6_tuUs/s1600/untitled.bmp8/14/2019 QTP Complete Reference for CS.doc
21/222
> QTP Commands
QTP (ommands are available in ways.
C=. )enu options
:=. Tool ar options
=. S"ort cut keys
8/14/2019 QTP Complete Reference for CS.doc
22/222
ile menuBT"roug" file menu user can create, save tests, open existing
tests, export tests in %ip format.
!dit )enuBIt provides editing options and renaming, deleting and
splitting actions.
+iew menuBT"roug" t"is menu we can launc" and close, active screen,
#ata Table, #ebug viewer, information, missing resources etc.
Insert )enuBT"roug" t"is menu user can inserting c"eck points, out put
values,sync"roni%ing points.
In t"is menu step generator available, using t"is user can generate
recordable and non-recordable scripts.
T"roug" insert menu user can insert + Script conditional and loop
statements and transaction points
8/14/2019 QTP Complete Reference for CS.doc
23/222
Tools )enuBT"is menu provides Tools settings option, view options and
ob'ect identification configuration.
T"roug" t"is menu we can set tool options as well as test pane view
options.
In t"is menu ob'ect spy option available, t"roug" t"is we can get ob'ectMs
information.
8/14/2019 QTP Complete Reference for CS.doc
24/222
New > Function Library Creates a new function library.
Open > Test Opens an existing test.
Open > Business/Scripted
Component
Opens an existing business or scripted
component.
Open > Application Area Opens an existing application area.
Open > Function Library Opens an existing function library.
Close Closes the active function library.
Close All Function
Libraries
Closes all open function libraries.
Quality Center Connection Opens the Quality Center Connection dialog
box, enabling you to connect to
a Quality Centerproject.
Quality Center Version
Control
Provides a sub-menu of options for managing
versions of Quic!est assets
in Quality Center. !he sub-menu is availableonly when you are connected to version-
control enabledQuality Center project.
Sae "aves the active document.
Sae As Opens the relevant "ave dialog box so you cansave the open document.
Sae Test wit! "esources "aves a standalone copy of the current test
together with its resource files.
Sae All "aves all open documents.
#nable #ditin$ #aes read-only function libraries editable.
#%port Test to &ip File Creates a $ip file of the active document.
'mport Test (rom &ip File %mports a document from a $ip file.
Conert to Scripted
Component
Converts a business component to a scriptedcomponent.
)rint Prints the active document.
)rint )reiew &isplays the 'eyword (iew as it will loo
8/14/2019 QTP Complete Reference for CS.doc
25/222
when printed and enables you to modify thepage setup.
Settin$s Opens the "ettings dialog box, enabling youtodefine settings for the open document. )*ot
relevant for function libraries+
)rocess *uidance
+ana$ement
Opens the Process uidance #anagementdialog box, enabling you to manage the list of
processes that are available in Quic!est.
Associate Library
,-Function Library
Name>, wit! ,-.ocument
Name>,
ssociates the active function library with the
open document. )vailable only from function
libraries+
"ecent Files ists the recently viewed files.
#%it Closes the Quic!est session.
&dit Menu8It provides editing options and renaming, deleting and
splitting actions.
Command Function
ndo /everses the last command or deletes the last entry
you typed.
"edo /everses the most recent operation of the 0ndo
command.
Cut /emoves the selection from your document.
Copy Copies the selection from your document.
)aste Pastes the selection to your document.
.elete &eletes the selection from your document.
Copy .ocumentation to
Clipboard
Copies the content of the .ocumentationcolumn
of the 'eyword (iew, enabling you to paste it in an
external application.
Action > Split Action "eparates an action into two sibling actions or into
parent-child nested actions.
8/14/2019 QTP Complete Reference for CS.doc
26/222
Action > "ename Action Changes the name of an action.
Action > .elete Action 1nables you to remove the selected call to the
action, or delete the action and its calls from theactive test.
Action > Action )roperties 1nables you to specify options, parameters, and
associated object repositories for a stored action.
Action > Action Call
)roperties
1nables you to specify the number of run iterations
according to the number of rows in the &ata !able,and to define the values of input parameters and the
storage location of output parameters.
Step )roperties >
Comment )roperties
Opens the Comment Properties dialog box for acomment step. vailable only when the selected
step is a comment.
Step )roperties
> Ob0ect)roperties
Opens the Object Properties dialog box for a
selectedobject. vailable only when the selected
step contains a test object.
Step )roperties >
C!ec1point )roperties
Opens the relevant Checpoint Properties dialog
box for a selected object. vailable only when the
selected step is a checpoint step.
Step )roperties > Output
Value )roperties
Opens the relevant Output (alue Properties dialog
box for a selected object. vailable only when theselected step is an output value step.
Step )roperties > "eport
)roperties
&isplays the /eport Properties dialog box for a
report step. vailable only when the selected step isa"eporter2"eport#entstep.
Find "earches for a specified string.
"eplace "earches and replaces a specified string.
*o To #oves the cursor to a particular line in the test.
Boo1mar1s Creates boomars in your script for easy
navigation.
Adanced > Comment
Bloc1
Comments out the current row, or selected rows.
Adanced > ncomment
Bloc1
/emoves the comment formatting from the current
or selected rows.
8/14/2019 QTP Complete Reference for CS.doc
27/222
Adanced > 'ndent %ndents the step according to the tab spacing definedinthe 1ditor Options dialog box.
Adanced > Outdent Outdents the step )reduces the indentation+according to the tab spacing defined in the
1ditor Options dialog box.
Adanced > *o to
Function .e(inition
*avigates to the definition of the selected function.
Adanced > Complete
3ord
Completes the word when you type the beginning ofa (2"cript method or object.
Adanced > Ar$ument
'n(o
&isplays the syntax of a method.
Adanced > Apply 43it!4
to Script
enerates 3it!statements for the action displayed
in the 1xpert (iew, and enables %ntelli"ensewithin 3it!statements.
Adanced > "emoe
43it!4 Statements
Converts any 3it!statements in the action
displayed in the 1xpert (iew to regular )single-line+(2"cript statements.
Optional Step %nserts an optional step )a step that is not re3uired tosuccessfully complete a run session+.
.iew menu8T"roug" t"is menu we can launc" and close, active screen,
#ata Table, #ebug viewer, information, missing resources etc.
%nsert Menu8 T"roug" t"is menu user can inserting c"eck points, out put
values, sync"roni%ing points.
In t"is menu step generator available, using t"is user can generate
recordable and non-recordable scripts.
T"roug" insert menu user can insert + Script conditional and loop
statements and transaction points
8/14/2019 QTP Complete Reference for CS.doc
28/222
T"roug" t"is menu we can start normal recording, analog recording
and 7ow levelrecording.
T"roug" t"is menu we can stop recoding, running and also we run tests.
Command Function
"ecord "tarts a recording session.
"un "tarts a run session from the beginning or from
the line at which the session was paused.
Stop "tops the recording or run session.
"un Current Action /uns only the active action.
"un (rom Step "tarts a run session from the selected step.
+aintenance "un +ode "tarts a run session during which the#aintenance /un #ode wi$ard opens for steps
that failed because an object was not found in
the application)if applicable+.
pdate "un +ode "tarts a run session to update
test objectdescriptions and other options )ifapplicable+.
Analo$ "ecordin$ "tarts recording in Analo$ "ecordin$mode.
Low Leel "ecordin$ "tarts recording in LowLeel "ecordin$mode.
"ecord and "un Settin$s Opens the /ecord and /un "ettings dialog box,
enabling you to define browser preferences for
recording and running your test.
)rocess *uidance List ists the processes that are available for the
current document type and for the currently
loaded Quic!est add-ins, enabling youto open them.
"esults 1nables you to view results for a test run
session.
Resources Menu8
T"is menu provides ob'ect repository and recovery scenarios options.
8/14/2019 QTP Complete Reference for CS.doc
29/222
8/14/2019 QTP Complete Reference for CS.doc
30/222
8/14/2019 QTP Complete Reference for CS.doc
31/222
QTP Test Process )tages of QTPTesting Process
:> Planning
o $naly%ing t"e $/To $utomation Test Plan Generation
o $utomation ramework Implementationo GeneratingASelecting Test cases for $utomationo (ollecting Test #atao QTP Tool Settings (onfiguration
=> Generating Tests
o ecordingo ?eyword driven met"odology
o #escriptive Programming
?> &n!ancing Tests
o Inserting ("eckpointso Inserting &utput valueso $dding (ommentso Sync"roni%ationo Parameteri%ation
o Inserting low (ontrol Statementso (alling /ser defined functions andAor eusable $ctions
o Generating Steps t"oug" Step Generatoro Inserting Transaction Pointso egular !xpressions
@> e#ugging Tests
o #ebug (ommands 6 reak Pointso Step by step executiono 0atc"ing +ariables
o ("anging values of variables
> Running Tests
o 8ormal !xecutiono atc" !xecution
o T"roug" $&) Scriptingo Tests unning t"roug" frameworko Sc"eduled !xecution
8/14/2019 QTP Complete Reference for CS.doc
32/222
> Analy(ing Results
o QTP esult windowo #efining our own esultso !xporting esults
o #eleting esults
> Reporting efects
o )anual #efect eportingo Tool based #efect eportingo 0orking wit" Quality (enter-----------------------------------------------------------
Types of)tatementsin QTP Test + Test )cript
i> eclarations "#$ect calls
!xCB #ialog
8/14/2019 QTP Complete Reference for CS.doc
33/222
vii>.B scriptot!erstatements
!xamplesB&ption !xplicit0ait Test Recording Process
It is a Process of ecording user operations on $/T Running +&,ecution Process
#uring unning QTP reads statements one by one andgets &b'ect Information from t"e &b'ect epository, based on t"at
Information performs operations on $/T.
c> Recording Modes
QTP "as ecording )odes to generate Tests A Test Scriptsi> 2ormal Recording
It records /ser )ouse and ?eyboard operations on $/T wit" respect toob'ects, but unable to record continuous mouse operations like #igitalSignatures, grap"s, paints etc.
#uring recording QTP generates +bScript statements in Test Pane,Simultaneously it stores ob'ects information into ob'ect repository.
2avigation8$utomationLecord &r
Select ecord option on automation toolbar &r /se s"ort cut key
8/14/2019 QTP Complete Reference for CS.doc
34/222
.It s"ows ecord and un Settings, Select type of !nvironment
Analog Recording8
It records t"e exact mouse and keyboard operations. 0e can use t"ismode for recording continuous mouse operations. It is not useful forrecording normaloperations w"y because it does not generate steps foreac" operation, generates total user actions in a Track ile. T"e Track fileis not editable.
2avigation8
C.?eep tool under recording mode:.$utomation L$nalog ecording&/se S"ort cut ?ey
8/14/2019 QTP Complete Reference for CS.doc
35/222
8/14/2019 QTP Complete Reference for CS.doc
36/222
9 It is used for $naly%ing t"e $/T in t"e initial stage to find out weat"er
t"e QTP tool is ecogni%ing all of our $pplication &b'ects or not
9 It is easy to create Tests A Test Scripts
9It is used for fre4uently c"anging /I
8/14/2019 QTP Complete Reference for CS.doc
37/222
T"is "elps make bot" test creation and maintenance easier over time.Configuring Quic'Test According to our Testing 2eeds
$fter we set up t"e test automation infrastructure, we needto configure QuickTest to use t"is infrastructureB
#efine your global testing preferences.
0e need to specify configuration settings t"at affect "ow we createand run tests in generalRt"ese settings are not test-specific.
Building our Tests
0e can create tests t"at are as simple or complex as needed. Ingeneral, it is best to create tests and actions t"at c"eck 'ust one or afew simple functions or complete atransaction rat"er t"an creatinglong tests and actions t"at perform several complex tasks or t"atperform many tasks.
0e may perform t"e following tasks w"en creating tests and teststepsB
(reate new tests, if needed. To do so, select ile L 8ew L Test.
(reate t"e re4uired actions.
$ssociate our ob'ect repositories wit" t"e relevant actionsT"is enables us to insert steps t"at perform operations on t"oseob'ects.$ssociate our function libraries wit" t"e relevant tests. T"is enables usto use our special keywords in any of t"e associated tests.
Obect Re!ository"#$ectRepository8
It is a storage place of QTP w"ere ob'ects information can be stored andit also acts as interface between t"e Test script and t"e $/T in order toidentify t"e ob'ects during execution.
"#$ect8&b'ect is somet"ing, w"ic" "as structure and properties.
)oftware o#$ects8
8/14/2019 QTP Complete Reference for CS.doc
38/222
8/14/2019 QTP Complete Reference for CS.doc
39/222
/ser can add some more ob'ects to 7ocal repository
/ser can perform rename, delete operations on local repository. $s it isQTP internal file user no need to save modifications.
)!ared Repository8
/ser
8/14/2019 QTP Complete Reference for CS.doc
40/222
8/14/2019 QTP Complete Reference for CS.doc
41/222
2ote8$fter merging also, source repository files will be available, if we donot want source files we can delete.
efining 2ew Test "#$ects
8avigationB &b'ectL#efine new test ob'ect LSelect
!nvironmentLSelect (lass oft"e ob'ectL!nter name of t"e ob'ectL(lick$ddLclick closeLSelect ob'ectLselect property nameLenter value
8/14/2019 QTP Complete Reference for CS.doc
42/222
0e can export our repository file to an xml file.
8avigationB ile Lexport Test ob'ects to @)7 !nter t"e file name and Savewit" xml extension.
%mporting Repository from3M4 file7
0e can import @)7 file to our repository.
8avigationB ileLimport from @)7 Lbrowse pat" of t"e @)7 file Lit loadsob'ects.
8oteB T"e purpose of t"is feature is !diting ob'ects information outside oft"e QTP
8avigationB esource menuLob'ect repository
8/14/2019 QTP Complete Reference for CS.doc
43/222
= creation time
8/14/2019 QTP Complete Reference for CS.doc
44/222
$s QTP is a I-tier
8/14/2019 QTP Complete Reference for CS.doc
45/222
rowser #lclic'It #ouble clicks t"e ob'ect.
> )et)et"odIt can be used in t"ree ways.
a. or setting t"e value of an edit boxSyntaxB &b'ect 1ierarc"y. S!T +alueU!xB #ialog
8/14/2019 QTP Complete Reference for CS.doc
46/222
!xB rowser Getitemscount8It returns number of items in a combobox.SyntaxB +ariableOob'ect "ierarc"y.getitemscount!xB xO0indow
8/14/2019 QTP Complete Reference for CS.doc
47/222
msgbox datatable.GetS"eet(ount
8/14/2019 QTP Complete Reference for CS.doc
48/222
!xB
&ption explicit #im a, b, c
aOdatatable.+alue
8/14/2019 QTP Complete Reference for CS.doc
49/222
8/14/2019 QTP Complete Reference for CS.doc
50/222
SyntaxB datatable.!xportS"eet Pat" of ileU, S"eet 8ame ASource S"eetU
!xB datatable.!xportS"eet Bgcreddy.xlsU, :
**********************ata riven Testing for 4ogin "peration usingata Ta#lemet!ods
#atatable.$ddS"eet N7oginN#atatable.ImportS"eetN(B#ocuments andSettingsgcr#esktopgcreddy.xlsN,C,owsXcountO#atatable.GetS"eet
8/14/2019 QTP Complete Reference for CS.doc
51/222
!ntering A Providing ob'ects information directly into t"e test script iscalled #escriptive Programming.
In t"is met"od of script creation, we no need to "ave &b'ect
epositories.
Advantages8
a= #escriptive Programming based Test scripts are faster in executiont"an epository based Test scripts.
b= Scripts are portable
8/14/2019 QTP Complete Reference for CS.doc
52/222
2ote=8If we feel one property information is not sufficient for recogni%ing t"eob'ect uni4uely, t"en we can provide more properties informationby separating wit" commas.
2ote ?8
If we want to get ob'ects information
8/14/2019 QTP Complete Reference for CS.doc
53/222
!xecuteile Pat" of t"e 7ibrary file
8/14/2019 QTP Complete Reference for CS.doc
54/222
#ialog
8/14/2019 QTP Complete Reference for CS.doc
55/222
:;. Image c"eckpoint::. Table c"eckpoint
8ote CB rom E to CC c"eckpoints are only for 0eb.
8ote :B rom J to CC c"eckpoints are "idden c"eckpoints, we can insert
t"esec"eckpoints t"roug" standard c"eckpoint.
:7 )tandard C!ec'point8
It c"ecks ob'ect property values. 0e can use t"is c"eckpoint for c"ecking
anyproperty value.
2avigation for %nserting standard c!ec'point
?eep tool under recording mode L place cursor in desired location L Insert L c"eckpoint L Standard c"eckpoint L S"ow t"e ob'ect L click okay L select property and
enter expected results 6 click &k and stop ecording.
2avigation for &diting standard c!ec'point
Select ("eckpoint statement and rig"t click L c"oose c"eckpoint properties option Lmodify t"e value L click &k.
2avigation for eleting standard c!ec'point8
Select ("eckpoint statements and rig"t click L c"oose delete option.
%nserting )tandard c!ec' points t!roug! active screen8
+iew L $ctive Screen Lplace cursor in desired location LPlace mouse pointer on
active screen 6 rig"t clickL c"oose insert standard c"eckpoint option L click ok Lenter expected result L click ok
8oteB Inserting Standard c"eck points t"roug" keyword view same as in expertview.
2ote80e can insert standard c"eckpoints in ways.
a7 T"roug" expert view,
#7 T"roug" keyword view,c7 T"roug" $ctive screen.
=> Te,t C!ec'point8
It ("ecks ob'ectMs text property value in different ways.
2avigation8
8/14/2019 QTP Complete Reference for CS.doc
56/222
?eep tool under ecording mode LInsert menu L c"eckpoint L Text c"eckpoint LS"ow t"e ob'ect L click ok L Select options
(Match case; ignore spaces# e+act match# te+t not displa"ed.$
0e can select one or more options L click ok 6 stop ecording.
?> Te,t Area C!ec'point8
It c"ecks t"e text area present in t"e application.
8avigationB
?eep tool under ecording mode L Insert menuL ("eckpoint L Text area c"eckpointL )ark t"e area of text L select one or more options
(Match case# ignore spaces# e+act match# te+t not displa"ed.$
(lick ok and stop recording.
@7 Bitmap c!ec'point8
It compares bitmaps5 we can compare complete bitmaps as well as part of t"ebitmaps.
2avigationB
?eep tool under ecording mode L Insert menu L ("eckpoint L itmap c"eckpoint
L s"ow t"e itmap Lclick ok Lselect c"eck only selected areaU option if we want tocompare part of t"e bitmap L click ok Lstop recording.
7 ata#ase c!ec'point8
It c"ecks (ontent of t"e back end #atabase.
2avigation8Insert L c"eckpoint L #atabase c"eckpoint Lc"oose specify SQ7statement manuallyU option Lclick next L click create L select mac"ine data source
L Select #S8
8/14/2019 QTP Complete Reference for CS.doc
57/222
Configuring accessi#ility c!ec'point8
Tools menuL options Lweb L advanced L c"eckAunc"eck items L click apply L click
ok
%nvigilation8?eep tool under recording mode wit" web environmentLinsertLc"eckpointLaccessibility c"eckpointLs"ow t"e webpageLclick okLclick
okLstop recording.
esult (riteriaB
a= If item is available but not according to 0( rules t"en fail.b= If an item is available, according to 0( rules t"en Pass.
c= If an item is not available t"en result would be pass
7 3M4C!ec' pointDfromApplication>
It c"ecks content of t"e @)7 file.
8avigationB?eep tool under ecording mode in web environment L insert menu L c"eckpoint
8/14/2019 QTP Complete Reference for CS.doc
58/222
It c"ecks Image property values.
2avigation8?eep tool under ecording mode wit" web environment L Insert menu L c"eckpointLstandard c"eckpoint L s"ow t"e image L select image L click ok L click ok Lstop
recording.
::7Ta#le c!ec'point8
It c"ecks content of t"e web tables.
8avigationB ?eep tool under ecording mode under web environment L Insert menuL c"eckpoint L standard c"eckpoint Ls"ow t"e web table L click ok Lstop
recording.
%nserting "utput .alues
It is a step in w"ic" one or more values are captured during test execution.
T"e values can later be used as input at a different point in t"e run session or we can
use as input for anot"er test.
It is stored in run time data table5 it is located in QTP result window and can be
retrieved later.
Types of "utput .alues8
:7 Standard output value
=7 Text output value
?7 Text area output value
@7 #atabase output value
7 @)7 output value
8/14/2019 QTP Complete Reference for CS.doc
59/222
8/14/2019 QTP Complete Reference for CS.doc
60/222
we can use @)7 output values to output t"e values of @)7 elements in
@)7documents.
8avigationB ?eep tool under recording mode wit" web environment L Insert menu L
output value L @)7 output value from application L S"ow t"e @)7 document L
select elements L click ok Lstop recording.
> 3M4 output .alue D*rom Resource>8
0e can use @)7 output values to output t"e values of @)7 elements in
@)7documents.
2avigation8
Insert menu Loutput valueL @)7 output value from resource L browse pat" of t"e
@)7 file L click ok L select elements Lclick ok.Para%eteri'ationPassing parameters, t"roug" t"is we can pass multiple values.
0e use parameteri%ation in #ata #riven Testing.
ata riven TestingB Testing t"e Same operation wit" multiple setsof test data.
Types of Parameteri(ationB 0e can parameteri%e testsin several ways in QTP
C. T"roug" 7oop Statements:. #ynamic Test #ata Submission. T"roug" #ata Table. etc"ing Test #ata directly from !xternal files
8/14/2019 QTP Complete Reference for CS.doc
61/222
8/14/2019 QTP Complete Reference for CS.doc
62/222
ii= (lick on column "eaderLenter t"e name of t"e field
8/14/2019 QTP Complete Reference for CS.doc
63/222
(onnecting Test #ata to QTP Test as above and run t"e test.
d7 %mporting test data from ata #ases8
T"roug" #ata table we can import Test #ata from #ata bases, but first
we "ave to create Aget t"e #S8
8/14/2019 QTP Complete Reference for CS.doc
64/222
xOmyfile.readlineSOsplit
8/14/2019 QTP Complete Reference for CS.doc
65/222
Set inputdataO(reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
66/222
Place cursor in desired locationLkeep tool under recordingmodeLInsert menuLSync"roni%ation point Ls"ow t"e ob'ect LclickokLselect property name 6 +alue
8/14/2019 QTP Complete Reference for CS.doc
67/222
:= It is recommended, w"enever we want to observe t"e Test !xecution
process= 8o ob'ect reference re4uired to insert wait statements
= It is useful to make QTP capture values and screen s"ots during test
execution
%nserting Transaction Points
QTP is providing a /tility ob'ect called )ervicesfor measuring transaction time
Suppose, we want to measure "ow muc" time t"at one test or part of t"e test is
taking for executionArunning, we can measure using t"ese transaction point
8/14/2019 QTP Complete Reference for CS.doc
68/222
InteractiveQuickTest Professionalsamplesflig"tappN,NopenN#ialog
T"e Step Generator enables us to add steps by selecting from a range of
context-sensitive options and entering t"e re4uired values. In t"e
Step Generatordialog box we can define steps t"at useB
Test ob'ect operations
8/14/2019 QTP Complete Reference for CS.doc
69/222
efore we open t"e Step Generator to define a new step, we first
select w"ere inour test t"e new step s"ould be inserted.
$fter we open t"e Step Generator, we first select t"e category for t"e
step operation
8/14/2019 QTP Complete Reference for CS.doc
70/222
8/14/2019 QTP Complete Reference for CS.doc
71/222
. (ommand
8oteB T"roug" #ebug +iewer Pane, 0e can watc" variables w"et"er t"e variables
aretaking correct values or not at a specific point of time. 0e can c"ange +alues of+ariables temporarily.
!x B
#im x,y,%
xOC;
yO:;
%Oxy
msgbox %
msgbox N1elloN
xOD
yOE>
%Ox*y
msgbox %
msgbox Nbye byeN
8avigationB +iew menu L #ebug +iewer L /se step into feature.
naly'ing Test Results Re!orting
$naly%ing t"e Test esult is not a responsibility of QTP. $fter unning
Tests, /ser
8/14/2019 QTP Complete Reference for CS.doc
72/222
c= #one
d= 0arning
efining our own Result8Generally QTP provides, test results, if we use 4tp tool features like
c"eckpoints. suppose if we use flow control statements
8/14/2019 QTP Complete Reference for CS.doc
73/222
8/14/2019 QTP Complete Reference for CS.doc
74/222
9 $o!ying an ction
9 Ma&ing an ction Reusable:4on Reusable
Creating an Action:"nsert;call to new action;enter na%e o# the action;clic& o&(te!s2
3. $reate re
8/14/2019 QTP Complete Reference for CS.doc
75/222
8/14/2019 QTP Complete Reference for CS.doc
76/222
msgbox x 3 &utputB bad
valONJ:>H>>HNxOig"t>H,D=msgbox x 3 &utputB >>H
valO]C;-C;-C;]xOig"t Mid function
eturns a specified number of c"arectors of a given string
!xampleB
#im val,xvalON1yderabadNxO)id>HN
xO)id>H
valON1J:yderabadNxO)id
8/14/2019 QTP Complete Reference for CS.doc
77/222
xO)idH>>H,D=msgbox x 3 &utputB H>>H
valO]C;-C;-C;]
xO)id )trReverse
retuns reverse value of a string
!xampleB
#im val,xvalON1yderabadNxOStreverse
8/14/2019 QTP Complete Reference for CS.doc
78/222
8/14/2019 QTP Complete Reference for CS.doc
79/222
(overts /pper case values into 7ower case
#im val,xvalON1V#!$$#N
xO7case 0case function
(overts 7ower case values into /pper case
!xampleB
#im val,xvalON1V#!$$#NxO/case
8/14/2019 QTP Complete Reference for CS.doc
80/222
xO/case
8/14/2019 QTP Complete Reference for CS.doc
81/222
Types of &nvironment varia#les8
C. Built in varia#les8T"ese are system defined variables, we can access
from all tests but t"ese are designed as read only.
:. 0ser defined varia#les8+ariables t"at we predefine in t"e activeexternal environment variables file. 0e can create as many files as we
want and we can c"ange values of variables.
0sage of environment varia#les8
SyntaxB
+ariable O !nvironment
8/14/2019 QTP Complete Reference for CS.doc
82/222
ile L settings L!nvironment L select variable type as user defined
L c"eck load variables and values from t"e external fileU L browse pat"
of t"e xml file L click apply 6 ok.
&r
1e can load environment file directly
!nvironment.loadfromfileUpat" of t"e xml fileU
0sage of user defined &nvironment varia#les8
$ssociate environment file to current testB
+ariable O !nvironment
8/14/2019 QTP Complete Reference for CS.doc
83/222
0e can define a regular expression for a constant value, a #ata
Table parameter value, an !nvironment parameter value, or a property
value in #escriptive programming.
0e can define a regular expression in standard c"eckpoint to verifyt"e property values of an ob'ect5 we can set t"e expected value of an
ob'ect3s property as aregular expression so t"at an ob'ect wit" a varying
value can be verified.
0e can define t"e text string as a regular expression, w"en creating a
text c"eckpoint to c"eck t"at a varying text string is displayed on
our application,
or @)7 c"eckpoints we can set attribute or element values as regular
expressions.
1ays of Regular &,pressions8
a> Bac'slas! C!aracter8
$ backslas" Matc!ing Any )ingle C!aracter in a 4ist8
S4uare brackets instruct QTP to searc" for any single c"aracter wit"in a
list of c"aracters.
!xB
To searc" for t"e date CHE>, CHEH, or CHEJ, enterB
8/14/2019 QTP Complete Reference for CS.doc
84/222
CHE^>HJ_
d> Matc!ing Any )ingle C!aracter 2ot in a 4ist8
0"en a caret Matc!ing ero or "ne )pecific C!aracter8
$ 4uestion mark
8/14/2019 QTP Complete Reference for CS.doc
85/222
8/14/2019 QTP Complete Reference for CS.doc
86/222
or exampleB
^a-%$-\_*
To matc" any number between ; and C:;;, we need to matc" numbers
wit" C digit, : digits, digits, or digits between C;;;-C:;;.
T"e regular expression below matc"es any number between ; and C:;;.
Matc! *ile 2ames in a irectory againstRegular &,pression
Set ob'S O (reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
87/222
ob'!.Ignore(ase O alse
ob'!.Pattern O 0Script.$rguments
8/14/2019 QTP Complete Reference for CS.doc
88/222
0e can manage t"e virtual ob'ects defined on our computer using t"e +irtual
&b'ect )anager.
2avigation8
Select Tools )enu Go to +irtual ob'ects
Select Y8ew +irtual &b'ectM option
(lick 8ext
)ark t"e area in t"e $pplication wit" "elp of mark ob'ect button
(lick next
Select one of t"e following options
o !ntire Parent "ierarc"y
o Parent only
(lick on 8ext
Specify t"e #esired ob'ect name Specify t"e #esired collection name
(lick finis"
.irtual "#$ect Manager8
+irtual ob'ect )anager feature enable us to create and manage +irtual
&b'ects
Batc! Testing or Batc! &,ecution
!xecuting a group of Tests or series of tests at a time is known as atc"Testing or atc" !xecution. or performing atc" Testing, QTP isproviding a separate Tool called Test atc" unner.
)teps for Batc! Testing8
C=. (reate Individual Tests and un once.
:=. &pen 3Test batc" unner3 Tool and orm atc"es.
= Provide permission to 3Test batc" unner3 to run tests
=. un or !xecute Test atc"es from Test atc" unner.
D= +iew Test wise esult in 3Test esult +iewer3.
8/14/2019 QTP Complete Reference for CS.doc
89/222
8/14/2019 QTP Complete Reference for CS.doc
90/222
8/14/2019 QTP Complete Reference for CS.doc
91/222
$ step in your test does not run successfully t"en Test un !rror
can be raised.
2avigation 8
esources )enu -Lecovery Scenario )anager - L8ew -L8ext -LSelectTestrunerror0indowU as Trigger event -L8ext -Lselect any error o -L8ext -L8ext-LSelect function call as ecovery&peration -L8ext ^&pen 8otepad -LSave empty file wit" .vbs extension_-Lrowset"e .vbs fie pat" -L8ext -L/nc"eck $dd anot"er ecovery &peration-L8ext -LSelect Post-ecovery Test un &ption ^epeat current step and continue,
Proceed to8ext step, Proceed to 8ext $ction, Proceed to next test iteration, estart
current testSelect &ption 8ext !nter Scenario 8ame 8ext run, Stopt"e Test un_ ecord re4uired ecovery &peration ^(lickSave t"e scenario wit" .4rsUinis" (lick unSave t"e library file ok, (lick (ancel_ take t"e script intofunction
Div> "#$ect )tate7
T"e property values of an ob'ect in your application matc"
specified values. Vou can specify property values for eac" ob'ect in t"e
"ierarc"y.
2avigation8
esources )enu -L ecovery Scenario )anager -L 8ew -L 8ext -L
Select &b'ect state
0indowU as Trigger event -L 8ext -L (lick on 1and Icon -L S"ow ob'ectwit" "and icon
-L 8ext -L 8ext-Lselect ob'ect property wit" value
8/14/2019 QTP Complete Reference for CS.doc
92/222
Select Post-ecovery Test un &ption ^epeat current step and continue,
Proceed to
8ext step, Proceed to 8ext $ction, Proceed to next test iteration, estart
current test
run, Stop t"e Test un_ -L 8ext-L !nter Scenario 8ame -L 8ext -L
Select &ption -Linis" -L Save t"e scenario wit" .4rsU -L ecord re4uired ecovery
&peration ^(lick
ok, (lick (ancel_ take t"e script into function -L Save t"e library file -L
(lick un
*ile )ystem "perations
*ile )ystem8
Its an operating system feature, it allows users to create, modify,
view and delete5 drives,folders and files
+ Script is providing an ob'ect called scripting.filesystemob'ect
and some met"ods for performing file systems operations
*ile )ystem "#$ect Model8
T"e ile System &b'ect
8/14/2019 QTP Complete Reference for CS.doc
93/222
full-featured database. In t"is case, storing our data in a text file or
binary file is t"e most efficient solution.
T"e S& model, contained in t"e Scripting type library
8/14/2019 QTP Complete Reference for CS.doc
94/222
3(reating an $utomation &b'ect in ileSystem class
3&pening t"e !xternal Test #ata file using t"e &b'ect
3ead t"e #ata 6 Split t"e #ata
3Generating t"e 7ogin &peration
3Pass Parameters
3********************************************************
#im ob'so, myile, my7ine, myield
Set ob'soO(reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
95/222
8/14/2019 QTP Complete Reference for CS.doc
96/222
5.@(erverAEour(erver4a%eDatabaseAEourDatabase4a%eTrusted$onnecti
onATrue@
MS Access connection strings
M( ccess ODB$ connection strings(tandard (ecurity2
@DriverA
Microso#tccessDriver/H.%db0CDBQA$2I!!3IEourDatabase4a%e.%db>idAEou
r>serna%ePwdAEourPassword@
1or&grou!2
@DriverAMicroso#t ccess Driver /H.%db0C
DbidAEour>serna%e
PwdAEourPassword@
M( ccess O?7 DB OleDb$onnection /.47T #ra%ewor&0 connection strings
O!en connection to ccess database2
@ProviderAMicroso#t.Jet.O?7DB..L Data
(ourceAc2I!!3IEourDatabase4a%e.%db >ser "dAad%in PasswordA@
O!en connection to ccess database using 1or&grou! /(yste% database02
@ProviderAMicroso#t.Jet.O?7DB..L Data (ourceAc2I!!3IEourDatabase4a%e.%db Jet O?7DB2(yste% DatabaseAc2I!!3IEour(yste%Database4a%e.%dw@
O!en connection to !assword !rotected ccess database2
@ProviderAMicroso#t.Jet.O?7DB..L Data
(ourceAc2I!!3IEourDatabase4a%e.%db Jet O?7DB2Database
PasswordAEourPassword@
O!en connection to ccess database located on a networ& share2
@ProviderAMicroso#t.Jet.O?7DB..L Data(ourceAII(erver4a%eI(hare4a%eI(har
ePathIEourDatabase4a%e.%db@
O!en connection to ccess database located on a re%ote server2
@ProviderAM( Re%ote Re%ote (erverAhtt!2::Eour-Re%ote-(erver-"P Re%ote
ProviderAMicroso#t.Jet.O?7DB..L Data
(ourceAc2I!!3IEourDatabase4a%e.%db@
8/14/2019 QTP Complete Reference for CS.doc
97/222
MySQ connection strings
My(Q? ODB$ connection strings
O!en connection to local My(Q? database using My(Q? ODB$ 6.3 Driver
@ProviderAM(D(Q? DR"+7RAMy(Q? ODB$ 6.3DriverC (7R+7RA localhost
DTB(7AEourMy(Q?Database >"DA Eour>serna%eP((1ORDAEourPassword OPT"O4A6@
My(Q? O?7 DB OleDb$onnection /.47T #ra%ewor&0 connection strings
O!en connection to My(Q? database2
@ProviderAMy(Q?ProvData (ourceAEourMy(Q?Database>ser
"dAEour>serna%e PasswordAEourPassword@
Oracle connection strings
Oracle ODB$ connection stringsO!en connection to Oracle database using ODB$@DriverA Microso#tODB$#orOracleC(erverAEourOracle(erver.world>idAEour>serna%ePwdAEour
Password@Oracle O?7 DB OleDb$onnection /.47T #ra%ewor&0 connection stringsO!en connection to Oracle database with standard security23. @ProviderAM(DORData (ourceAEourOracleDatabase>ser"dAEour>serna%ePasswordAEourPassword@5. @ProviderAOraO?7DB.OracleEourOracleDatabase>ser"dAEour>serna%ePasswordAEour
Password@
O!en trusted connection to Oracle database@ProviderA OraO?7DB.OracleData(ourceAEourOracleDatabaseO(uthentA3@
A"M)criptingDAutomation"#$ect Model>
"#$ect Model8
$n ob'ect model is a structural representation of software ob'ects
8/14/2019 QTP Complete Reference for CS.doc
98/222
QTP $utomation ob'ect model provides ob'ects, met"ods and properties
t"at enable us to control QTP from anot"er application.
0e can use Scripting languages or programming languages suc" as
+script, 2ava script or +(, .8et for automating QTP operations.
!xampleB
:> 1rite an A"M )cript to launc! QTP ToolI &,ecute Tests and to
close t!e QTP Tool
option explicit
#im 4t$pp
Set 4t$ppOcreateob'ect 1rite an A"M script to e,ecute series of tests
#im ob'so,ob'Qtp,myile,i,gcreddy
Set ob'Qtp O (reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
99/222
#o /ntil myile.$t!nd&fStream OTrue
testurl O myile.ead7ine
ob'Qtp.&pen gcreddy
ob'Qtp.Test.un
ob'Qtp.Test.(losei O iC
7oop
ob'Qtp.Quit
Set ob'Qtp O 8ot"ing
ynamic !andling of o#$ect Repositories
7oading repositories during running, finding pat" of t"e repositories and
removing repositories is called #ynamic 1andling of &b'ect epositories.
/sing t"is feature we can increase QTP performance. To do t"is, QTP is
providing an ob'ect called RepositoriesCollectionU.
)ynta,for 4oading a Repository8
epositories(ollection.$dd Pat" of t"e epository ileU
)ynta, for finding Position of t!e Repository8
+ariableOepositories(ollection.ind
8/14/2019 QTP Complete Reference for CS.doc
100/222
posOepositories(ollection.ind
8/14/2019 QTP Complete Reference for CS.doc
101/222
For 7ach oDrive in colDrivesMsgBo8 @Drive letter2 @ oDrive.Drive?etter4e8t
-# .etting a!ailable space on a Disk Dri!e
(et oF(O A $reateObect/@(cri!ting.File(yste%Obect@0(et oDrive A oF(O.=etDrive/@$2@0MsgBo8 @vailable s!ace2 @ oDrive.vailable(!ace
Flat File (cri!tsComputer *ile )ystemIt is a feature of t"e &perating System, used to(reateA)odifyAviewAdelete #rives, olders and iles
") istri#ution&perating System and &t"er /tilities
*ile)ystem"#$ect
+Script "as Provided *ile)ystem"#$ectto perform file systemoperations t"roug" scripting
#im ob'so3(reating an $utomation &b'ect in ile System class, t"at can be usedto perform&perations on (omputer ile System
Set ob'soO(reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
102/222
Set ob'S& O (reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
103/222
3Pass Parameters3*************************************************
#im ob'so, myile, my7ine, myieldSet ob'soO(reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
104/222
E>C!ec'ingweat!er t!e *ile is availa#le or notI if availa#le delete
t!e *ile
str#irectoryON!BNstrileONgcr.txtN
Set ob'S& O (reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
105/222
sile8ameON!Bgcr.txtNsStringONgcreddyN(onst &X!$#I8G O C#im oso, oTxtile, seadTxt, oeg!x, o)atc"es
Set oso O (reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
106/222
(onst oreading O C
Set ob'S& O (reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
107/222
8/14/2019 QTP Complete Reference for CS.doc
108/222
myile.0rite7ine Nutton 8amesN
myile.0rite7ine N----------NSet outtonO#escription.(reateoutton elete a Te,t file if it is an empty file
#im ob'so, ilePat"ilePat"ON(B#ocuments and Settingsgcreddy#esktopabc.txtNSet ob'soO(reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
109/222
ob'(on.ProviderO &,porting ata from a ata#ase to an &,cel)!eet
C= #im con,rs
:= Set conOcreateob'ect= Set exOcreateob'ect
8/14/2019 QTP Complete Reference for CS.doc
110/222
8/14/2019 QTP Complete Reference for CS.doc
111/222
0script.!c"o ob'ecordSet.ecord(ount
> "pen a ata#ase 0sing a )2
(onst ad&penStatic O (onst ad7ock&ptimistic O
Set ob'(onnection O (reate&b'ect "pen Two Recordsets
(onst ad&penStatic O (onst ad7ock&ptimistic O
Set ob'(onnection O (reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
112/222
8/14/2019 QTP Complete Reference for CS.doc
113/222
8/14/2019 QTP Complete Reference for CS.doc
114/222
8/14/2019 QTP Complete Reference for CS.doc
115/222
!nd If
8ext
ob's.)ove8ext
7oop
ob'!xcel.QuitSet ob'!xcelO8ot"ing
ob's.(lose
ob'(on.(lose
Set ob'sO8ot"ing
Set ob'(omO8ot"ing
QTP ata#ase )cript &,amples-----------------------------------------------------------------------------
:> ata riven Testing for 4ogin "peration #y *etc!ing Test atadirectly *rom a ata#ase
&ption !xplicit
#im ob'(onnection, ob'ecordSet
'Creating an Automation Object in Database Connection Class,
that can be used to connect to Databases
Set ob'(onnectionO(reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
116/222
0indow
8/14/2019 QTP Complete Reference for CS.doc
117/222
ob'(onnection.ProviderO &,port ata from a ata#aseTa#leto an&,cel fileD=nd )!eet>
&ption !xplicit#im ob'(onnection, ob'ecordset
#im ob'!xcel, ob'0orkbook, ob'0orks"eet, i
Set ob'(onnection O (reateob'ect
8/14/2019 QTP Complete Reference for CS.doc
118/222
ob'ecordset.&pen NSelect $gent, Password from 7oginN, ob'(onnection
i O : 3ows
#o /ntil ob'ecordset.!&
ob'0orks"eet.cells
8/14/2019 QTP Complete Reference for CS.doc
119/222
#o /ntil ob'ecordset.!&
myile.0rite7ine ob'ecordset.ields &,port ata from a Te,t *ile to a ata#aseTa#le
&ption !xplicit
#im ob'(onnection, ob'(ommand
#im ob'so,myile,my7ine,myield,S8&,$gent,Password
Set ob'(onnection O (reateob'ect
8/14/2019 QTP Complete Reference for CS.doc
120/222
ob'(ommand.$ctive(onnection O ob'(onnection
ob'(ommand.(ommandText O NInsert into 7ogin:
values
8/14/2019 QTP Complete Reference for CS.doc
121/222
8/14/2019 QTP Complete Reference for CS.doc
122/222
8/14/2019 QTP Complete Reference for CS.doc
123/222
Set ob'!xcel O (reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
124/222
ob'!xcel.0orkbooks.&pen
8/14/2019 QTP Complete Reference for CS.doc
125/222
#im ob'!xcel
Set ob'!xcel O createob'ect
8/14/2019 QTP Complete Reference for CS.doc
126/222
>= System/til.un $pplication#ir 6 $pplicationPat"
H= !nd IfJ= #ialog= eporter.eport!vent ;,NsdN,NPassNH= Invokeapplication N(BProgram iles)ercury InteractiveQuickTestProfessionalsamplesflig"tappflig"ta.exeNJ= !nd IfC;= #ialog
8/14/2019 QTP Complete Reference for CS.doc
127/222
CJ= #ialog
8/14/2019 QTP Complete Reference for CS.doc
128/222
8/14/2019 QTP Complete Reference for CS.doc
129/222
CJ= else
:;= eporter.eport!vent C,NesN,N/pdate &rder utton !nabledN:C= !nd If::= If aoOTrue T"en:= eporter.eport!vent ;,NesN,N/pdate &rder utton !nabledN
:= else:D= eporter.eport!vent C,NesN,N/pdate &rder utton #isabledN
:E= !nd If
> Price ConsistencyI %n*lig!t Reservation
8/14/2019 QTP Complete Reference for CS.doc
130/222
8/14/2019 QTP Complete Reference for CS.doc
131/222
available or not in ly ToB combo box, like t"is select all items one by one
in ly rom and verify weat"er selected items available or not in ly To.=
C= &ption explicit:= #im 4tp,flig"tXapp,f,t,i,',x,y
= If 8ot 0indow= !nd If:H= 8ext:J= 8ext
E> .erify "rder 2o &ntry in *lig!t Reservation7
8/14/2019 QTP Complete Reference for CS.doc
132/222
C= If 8ot window
8/14/2019 QTP Complete Reference for CS.doc
133/222
:;> CountI !ow many Buttons and &dit #o,es availa#le in *lig!t
Reservation main window7
C= If 8ot window
8/14/2019 QTP Complete Reference for CS.doc
134/222
8/14/2019 QTP Complete Reference for CS.doc
135/222
;= onoOfalse
C= eporter.eport!vent ;,NesN,NPassN:= else= eporter.eport!vent C,NesN,NailN= !nd If
D= 0indow
8/14/2019 QTP Complete Reference for CS.doc
136/222
Set rowsers O#esktop.("ild&b'ects
8/14/2019 QTP Complete Reference for CS.doc
137/222
k=
Set!ditoxesObrowser
8/14/2019 QTP Complete Reference for CS.doc
138/222
perfumeXN=.0eb!dit
8/14/2019 QTP Complete Reference for CS.doc
139/222
*unction to Clear Coo'iesD>
unction (lear(ookies
8/14/2019 QTP Complete Reference for CS.doc
140/222
8/14/2019 QTP Complete Reference for CS.doc
141/222
Set )yileOfso.&penTextile
8/14/2019 QTP Complete Reference for CS.doc
142/222
#im d
set mwO(reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
143/222
8/14/2019 QTP Complete Reference for CS.doc
144/222
Set ob'(ollOrowser
8/14/2019 QTP Complete Reference for CS.doc
145/222
msgbox Target/rl
rowser
8/14/2019 QTP Complete Reference for CS.doc
146/222
cD.font.colorOvbed
!nd If
rowser ata riven Testing for 4ogin "peration #y fetc!ing from
ane,cel file
http://www.gcreddy.com/2010/04/qtp-scripting.htmlhttp://www.gcreddy.com/2010/03/excel-scripts.htmlhttp://www.gcreddy.com/2010/04/qtp-scripting.htmlhttp://www.gcreddy.com/2010/03/excel-scripts.html8/14/2019 QTP Complete Reference for CS.doc
147/222
#im ob'!xcel, myile, myS"eetSet ob'!xcelO(reate&b'ect
8/14/2019 QTP Complete Reference for CS.doc
148/222
8/14/2019 QTP Complete Reference for CS.doc
149/222
8/14/2019 QTP Complete Reference for CS.doc
150/222
myS"eet.(ells
8/14/2019 QTP Complete Reference for CS.doc
151/222
8/14/2019 QTP Complete Reference for CS.doc
152/222
Set colItems O wms.!xecQuery
8/14/2019 QTP Complete Reference for CS.doc
153/222
strTextONgcreddyN
streadOmyfile.(ontent
Set eg!xpOnew regexp
regexp.ignorecaseOTrue
regexp.globalOTrue
regexp.patternOstrTextSet matc"esOregexp.execute
8/14/2019 QTP Complete Reference for CS.doc
154/222
!nd if!nd unctionmsgbox Generating t!e #asic Test
C= ?eyword driven met"odologyAS"ared ob'ect repositorymet"odAPreparing t"e script manually:= #escriptive programmingAProgrammatic #escriptionsi= !ntering Programmatic #escriptions #irectly into Statements
ii= /sing #escription &b'ects for Programmatic #escriptions
iii= etrieving ("ild &b'ectsiv= /sing t"e Index Property in Programmatic #escriptions
c> &n!ancing t!e Test
a= $dding (ommentsb= (reating ("eckpoints Programmaticallyc= Sync"roni%ationd= Parameteri%atione= Inserting Programmatic statementsf= !n"ancing Tests wit" t"e windows $PI
g= (alling unctions andAor $ctions
d> e#ugging t!e Test
e> Running t!e Test
f> Analy(ing t!e Test Results
8/14/2019 QTP Complete Reference for CS.doc
155/222
g> Reporting efects
a. )anual #efect eportingb. Tool based #efect eportingc. Integration wit" Quality (enter
%%> .B )cript
+bScript is t"e QTP Tool #efault Scripting 7anguage for applayingProgamming 7ogic, so learn +bscript indept".
elow fundamentals 6 eatures are ImportantB
a> .B)cript *undamentals
C=Introductiona= Scripting 7anguages vs. Programming 7anguagesb= asic eatures of +Script
c= 1osting !nvironments 6 Script !nginesd= (rating 6 running a Script
:= +ariables and (onstantsa= +Script data typesb= #eclaring +ariables and &ption !xplicit Statement
c= $ssigning +alues to +ariablesd= Scalar +ariables and $rray +ariables
e= #ynamic $rrays, #imensional $rraysf= (onstantsg= +ariables +s. (onstants
= +Script &peratorsa= &perator Precedenceb= $rit"metic &peratorsc= (omparison &peratorsd= (oncatenation &peratorse= 7ogical &perators
= low (ontrol
8/14/2019 QTP Complete Reference for CS.doc
156/222
f= !xecuting a certain block of statements w"en two A more conditions are
True
8/14/2019 QTP Complete Reference for CS.doc
157/222
"= $lternation and Grouping
i= ackreferences'= egular !xpression Automation *ramewor'
$utomation ramework is a Systamatic $pproac" for $utomating,
SoftwareTesting Process.In order to (reate 6 un Tests as well oragani%ing 6 )anaging$utomation esources, a well defined ramework re4uired.
8/14/2019 QTP Complete Reference for CS.doc
158/222
ramework may vary from one company to anot"er.
elow concepts are important to learnBo Test $utomation ramework
o Types of rameworko ?eyword #riven ramework
o ramework Structureo #eveloping a obust $utomation rameworko Implementing 6 )anaging $utomation esources
%.> C"M+C"M Tec!nologies
0"en working wit" QTP, It is important to know,)icrosoft $pplications likeB
o )S !xcel,o )s 0ord,o &utlook !xpress and
o Internet !xplorer
.> 3M4
@)7 is an extremely popular and useful format. It can be used in severalareas in QTP.
!xBo !xporting ob'ects,
o !nvironment +ariables,o #ata driven Testingo #ata transporting etc.
.%> )Q4
SQ7 ?nowledge is "ig"ly recomendable in order to perform #atabaseTesting using QTPelow concepts are importantBo #atabase undamentals
o #ata (reation 6 !xporting
o #atabase (onnectionso Select Statements
.%%> /TM4I "MIn order to work wit" 0eb based $pplications, It is important to femiliar
wit" web tec"nologies likeBo 1T)7, #1T)7o las"
8/14/2019 QTP Complete Reference for CS.doc
159/222
o 1TTP like Protocols
o #&)
8/14/2019 QTP Complete Reference for CS.doc
160/222
8/14/2019 QTP Complete Reference for CS.doc
161/222
!nd If
Sum O 8umC 8um:
!nd unction
(all Sum
&rr "#$ect Properties and Met!ods
Properties
#escription Property
1elp(ontext Property
8/14/2019 QTP Complete Reference for CS.doc
162/222
1elpile Property
8umber Property
Source Property
Met!ods
(lear )et"od
aise )et"od
f> &,it )tatement
"pen ?; to @; "rders in *lig!t Reservation 1indowI if some
records not availa#le !andle t!e situation
&ption !xplicit
#im &rderX8umber
If 8ot 0indow
8/14/2019 QTP Complete Reference for CS.doc
163/222
eservationsN=.0inutton= It reduces maintenance of cost
H= Implicit Support of #ata Types.
J= 7imited support for /ser Interface #esign
C;= 7imited or 8o Support for Grap"ics #esign
!xample Scripting 7anguages areB
S"ell, Perl, + Script, 2ava Script, Pyt"on, uby, exx, P1P !tc..
Programming 4anguage8
http://www.gcreddy.com/2010/04/vb-script-for-qtp_05.htmlhttp://www.gcreddy.com/2010/04/vb-script-for-qtp_05.html8/14/2019 QTP Complete Reference for CS.doc
164/222
C= It is a compiler based 7anguage.
:= (ompiler converts t"e w"ole program in single s"ort
into mac"ine language.
= It (reates .exe file.
8eed to compile t"e program
= It takes numerous lines of codeD= It increases development time
>= It Increases maintenance of cost
H= !xplicit support of #ata Types
J= ic" support for /ser Interface #esign
C;= ic" Support for Grap"ics #esign
!xample Programming 7anguages areB
(&&7, asic, (, (, +(, + !tc...
+B (cri!t Funda%entals nd Features.B )cript!as several purposes8
a= (lient side scripting in t"e 0eb
8/14/2019 QTP Complete Reference for CS.doc
165/222
f= low (ontrol Statements
8/14/2019 QTP Complete Reference for CS.doc
166/222
a= (omparing values
!xampleB
#im x,y,a
xOC;;
yOC;;aOxOy
)sgbox a 3It returns True
b= 1olding Program esult
!xampleB
(ostOTickets*Price
c= Passing parameters
d= To store data t"at returned by functions
!xampleB
my#ateO8ow Y It returns current data 6 time
e= To "old data
!xampleB
my8ameOUgcreddyU
eclaring .aria#les
0e declare variables explicitly in our script using t"e #im statement,
t"e Public statement, and t"e Private statement.
or exampleB
#im city
#im x
0e declare multiple variables by separating eac" variable name wit"
a comma. or
!xampleB
#im x, y, city, gcreddy
0e can also declare a variable implicitly by simply using its name in
our script. T"at is notgenerally a good practice because we could
misspell t"e variable name in one or more places, causing unexpected
results w"en our script is run. or t"at reason, t"e &ption !xplicit
statement is available to re4uire explicit declaration of all variables.
T"e &ption !xplicit statement s"ould be t"e first statement in our
8/14/2019 QTP Complete Reference for CS.doc
167/222
script.
"ption &,plicit )tatement
orces explicit declaration of all variables in a script.
&ption !xplicit 3 orce explicit variable declaration.
#im )y+ar 3 #eclare variable.
)yInt O C; 3 /ndeclared variable generates error.
)y+ar O C; 3 #eclared variable does not generate error.
2aming Restrictions for .aria#les
+ariable names follow t"e standard rules for naming anyt"ing in
+Script. $ variable nameB
a= )ust begin wit" an alp"abetic c"aracter.#im abc 3ig"t
#im Jab 30rong
#im abJ 3ig"t
b= (annot contain an embedded period.
#im abc 3ig"t
#im ab.c 3worng
#im ab-c 3wrong
#im ab c 3wrong
#im abXc 3ig"t
c= )ust not exceed :DD c"aracters.
d= )ust be uni4ue in t"e scope in w"ic" it is declared.
)cope of .aria#les
$ variable3s scope is determined by w"ere we declare it.
0"en we declare a variable wit"in a procedure, only code wit"int"at procedure can access or c"ange t"e value of t"at variable.
If we declare a variable outside a procedure, we make it recogni%able
to all t"e procedures in our script. T"is is a script-level variable, and it
"as script-level scope.
!xampleB
#im x,y,%
8/14/2019 QTP Complete Reference for CS.doc
168/222
8/14/2019 QTP Complete Reference for CS.doc
169/222
!xampleB
#im $
8/14/2019 QTP Complete Reference for CS.doc
170/222
placed inside t"e parent"eses.
or exampleB#im )y$rray Arit!metic "perators8
&perator #escription
C= !xponentiation &perator DO>aises a number to t"e power of an
exponent
:= )ultiplication &peratorD5> )ultiplies two numbers.
8/14/2019 QTP Complete Reference for CS.doc
171/222
8/14/2019 QTP Complete Reference for CS.doc
172/222
bO:
cO
dOc*a`b
3cOab
msgbox d 3C;;;
Addition DH> operator
#im a,b,c
aOC;
bO:
cOab
msgbox c 3C:
8/14/2019 QTP Complete Reference for CS.doc
173/222
bO:
cOa6b
msgbox c 3C;:
aONC;N
bON:NcOa6b
msgbox c 3C;:
aON"yderaN
bONbadN
cOa6b
msgbox c 3C;:
=>Comparison"perators
/sed to compare expressions.
&perator #escription
C= O
:= ZL = Is &b'ect e4uivalence
&,ample8
#im x,y,%
xOC;
yO:;
%OxOy
)sgbox % 3alse
xOC;
yO:;
%OxLy)sgbox % 3alse
xOC;
yO:;
%OxLOy
)sgbox % 3alse
8/14/2019 QTP Complete Reference for CS.doc
174/222
xOC;
yO:;
%OxZLy
)sgbox % 3True
xOC;yO:;
%OxZy
)sgbox % 3True
xOC;
yO:;
%OxZOy
)sgbox % 3True
?> Concatenation "perators
&perator #escription
C= $ddition &perator
8/14/2019 QTP Complete Reference for CS.doc
175/222
8/14/2019 QTP Complete Reference for CS.doc
176/222
"#...Then...7lse state%ents can be nested to as %any levels as you need.
"# Runninga Statementif a Con%ition is True 1single statement#
To run only one state%ent when a condition is True, use the single-line synta8 #orthe "#...Then...7lse state%ent.
Di% %yDate%yDate A N5:36:N"# %yDate G 4ow Then %yDate A 4ow
RunningStatementsif a Con%ition is True 1multiplestatements#To run %ore than one line o# code, we %ust use the %ulti!le-line /or bloc&0 synta8.This synta8 includes the 7nd "# state%ent.
Di% 8
8A 5L"# 8;3L Then
%sgbo8 @8 value is2 @8%sgbo8 @Bye Bye@7nd "#
'# Running CertainStatementsif a Con%ition is True an% Running Ot)ers if aCon%ition is $alse
1e can use an "#...Then...7lse state%ent to de#ine two bloc&s o#e8ecutable state%ents2 one bloc& to run i# the condition is True, the other bloc& to
run i# the condition is False.
78a%!le2
Di% 88A "n!utbo8 /@ 7nter a value@0"# 8;3LL ThenMsgbo8 @ello =.$.Reddy@Msgbo8 @ is a Big 4u%ber@Msgbo8 @ value is2 @7lse
Msgbo8 @=$R@Msgbo8 @ is a (%all 4u%ber@Msgbo8 @ value is2 @7nd "#
(# Deci%ing 6et*een Se!eral Alternati!es
variation on the "#...Then...7lse state%ent allows us to choose #ro% severalalternatives. dding 7lse"# clauses e8!ands the #unctionality o# the "#...Then...7lse
8/14/2019 QTP Complete Reference for CS.doc
177/222
state%ent so we can control !rogra% #low based on di##erent !ossibilities.
78a%!le2Di% 88A "n!utbo8 /@ 7nter a value@0
"# 8;L and 8GA3LL ThenMsgbo8 @ello =.$.Reddy@Msgbo8 @ is a (%all 4u%ber@Msgbo8 @ value is @8
7lse "F 8;3LL and 8GALL ThenMsgbo8 @ello =$R@Msgbo8 @ is a Mediu% 4u%ber@
7lse "F 8;LL and 8GA3LLL Then
Msgbo8 @ello $handra Mohan Reddy@Msgbo8 @ is a ?arge 4u%ber@
7lseMsgbo8 @ello (ir@Msgbo8 @ is a =rand 4u%ber@7nd "#7nd "#7nd "#
,# 37ecuting a certain block ofstatements*)en t*o 8 morecon%itionsareTrue 19este% 0f555#
78a%!le2
Di% (tate, Region(tateA"n!utbo8 /@7nter a (tate@0RegionA"n!utbo8 /@7nter a Region@0
"# stateA @P@ Then"# RegionA @Telangana@ Then%sgbo8 @ello =.$.Reddy@%sgbo8 @Dist count is 3L@
7lse i# RegionA @Rayalase%a@ Then%sgbo8 @ello =$R@%sgbo8 @Dist count is @
7lse "# RegionA @$ostal@ Then%sgbo8 @ello $handra %ohan Reddy@%sgbo8 @Dist count is @
8/14/2019 QTP Complete Reference for CS.doc
178/222
8/14/2019 QTP Complete Reference for CS.doc
179/222
Msgbo8@78!onentation o# 8,y values is @Result
$ase 7lseMsgbo8 @ello =.$.Reddy@%sgbo8 @1rong O!eration@
7nd (elect
?oo!ing Through $ode
$lo* Control 1oopStatements#
o ?oo!ing allows us to run a grou! o# state%ents re!eatedly.o (o%e loo!s re!eat state%ents until a condition is Falseo Others re!eat state%ents until a condition is True.o There are also loo!s that re!eat state%ents a s!eci#ic nu%ber o# ti%es.The #ollowing loo!ing state%ents are available in +B(cri!t2
o Do...?oo!2 ?oo!s while or until a condition is True.o 1hile...1end2 ?oo!s while a condition is True.o For...4e8t2 >ses a counter to run state%ents a s!eci#ied nu%ber o# ti%es.o For 7ach...4e8t2 Re!eats a grou! o# state%ents #or each ite% in a collection oreach ele%ent o# an array.
"# 4sing Dooops
1e can use Do...?oo! state%ents to run a bloc& o# state%ents aninde#inite nu%ber o# ti%es.
The state%ents are re!eated either while a condition is True or until a condition
beco%es True.
a# RepeatingStatements)ile a Con%ition is True
Re!eats a bloc& o# state%ents while a condition is True or until a condition beco%esTrue
i0 Do 1hile condition(tate%ents----------------------?oo!Or, we can use this below synta82
78a%!le2
Di% 8Do 1hile 8G 8A8S3Msgbo8 @ello =.$.Reddy@Msgbo8 @ello QTP@
8/14/2019 QTP Complete Reference for CS.doc
180/222
?oo!
ii0 Do(tate%ents----------------------?oo! 1hile condition
78a%!le2
Di% 88A3DoMsgbo8 @ello =.$.Reddy@Msgbo8 @ello QTP@8A8S3
?oo! 1hile 8G
b# Repeatinga Statement4ntil a Con%ition 6ecomes True
iii0 Do >ntil condition(tate%ents----------------------?oo!Or, we can use this below synta8278a%!le2
Di% 8Do >ntil 8A 8A8S3Msgbo8 @=.$.Reddy@Msgbo8 @ello QTP@?oo!
Or, we can use this below synta82
iv0 Do(tate%ents-----------
-----------?oo! >ntil conditionOr, we can use this below synta82
78a%!le2
Di% 88A3Do
8/14/2019 QTP Complete Reference for CS.doc
181/222
8/14/2019 QTP Complete Reference for CS.doc
182/222
8/14/2019 QTP Complete Reference for CS.doc
183/222
Statements
----------------------!nd Sub
!xampleB C
Sub (onvertTemp
8/14/2019 QTP Complete Reference for CS.doc
184/222
unction (elsius 0sing )u# and *unctionProceduresin Code
$ unction in our code must always be used on t"e rig"t side of a variableassignment or in an expression.
or exampleB
Temp O (elsius
8/14/2019 QTP Complete Reference for CS.doc
185/222
8otice t"at t"e parent"eses are omitted in t"e call w"en t"e (all
statement isn3t used.
> &,amples8
D"ere, I used lig"t eservation$pplication for creating unctions, w"ybecause, It is t"e default application for QTP, anybody can practice
easily...G ( eddy>
3*******************************************3 7ogin &peration3*******************************************unction 7ogin
8/14/2019 QTP Complete Reference for CS.doc
186/222
0indow
8/14/2019 QTP Complete Reference for CS.doc
187/222
3 unction to send a mail
3******************************************unction Send)ail
8/14/2019 QTP Complete Reference for CS.doc
188/222
DC Internal error
D;D Invalid or un4ualified referenceHC Invalid pictureD Invalid procedure call or argumentD;:C Invalid range in c"aracter set
J Invalid use of 8ullH 8amed argument not found
> &b'ect doesn3t support current locale settingD &b'ect doesn3t support t"is actionH &b'ect doesn3t support t"is property or met"odDC &b'ect not a collectionD; &b'ect not safe for creatingD; &b'ect not safe for initiali%ing
D;: &b'ect not safe for scripting: &b'ect re4uiredJC &b'ect variable not set
> &ut of )emory:H &ut of stack spaceC &ut of string space
E &verflowD Sub or function not definedJ Subscript out of rangeD;C> Syntax error in regular expressionE: T"e remote server mac"ine does not exist or is unavailableC; T"is array is fixed or temporarily locked
C Type mismatc"D;CH /nexpected 4uantifier
D;; +ariable is undefinedDH +ariable uses an $utomation type not supported in +ScriptD; 0rong number of arguments or invalid property assignment
=> .B )cript )ynta, &rrors
+Script syntax errors are errors t"at result w"en t"e structure of one ofyour+Script statements violates one or more of t"e grammatical rules oft"e+Script scripting language. +Script syntax errors occur during t"eprogram compilation stage, before t"e program "as begun to be
executed.
&rror 2um#er escription8
C;D: (annot "ave multiple default propertyAmet"od in a (lassC; (annot use parent"eses w"en calling a Sub
C;D (lass initiali%e or terminate do not "ave argumentsC;DH 3#efault3 specification can only be on Property GetC;D> 3#efault3 specification must also specify 3Public3
8/14/2019 QTP Complete Reference for CS.doc
189/222
C;;D !xpected 3 !xpected 3(lass3
C;:D !xpected end of statementC;C !xpected 3!nd3
C;: !xpected expressionC;CD !xpected 3unction3C;C; !xpected identifierC;C: !xpected 3If3C;E !xpected 3In3C;:E !xpected integer constant
C;J !xpected 7et or Set or Get in property declarationC;D !xpected literal constantC;CJ !xpected 37oop3
C;:; !xpected 38ext3C;D; !xpected 3Property3C;:: !xpected 3Select3
C;: !xpected statementC;CE !xpected 3Sub3C;C> !xpected 3T"en3C;C !xpected 3To3C;CH !xpected 30end3C;:> !xpected 30"ile3 or 3