Sie sind auf Seite 1von 7

Search

CertificationQTPTraining
Home
WhatisUFT(QTP)?
Definitions
Downloads
SupportMatrix
Books
Forums
Certification
QTPTraining

HomeTipsandTricksinQTPSomeUsefulTipswithQTP

SomeUsefulTipswithQTP
UpdatedOnJul8,2014byAnkurJain

SharingsomeoftheusefultipsonQTPIusedwhileworking.Iurgethereaderstosharetheir
experiences/tipstheyhaveusedwhileworkingonQTP/UFT.
Youcanusethecommentssectiontodothesame.

1.Howtoaddaconstantnumberinadatatable?
ThisismoretodowithMSexcelthenQTP!!butusefultoknowbecauseattimesitbecomesfrustrating

tothenovices.Justappendtothenumber
Ex:ifyouwishtoenter1234567indatatablethenwriteitas1234567

2.HowcanicheckifaparameterexistsinDataTableornot?
Thebestwaywouldbetousethebelowcode:
onerrorresumenext
val=DataTable("ParamName",dtGlobalSheet)
iferr.number<>0then
'Parameterdoesnotexist
5. else
'Parameterexists
endif

3.Howcanicheckifacheckpointpassesornot?
chk_PassFail=Browser(...).Page(...).WebEdit(...).Check(Checkpoint("Check1"))
ifchk_PassFailthen
MsgBox"CheckPointpassed"
elseMsgBox"CheckPointfailed"
5. endif

4.Mytestfailsduetocheckpointfailing,Canivalidatea
checkpointwithoutmytestfailingduetochecpointfailure?
Reporter.Filter=rfDisableAll'Disablesallthereportingstuff
chk_PassFail=Browser(...).Page(...).WebEdit(...).Check(Checkpoint("Check1"))
Reporter.Filter=rfEnableAll'Enableallthereportingstuff
ifchk_PassFailthen
5. MsgBox"CheckPointpassed"
else
MsgBox"CheckPointfailed"
endif

5.WhatisthedifferencebetweenanActionandafunction?
ActionisathingspecifictoQTPwhilefunctionsareagenericthingwhichisafeatureofVBScripting.
Actioncanhaveaobjectrepositoryassociatedwithitwhileafunctioncant.Afunctionisjustlinesof
codewithsome/noneparametersandasinglereturnvaluewhileanactioncanhavemorethanoneoutput
parameters.

6.Wheretousefunctionoraction?

Wellanswerdependsonthescenario.IfyouwanttousetheORfeaturethenyouhavetogoforAction
only.Ifthefunctionalityisnotaboutanyautomationscripti.e.afunctionlikegettingastringbetweento
specificcharacters,nowthisissomethingnotspecifictoQTPandcanbedoneonpureVBScript,sothis
shouldbedoneinafunctionandnotanaction.CodespecifictoQTPcanalsobeputintoanfunction
usingDP.Decisionofusingfunction/actiondependsonwhatanyonewouldbecomfortableusingina
givensituation.

7.WhentouseaRecoveryScenarioandwhentousonerror
resumenext?
Recoveryscenariosareusedwhenyoucannotpredictatwhatsteptheerrorcanoccurorwhenyouknow
thaterrorwontoccurinyourQTPscriptbutcouldoccurintheworldoutsideQTP,againtheexample
wouldbeoutofpaper,asthiserroriscausedbyprinterdevicedriver.Onerrorresumenextshould
beusedwhenyouknowifanerrorisexpectedanddontwanttoraiseit,youmaywanttohavedifferent
actionsdependingupontheerrorthatoccurred.Useerr.number&err.descriptiontogetmoredetails
abouttheerror.

8.Howtouseenvironmentvariable?
Asimpledefintioncouldbeitisavariablewhichcanbeusedacrossthereusableactionsandisnot
limitedtoonereusableaction.
Therearetwotypesofenvironmentvariables:
1.Userdefined
2.Builtin
Wecanretrievethevalueofanyenvironmentvariable.Butwecansetthevalueofonlyuserdefined
environmentvariables.
Tosetthevalueofauserdefinedenvironmentvariable:
Environment(VariableName)=NewValue

Toretrievethevalueofaloadedenvironmentvariable:
CurrValue=Environment(VariableName)

Example
ThefollowingexamplecreatesanewinternaluserdefinedvariablenamedMyVariablewithavalueof
10,andthenretrievesthevariablevalueandstoresitintheMyValuevariable.
Environment.Value("MyVariable")=10
MyValue=Environment.Value("MyVariable")

9.WhatarethefilesandsubfoldersofaQuickTestProfessional
test?

Thefilesandfoldersholdbinaryandtextdatathatarerequiredforthetesttorunsuccessfully.
Thefollowingtableprovidesadescription,thetype,andcommentsregardingthefilesthatmakeupa
QuickTestProfessionaltest.

FileName

Description

Type

Test.tsp

Testsettings

Binary

Default.xls

Datatableparameters

Excelsimilar CanbeeditedusingExcel

Parameters.mtr Parameterizationinformation Binary

CommentsRegardingFile

Donotedit

Donotedit

Action

Actionfolder(Seeothertable)

Default.cfg

Loadtestconfigurationfile

Text

Donotedit

Default.prm

Loadtestconfigurationfile

Text

Donotedit

Default.usp

Loadtestconfigurationfile

Text

Donotedit

.usr

Loadtestconfigurationfile

Text

Donotedit

Thick_usr.dat Loadtestconfigurationfile

Text

Donotedit

Thin_usr.dat

Text

Donotedit

Loadtestconfigurationfile

FileswithinActionfolder:
FileName

Description

Type CommentsRegardingFile

Script.mts

Actionscript

Text

Edittextprecedingthe@@signonly

Resource.mtr ObjectRepository Binary Donotedit

Snapshots

Activescreenfiles Folder Donotedit

Therearefewmorefilesextensionslike
.MTBBatchFile
.LCKLocked

10.Howtorenameacheckpoint(QTP9.0)?
Example:
Window("Notepad").WinEditor("Edit").CheckCheckPoint("Edit")

Intheaboveexample,theuserwouldliketochangethenameoftheCheckPointobjectfromEditto
somethingmoremeaningful.
Note:
ThisfunctionalityisnewtoQuickTestProfessional9.0.ThisisnotavailableforQTP8.2andbelow.
1.RightclickontheCheckpointstepintheKeywordVieworontheCheckpointobjectinExpertView.
2.SelectCheckpointPropertiesfromthepopupmenu.
3.IntheNamefield,enterthenewcheckpointname.
4.Click.Thenameofthecheckpointobjectwillbeupdatedwithinthescript.
Example:
Window("Notepad").WinEditor("Edit").CheckCheckPoint("NewCheckPointName")

Note:
YoumustusetheQuickTestProfessionaluserinterfacetochangethenameofthecheckpoint.Ifyou
manuallychangethenameofthecheckpointinthescript,QuickTestProfessionalwillgenerateanerror
duringreplay.Theerrormessagewillbesimilartothefollowing:

TheCheckPointobjectwasnotfoundintheObjectRepository.ChecktheObjectRepositoryto
confirmthattheobjectexistsortofindthecorrectnamefortheobject.
TheCheckPointobjectisnotavisibleobjectwithintheobjectrepository,soifyoumanuallymodifythe
name,youmayneedtorecreatethecheckpointtoresolvetheerror.

11.DoesQuickTestProfessionalsupportInternetExplorer7.0?

QuickTestProfessional9.1
QuickTestProfessional9.1supportsMicrosoftInternetExplorer7.0Beta3.InternetExplorerversion7.0
isnowcertifiedtoworkandtobetestedwithQuickTestProfessionalversion9.1.
QuickTestProfessional9.0
QuickTestProfessional9.0supportsInternetExplorer7.0Beta2.
QuickTestProfessional8.2andbelow
QuickTestProfessional8.2andbelowdonotincludesupportforInternetExplorer7.0.

DoesQuickTestProfessionalsupportFirefox?
QuickTestProfessional9.1and9.2
QuickTestProfessional9.1providesreplaysupportforMozillaFirefox1.5andMozillaFirefox2.0
Alpha3(AlphalevelsupportforBonEcho2.0a3).
Notes:
QuickTestProfessional9.1willnotrecordonFireFox.YoucanrecordatestonMicrosoftInternet
Explorerandrunitonanyothersupportedbrowser,suchasFireFox.
The.ObjectpropertyforwebobjectsisnotsupportedinFireFox.
QuickTestProfessional9.0
QuickTestProfessional9.0providesreplaysupportforMozillaFireFox1.5.
Notes:
QuickTestProfessional9.0willnotrecordonFireFox.YoucanrecordatestonMicrosoftInternet
Explorerandrunitonanyothersupportedbrowser,suchasFireFox.
The.ObjectpropertyforwebobjectsisnotsupportedinFireFox.
QuickTestProfessional8.2andbelow
QuickTestProfessional8.2andbelowdonothavesupportforFirefox.

12.Problem:AfterQuickTestProfessionalisstarted,Windows
Mediawillnotstart.Itreturnstheerrormessagewmplayer.exe
hasgeneratederrorsandwillbeclosedbyWindows.Youwill
needtorestarttheprogram.Anerrorlogisbeingcreated.
IfyoustartWindowsMediaPlayerfirst,itwillcontinuetoworknormallyafterstartingQuickTest
Professional.
Solution:
IncludetheWindowsMediaPlayersexecutableintheNoBBTAppssectionofthemic.inifile
1.CloseQuickTestProfessional.
2.Gotobinmic.ini.
3.Includewmplayer.exeintheNoBBTAppssectionofmic.inifile.
Example:
[NoBBTApps]
wmplayer.exe=rek

4.Savethemic.inifileandrestartQuickTestProfessional.

13.WhatisthelservrcfileinQTP?
Thelservrcfilecontainsthelicensecodesthathavebeeninstalled.Wheneveranewlicenseiscreated,
thelicensecodeisautomaticallyaddedtothisfile.Thelservrcfileisatextfile,withnoextension.
FileLocation:
1)ForaConcurrent(Floating)licenseinstallation:
C:ProgramFiles/CommonFiles/SafeNet/SafeNetSentinelLMServerWinN
2)ForaSeat(Standalone)licenseinstallation:
QTP9.2andbelowversions:C:ProgramFiles/CommonFiles/MercuryInteractive/License
Manager/lservrc
QTP9.5andaboveversions:C:DocumentsandSettings/AllUsers/ApplicationData/HPFunctional
testingLicense

14.WhattodoifyouarenotabletorunQTPfromQuality
Center?
ThisisforespeciallyfornewbieswithQTP.
CheckthatyouhaveselectedAllowothermercuryproductstoruntestsandcomponentsfromTools>
Options>RunTab.CheckoutQTPandQCguide.

15.DoesQuickTestProfessionalsupportMacintoshoperating
systems?
No,QTPdoesnotsupportanyOSotherthanWindows.
Note:PleaseusetheQTPforumforpostingquestions!
IfyouwanttokeeptrackoffurtherarticlesonQTP.IrecommendyoutosubscribeviaRSSFeed.You
canalsosubscribebyEmailandhavenewQTParticlessentdirectlytoyourinbox.

Welcomenewreaders:DownloadtheFreeeBook!
IamAnkurJain,theownerofLearnQTPandfounderofasoftware
organization.Thissiteisrun,maintainedandupdatedbymeandmy
team.Feelfreetotakealookaround,youmaywanttostartwithWhatis
QTP?
YoucanconnectwithmeonmyGoogle+page.
PleaseenteryourfirstnameandemailaddressbelowtoinstantlydownloadtheeBookon
OptimizingQTPScripts.Infuture,wewillmakesureyougetnewtips&tricksonQTP

Das könnte Ihnen auch gefallen