Home

QuickTest Professional Unplugged Tarun Lalwani

image

Contents

1. 386 Net Armys Revisited Sean nan ux S Tub AAA 387 Working with Net Stacks viniera beta daa ee based xx er RE daa ERR E RN T 387 Working with INetOucues 2 eet e Sot ae scien Saas Bt Sen Poe SEES 388 Working with Net Date and Time Formatting 388 Sending Emails using NET ood s we e EIE RR RR E RR 389 Converting Images to other File Formats 390 Getting user Input using NET Forms es eee ene 392 31 Designing Frameworks 399 Desig surdelingss ou aa Sauk d page ed a We eR bd oe ad 399 Support of different application versions 400 OTP AMP LES tevin cases ahaa weed do dai a hb orenteve tu pue a gt AA dad 402 Re sability cre sie dete dta dere wrk A AE eher t hed 402 Support for different application versions 403 Externally Configurable wee eile haan ene ee 404 Tun L R giant try eae ds ERA ne E Reed De SA LANA 404 Deli Com Gira Dla C ud Assess Ufo oe oh teu LAN ao RE ended 405 32 Usef l TOONS e ra Rer mU oie Woe ACA XN CR Ow wT OO KD ES UON 409 CLP Script Editor es s oca werdet VERS E ERIT E SEES e Wer dC SO YES 409 QuickTest Professional Unplugged VBSEditi TTT 410 INGLE Pada amus eite ans bee A ad PAM age Seite a do A Utd 410 QTP sy 411 Sereen Capture Pl Sato Saee Ves Mite INVI RS ese TR Wea ne ee a 412 Knowled
2. HO E E VENE eee 80 Converting an OR based script to a DP based script 81 Using a VBScript DP object repository ceeded ds hee ee ER REY 83 Problems with Ordinal Identifiers 0 llle 84 Working with Multiple Browser Suicida e VD UR nae taeda 86 Browser identification Issue eese y Sau sire ew keene eeu eer ge Wa ann ERES 87 Browser identification using OpenTitle 87 Browser Identification using a unique OpenURL Property 88 ll Debugging in QTP ena Sea A RRR SR ROO RTT EE RARA X 91 Establishing our Debugging Configuration 9 Using Break poss sse nere se DAD Site Ped SP aa aed ab eds ESL ohare ee 92 Working with the Watch Expression Tab 92 Working with the Variables Tab i n occas teas ava e RR E br A es 93 Working with the Command Tab 25 Se ah been c EO rn s 94 12 Recovery Scenarios 97 When not to use recovery scenarios esos care A awa A AES S 97 Situations in which a Recovery Scenario won t work 101 Recovery Scenario for IE Authentication window 103 Default Recovery Scenar10S d aor AA eee EUR EDUC Pu e ees 104 Pe Recovery object v perros peated vp po cido 105 Recovery Function Calls ea e Eee ate es 105 Error PU an lR lt raon a edat too Vect es a alte equa b oda RT iudi
3. SelectRadioByTextIndex 206 SendMessage 172 SetActiveWindow 184 SetCurrentRow 34 35 SetForegroundWindow 173 SetSecure 56 Setting Object 57 SetTOProperty 17 ShowWindow 176 SnapshotOnErrorActiveUI 342 SnapshotReportMode 163 Space 128 Split 128 SplitEx 129 StopAndReRunQTP 344 StrComp 123 String 128 StrReverse 124 Sync 151 Synchronization Points 151 SystemUtil 370 BlockInput 370 UnBlockInput 370 SystemUtil Run 86 SystemUtil Object 59 T TDAPIOIe80 TDConnection 326 TDConnection 322 324 Test Arguments 191 Test Results 159 Accessing Test Results at the end 167 Configuring QTP to generate HTML results 164 Converting XML Results to HTML 164 Inserting Files in Test Results 161 Inserting Snapshots in Test Results 162 Time 132 Timer 134 Trim 127 TrimAll 138 TrimW 120 TSRFilePath 343 TypeName 135 U UBound 143 Ucase 123 URLDownloadToFile 176 UseExternalDataTablePath 342 Useful Tools 409 IE WebDeveloper 413 Internet Explorer Session Cookies 413 Notepad 410 QTP Script Editor 409 QTP Uninstaller 411 RAD Regular Expression Designer 416 ScreenCapture API 412 Test Design Studio TDS 415 VB 2 QTP API Converter 413 VBSEdit 410 U B 5 ser defined Objects 22 v V V alueByRow 34 arType 135 W Wait 152 WaitProperty 152 WebRegSelectValue 118 Web Tables 211 Access using OR 216 Asynchronous Table loading 223 Clicking inside a WebTable 221 Exporting WebTable to a DataTable 2
4. is equivalent to DataTable Value ParamName dtGlobalSheet val DataTable ParamName dtGlobalSheet val DataTable ParamName Using the data table object model val DataTable GlobalSheet GetParameter ParamName Value Using the data table object model val DataTable GlobalSheet GetParameter ParamName ValueByRow 1 QuickTest Professional Unplugged DataTables gt gt Data table formatting 33 Problem 4 2 How to access a parameter from a Local data sheet Various methods to get data table value val DataTable Value ParamName dtlocalSheet val DataTable Value ParamName lt LocalActionName gt val DataTable ParamName dtlocalSheet Val DataTable ParamName LocalActionName The local sheet of the action which is executing this statement val DataTable LocalSheet GetParameter ParamName value Problem 4 3 How to check if a Sheet exists Function to check if DataTable sheet exists Function isSheetExists sheetName On error resume next isSheetExists TRUE Err clear Set objSheet DataTable GetSheet sheetName In case error occured sheet does not exist If err number lt gt 0 then isSheetExists FALSE End if End Function Problem 4 4 How to preserve format of data output to a data table This would be modified to 1 23456789E 010 due to auto formatting DataTable ParamName 12345678901 This will not be auto formatted and will be treated as text DataTa
5. AUR MON OS xii I Introduction lt iae AR VIRI CR COR STD BOR AA MoO RR R EORR l Whatis Test A tomation s xu ode A eens oe sad dnce 1 When Should Test Automation Be Used se 1 When Should Test Automation Be Avoided 2 The Automated Testing Processus ewe AA We Y RAS 2 What is HP QuickTest Professional OTP eese 4 2 Using QTP Help o II ARAS AAA 7 Contents Ta a coo sco ad ud e obe AAA ones de e quede de LG 8 Properties returned by the GetROProperty Function sss 8 Methods provided by a Test Object sia dat a at 8 Index Tab SA a iene ig ee ee oes et da EA e scu b sat itus s eer 9 Search Tab SAM ewe iu xev Ne A RR Ra maa eee 10 3 Object Repository OR 13 How objects are added to the OR shin dias e Cee eR dat 14 Test and Run time ODE ccu d Ge enced tlw haem RR EU ads eats 16 TO Properties vestir pedos as gre aetna E LA Mes pr beta p lt Ls 16 Object Repository Modes co ce tics veteres oon RU ce Oe Fatih ub Lac Wate a 18 Per Action versus Shared Object Repository 18 The Object Spy v due AAA iesu per FR ROLE E seite 19 Object Ident cation reso me o ete eh em cu A dU ebd pec a 2 Esersdebned Objects o deze exa rasure rrit SEE SE AS ERES A 22 Object Repository Shortcomings 0 eee aaa 23 4 Data Tables sa osse tra RI o eee ea cores v a a dos 27 Design and run time data table ist
6. Problem 23 8 How can we access an Excel spreadsheet embedded in Internet Explore a Va reae TR PETER UR EU ORS PHP 262 Problem 25 1 How to instantiate and terminate a word application 286 Problem 25 2 How to get reference to an already open word application 286 Problem 25 3 How to enumerate all the open word documents 286 Problem 25 4 How to open and save a new document in word 287 Problem 25 5 How to get reference toan already existing word document 287 Problem 25 6 How to open a word document in the read only mode 288 Problem 25 7 How to print an open word document 288 Problem 25 8 How to insert text into a word document from a pre defined style 288 Problem 25 9 How to insert an image in a word document and scale its size wc y c 289 Problem 25 10 How to find and replace some text in a word document 289 Problem 25 11 How to insert a table into a word document 290 Problem 25 12 How to change the font for the text being written in a word document o neo caa ae tee ans aa E arb UN We opua A utes ale ie qui quidem 291 Problem 25 13 How to preserve the text already present in a word document While Writing ecoute udo E STE tuti duo dude a S tita ufo p utate Koc PU utate AN 292 QuickTest Professional Unplugged B Appendix B Index A Actions 37
7. Rr RES ee cia Bene eS 59 The RegisterUserFunc Object mr bere Me eec a a PERS MUT 60 8 Checkpoints v ora Hak a pec eee pct sect ct 63 Types of checkpoints A iatis Men 63 Problems with QTP built in checkpoints 64 Alternatives to QTP checkpoints ada ERI 65 Updating Checkpoints at run time ee 65 9 Library Piles 6 49 do eu EE OX HR OO ek DURA AE DOSTDERDRES ROR ELS BAR 69 Associating a Library globally with a Test 69 Dynamically Loading libraries locally at run time 70 Dynamically Loading libraries globally at run time 70 Understanding Execution Scope 0 cece cece cece cece teen en kaa 72 Applicability of Option Explicit ss RE TE 73 Executing code in Local scope from within Global Scope 73 10 Descriptive Programming DP 77 Object Id ntificatioti LL dese Dra rb POSER EDI SR ee EGS 77 Implicit Properties d aod ve Pus e rea etate ees FAR NR NC fe ds 78 When to use Descriptive Programming eee 78 Descriptive Programming Syntax ad PORA qq NU 78 Using description objects acuta eyes ing en RES eres usines ei 78 The micclass Identidad OPI HUS VAGUE BS ee e 80 Using Description Strings vts t ius Hd RD EP ek So eke ee ERE SEAT 80 QuickTest Professional Unplugged Enumerating ChildObjects
8. Shag whew ooo eS ER Reed 295 IE COM Methods and Properties ss sesak 296 Page Svhohronizatlom oes aav rug bu wt xa A cra esu e whee RC OUS 297 Enumerating all IE Windows ee Rd ee SHE ar eo eoa 298 Finding an IE window A e ou dut se eg ut Ul der ie 299 Launching a new BrOWSBE 42er ved a Shes T e DEG ed 299 Getting Web page DOM E pes ERU RE ah hee 301 Accessing webpage script variables 301 Using JE fo Betuser put usu R cuo qe A Ec ere DE Wind eee P ud 302 IB Popup Dial o pes ach t rede as id d ode Pa od but ded 304 Disabling IE dialogs a Au Ee c i dice a ca qe i ul cS gna 304 Changing IE settings using the Registry 304 Popup Te 2 4 20 2003 4 euet he poor y pere hg AWS Y a ede edes 305 Disable Script Error dialog ons c RIS E P RA GO REG ipsu eT dd 305 Security Alert Redirection popup sia eere tp IRR ELEC E 306 Security Alert Certificate warning 307 Security Alert Secure Connection 0 cece cece eee eens 307 Security Information Secure and non secure item 308 Active content Java Script Prompt eens 309 File download Information bar 309 Handling popup dialog by using a code 310 File Download Security Warning popup 000 cec
9. a dg Du E 216 Using an object inside the table 218 Getting the location of an object inside the table 219 Clicking mside a Web Tables 25 24 2c secede Poe eU ua e ee deal bte pla ats 221 Asynchronous Table loading A A e Res 223 Exporting WebTable to a Data Table 223 Extending Web lable functionality 224 Getting a QTP Table from a element 224 Finding a cell in a Tables iu eee RA Ne NU RR MAS E o 225 21 Working with XML 231 OTEXME ODICCIS na a de y cue cu NA ec e e d SARA 232 Reading and Modifying ME e a aa 232 Working with Multiple environments of an Application 235 Exporting XML to a DataTable 237 Compartido XM Bs oie ve thee A A NR ERT REAR cti ue TR ud gu gad 238 22 Working with Databases 243 Connecting to d Database cse arar ia Eo Ur AN RUE 243 Building Connection Strings o s opt ag AS V VERE quA d e 244 Checking the State of a Connection or Recordset 247 Exporting the Results of a Query to Data Table 248 Executing a Stored DB procedure een 249 23 Working with Microsoft Excel 253 The Excel Automation Object Model 0 00 259 Con
10. and Password QuickTest Professional Unplugged 28 DataTables gt gt Introduction We can use most of the formulas that work inside a typical Excel spreadsheet But there are some differences between a DataTable and an Excel spreadsheet In fact a DataTable is wrapped around an Excel spreadsheet which provides access functionality to the values but does not expose the Excel spreadsheet object model gives the value of Parameterl stored in the Global data table DataTable Parameteri dtGlobalSheet gives the value of Parameterl stored in the current s action local data table DataTable Parameteri dtLocalSheet The same DataTable cannot have duplicate parameter names but we can use the same name parameters in different sheets Global DataTable and Local DataTable Each DataTable has only 1 row enabled even when it is blank and the other rows get enabled when data is entered into a new row A DataTable is stored as Default xls file in the test folder Figure 4 2 shows how the stored file looks like ix Microsoft Excel Default xls Bg File Edit View Insert Format Tools Data Window Help X FP S Mic Shell Dlg 1 10 B 7 U FECE ST gt Security Y 52 AZ G6 C3 lt fe 5 a VE ETE ies 1 Parameterl Parameter Sum Ea EX M 4 Global Action1 Ready C 1 2 3 5 Figure 4 2 Default xls Data table When viewed in Excel the first row of the sheet contains the parameter names
11. outSheet SetCurrentRow i 1 re calculate the column count as some rows have different column sizes colCount objTable ColumnCount i For j 2 to colCount cellText objTable GetCellData i j We are using index here to avoid the problem of the issue if cell text has spaces or new line chars then we will get an error to overcome that we can also use outSheet GetParameter Replace cellText Value outSheet GetParameter j 1 value cellText Next Next Problem 4 7 How to get value of a parameter from any specific row in the data table We use the ValueByRow method to get value for any row Get a value by row DataTable GetSheet SheetName GetParameter ParameterName ValueByRow RowNumber QuickTest Professional Unplugged DataTables gt gt Data table formatting 35 Problem 4 8 How to execute a script for all Global Data Table iterations when the script is set to run for only one iteration In case we want to manually repeat the code for each iteration we need to write a bit code Declare variable Dim i iCount Get the global sheet object Set oGlobal DataTable GlobalSheet Get of rows iCount oGlobal GetRowCount For i 1 to iCount Set the current row oGlobal SetCurrentRow i Execute the code to be repeated here Msgbox DataTable UserName Next Problem 4 9 How to get the number of columns that contain data To solve this problem we need to utilize the excel formula COUN
12. supports one more undocumented EventStatus micInfo Using micInfo creates a step with an 1 icon for the step This is useful to report just information in the report which we may want to visually segregate from the similar micDone entries Inserting Files in Test Results Consider the following code Create the html file path store it in a Test Results folder sFile Reporter ReportPath amp StepsToRecreate html Create the HTML file Set FSO CreateObject Seripting FileSystem0bject Set file FSO CreateTextFile sFile True file Write lt I gt lt B gt Step 1 lt B gt lt I gt Launch www mywebsite com file Write P B Step 2 lt B gt Click on the Login link file Write P B Step 3 B Enter the username as tarun QuickTest Professional Unplugged 162 Test Results gt gt Inserting Snapshots in Test Results file Write P B Step 4 lt B gt Enter password as tarun file Write P B Step 5 lt B gt Click on the Login button file Write P B I Step 6 lt I gt lt B gt Close the browser file close Insert the above file as a IFRAME in the report SHTML 81t lt IFRAME width 100 height 250 src file 8 sFile amp gt lt IFRAME gt amp gt Reporter ReportEvent micPass Steps To Recreate sHTML Clean up Set file Nothing Set FSO Nothing E Uii d Test Tempra Teri Miras Ple Wen Dusk Heb TO AAR 7 vm fe
13. tool This book presents QTP as a development tool rather than a mere test tool One of my problems while evaluating the tool led to me to join www SQAForum com without knowing that I will specialize in the use of this tool in future After sometime I launched KnowledgeInbox com for sharing my articles on QTP with the larger group Dealing with day to day automation problems faced by people on the QTP forums I tried solving those problems for them and learnt a few new things on my own Observing the patterns of queries being asked on the QTP forums I thought what the QTP community was missing is a book which can guide the amateur automation engineers in becoming a professional in the use of this tool I took up this responsibility and started writing this book in May 2005 I spent an year on the research of the undocumented QTP features and solving the unsolved queries of QTP Being a first time author I had a very hard time getting this project completed It was an additional responsibility over and above my office work QTP forum support writing articles on KnowledgelInbox creating tools for the community It required a lot of motivation to keep myself on the project But knowing what difference this book can make to the QTP community always kept me motivated I have organized the chapter in such a way that can make learning QTP an easier task Each chapter is based on a QTP feature The book is divided in two sections Basics and Advanced Chap
14. 23 Finding a cell in a Table 225 FindTextBySearch 226 GetTableFromElement 219 Getting a QTP Table from a element 224 Getting the location of an object inside the table 219 GetWebTableFromElement 224 Using an object inside the table 218 Using Index 213 Using innerText outerText 213 Using Name or HTML ID 213 WebUtil Object 59 Weekday 133 WScript Shell 168 183 187 282 295 305 309 345 405 406 Ss XX AS M PS xX MLAttribute 232 ML Attributes 232 MLAttributesColl 232 ML Child nodes 232 MLData 232 MLElement 232 MLElementsColl 232 MLItemColl 232 ML Node values 232 ML Root node 231 MLUtil 232 MLUtil CreateXML 232 MLUtil CreateXMLfromFile 233 lt Y ear 132 QuickTest Professional Unplugged About the Author Tarun works as an Automation amp Solution consultant and has over 5 years of experi ence in IT He has worked on various Automation projects using QTP VBScript VB6 VB NET C NET Excel Macro Outlook Macro He blogs at Knowledgelnbox com He can be contacted through http Knowledgelnbox com contact me HP QuickTest Professional is a functional test automation tool It supports a Record and Playback framework out of the box where we can record and capture our interactions with the application under test and then replay those actions later With this book you will learn Basic concepts of QTP Working without Object repository using Descriptive Programming Advanced concept
15. 48 GetWindowDC 173 GetWordFromPos 138 GloballterationMode 342 GlobalSheet 32 H Hex 132 Hour 132 HowManyWeekDays 133 HTML Button 199 HTML Checkbox 200 HTML ComboBox 199 HTML Element Collection 197 HTML Element Object 197 HTML Link 199 HTML List Box 199 HTML Node 196 HTML Radio Button 200 B 3 HTML Table 201 HTML Text Box 199 l IEDownloadFile 312 InStr 124 InStrRev 126 Internet Explorer 295 EnumerateIE 298 Popup Blocker 305 Using IE to get user input 302 InternetExplorer Application 296 297 301 IsConnected 322 IsEnvExist 47 isParameterExists 33 IsRegEqual 117 J Join 128 JScript 357 Passing variable number of arguments to a function 358 Scope differences 358 Try Catch block 359 Working with JS classes 360 Working with JScript Arrays 360 K keybd event 173 KeyDown 174 KeyPress 174 KeyUp 174 L LastGloballteration 342 launchreport 343 Lcase 123 Left 124 Len 124 Library files 69 Associating a Library globally with a Test 69 Dynamically Loading libraries locally at run time 70 73 LoadFromFile 52 LocalSheet 33 LTrim 127 LTrimW 120 M MakeObjVisible 348 QuickTest Professional Unplugged B 4 MapVirtualKey 173 MercuryTimers 375 micclass 80 micGreaterThan 375 micGreaterThanOrEqual 375 micLessThan 375 micLessThanOrEqual 375 micNotEqual 375 micRegExpMatch 375 Mid 124 Minute 132 Modal dialog boxes 184 Month 132 N NewSync 311 Now 132 O Object Identificatio
16. Input and Output Parameters 37 Insert Call to Copy 43 Insert Call to Existing 42 Insert Call to New 41 actionsspath 343 AddAttachment 331 AddParameter 34 35 AddSheet 34 ADODB Command 243 247 249 ADODB Connection 243 ADODB Recordset 243 246 Advanced Text Checkpoints 348 API using COM Objects in VB6 176 API using Excel 179 ApplyXSL 239 Array 128 Asc 131 Automation Object Model AOM 189 B Browser Vs Page Sync 153 C CBool 131 CByte 131 CCur 131 CDate 131 Check 64 CheckBrokenImages 314 Checkpoints 63 Alternatives to QTP checkpoints 65 Types of checkpoints 63 Updating Checkpoints at run time 65 ChildObjects 80 Chr 132 CInt 131 CleanBrowserPopups 310 CleanText 141 CLng 131 CloseDescendentProcesses 59 CloseProcessByHwnd 59 CloseProcessById 59 CloseProcessByName 59 CloseProcessByWndTitle 59 Comparing XML 238 Converting a DOM object to QTP Test Object 202 Converting VBA to VBScript 258 CreateDescription 79 CreateObject 136 CreationTime 84 Crypt Object 55 CSng 131 CStr 131 CurrentRun 323 currentStyle 203 CurrentTest 323 CurrentTestSet 323 CurrentTestSetTest 323 D Database 243 DataTable 27 Data table formatting 32 Data table object model 32 Design time data table 29 Run time data table 29 Setting data table iterations 30 When to use the global or a local data table 29 QuickTest Professional Unplugged B 2 Date 132 DateDiff 133 Day 132 Debugging 91 Using Breakpoints 92 Worki
17. N oaa Gall Mens 179 Dynamically generating an Excel Macro 0 eese 181 Working with Modal dialog boxes eects 184 18 QTP Automation Object Model 189 QTP Automation Object Model AOM 189 Passing arguments to Test Cases eh 190 19 HTML DOM iii av o E RE PESE ee E 195 When to use the HTML DOM 195 When not to use the HTML DOM 196 HIME DOM Objects o4 Uo xem eR EODD va a e Ph C E PERO eo RS 196 HEME Node rd ada 196 TheDocument OBIGet soos ts a ti 197 The HTML Element ODIGGtrs lt e a ou cence E ae EE UE Re IPs 197 QuickTest Professional Unplugged The HTML Element Collection 54 ans cas COSI Gals aN Ge eas eas 197 Getting the Web page Element using the DOM nsen 198 Other HIME Elements ove oe xS aaa 199 Converting a DOM object to QTP Test Object 202 Checking Appearance using Style Sheets 202 Checking Visibility of a Object on a Page 202 Selecting a Radio button by Text 204 20 Working with Web Tables 211 Web Tables oso aA o E E UR oy Fea wate aoe wh ie REA A 211 Accessing the Web able orti sores en a e t Rte MARG AE Re p LATO Cu s 212 Using Indeed a Ste PP OLET PCR pd Lee PLS S Ie 213 Using Name or HTML ID uote A E ORE tes 213 Using innert Text outer Text iud eer 2 res evans Dex P oc ox 213 Using OR G4 ode de tne recreo AS cien S ue
18. Objects cece ce eee ences 370 DHE Print Log Utility estan noe fot oe A SA Soo utei abe 372 Hiding the Print Window i224 62 bcat ee eene ue dn Lae eed ea ta ee hed 372 Showing the Print windOW GAS seen US a bw ud VERUS 373 Clearing the Print Window x dann oer nS Mr ia 373 Programmatically Capturing the Print Log text 374 Mere ExpMateh a peus ved aaa weet eae THE CN ets s 375 Mercury e oo pena ade H Ta ude RE ae ed AAA RM en A E AG dins 345 KepositortescollecHoDo ana oe Ve pen ve cata RC baee Deuda aa Lai 377 DOtNEtFACtOIY s tes ene NE Rr eO TAN Vows e ues RR T EE ees E S 377 Generating Object name from the object 378 30 Working with NET Classes 381 Using the DotNetFactory ODIO aue ud a a RICH Rn Ren 381 Passing Parameters to Class Constructors 381 Passing Parameters to NET Objects ee eens 382 Passing EDUtlis iiec anre a aed RR UR T Ce eg Ee ME EU es 383 Working with NE DATOS o isa mir vehere Lr ebd e 384 Playing a Wav File Dota A d oy A 385 Working with the Clipboard wince a e RP RE AXE EE ES 385 Getting Computer Information os souche URS OR bee eroe 385 Accessi the REGIST used des a esr RO NER WEN He NE OU E WEM Red 386 Ping an IP Address ot d aso g A dm d Re OR OE Reg LAT TA dU Wes 386 Evaluating Keyboard Control Key Status
19. Quicklest Professional Advanced Keyword Driven Testing This program is Protected by US und niail 7 apynghi law ms descried in Halp ES ZEBHHHHHHHEE 9988900799 EE 2 OOOO a a JUBBHBHBBBHHEC JUBDBOBH HHH BS 299898868 on zd AD 1 209 DI QuickTest Professional Unplugged By Tarun Lalwani QuickTest Professional Unplugged By Tarun Lalwani Editor Siddharth N Kanoujia Technical Editor Terry Howarth Reviewer Mark Smith and Terry Howarth Printing History May 2009 First edition No part of this publication may be reproduced stored in a retrieval system or transmitted in any form or by any means electronic mechanical photocopying recording scanning or otherwise without either the prior written permission of the Author or authorization through payment of the appropriate per copy fee to the Author For permission please contact author at ttp knowledgeinbox com contact me Source codes discussed in this book can be copied modified or distributed without permission from author or the publisher by including the below mentioned reference Source code taken from QuickTest Professional Unplugged By Tarun Lalwani Website http Knowledgelnbox com books quicktest professional unplugged This document also contains registered trademarks trademarks and service marks that are owned by their respective companies or organizations The Publisher and the author disclaim any respon
20. TA We add a parameter to the data table with the formula and then read its value Add a new parameter with the formula For Columns 1 of data table use A1 A65536 For column 2 of data table use B1 B65536 and so on DataTable GlobalSheet AddParameter New COUNTA A1 A65536 Get the new value Msgbox DataTable New NOTE The above code won t work when there are no columns in the data table or all the columns have been used QuickTest Professional Unplugged Reader s Note Chapter 16 Test Results Test Results provides a summary of a QuickTest run session The results are stored in an XML file format QTP provides a Test Results viewer tool used to review and print these results Test Results optionally contain image snapshots based on QTP configuration settings Figure 16 1 shows a typical test result summary De pa Sb de ATRAN listed eee fe our x aiai 1 R ri M dec U da 2 NB pa ea 2 D reg kire erdi D ra oy KT nm 1 pet BE irie eir 1 D faces arpi Pda zi reir E reo Jae Aai ek pee ee Pr i LS iaa A rmm er 3 op rm Boer Fur IP Liniitied Tesi Results Summary Megat pame o Dem pica Tua Joi Fac Sms arl Tn e Vien nium ALM UL d Tra osded CAP 5 oF een f Figure 16 1 Test Results summary The left hand pane provides summary information about each step performed during the test run Icons to the left of each step provide the following information a
21. TestPlan 333 EnumerateSettings 341 Environment variables 45 BROWSER ENV 49 ExternalFileName 46 LoadFromFile 46 Types of Environment variables 45 URL ENV 49 Value 46 Error Handling 107 Eval 144 Excel Application 136 181 182 254 258 347 353 Excel Automation Object Model 253 Execute 51 79 143 ExecuteFile 70 ExecuteFileGlobal 71 ExecuteGlobal 72 ExecuteGlobalCode 72 Executing a Stored DB procedure 249 Executing code when Script ends 346 Exist 153 ExitAction 39 Exporting XML to a DataTable 237 Extend 356 extendWebTable 356 Extern Declare 171 ExternalDataTablePath 342 Extern object 171 F Filter 131 FilterStr 139 FindAttachment 328 FindWindow 184 FindWindowEx 184 FireEvent 154 FirstGloballteration 342 Fixed length arrays 142 G GenericSet 60 GetAddressesFromMail 279 GetBusinessDays 134 GetColumnName 265 GetCurrentTestPath 332 GetCurrentTestSetPath 335 GetCursorPos 179 GetDC 173 GetDOMObjectByPath 205 getElementsByld 198 getElementsByName 198 getElementsByTagName 198 GetEnvironmentVariable 172 GetFileName 140 GetFilePath 140 GetForegroundWindow 171 172 GetIECOMByhWnd 299 GetIECOMByURL 299 GetIEObjectFromhWnd 262 GetObject 136 GetParameter 34 GetParentOfElement 218 GetPixel 173 GetRandomNumberByLen 300 GetROProperty 8 17 GetRowCount 35 GetSheet 33 GetSMTPAddress 280 GetStrBetweenChar 137 GetStrFromChar 137 GetSubFolderByPath 271 GetTOProperties 16 GetTOProperty 17 GetVarXML
22. al data sheet 32 Problem 4 2 How to access a parameter from a Local data sheet 33 Problem 4 3 How to check if a Sheet exists 33 Problem 4 4 How to preserve format of data output to a data table 33 Problem 4 5 How to check if a parameter exists in a specific sheet 33 Problem 4 6 How to export contents of a WebTable to a data sheet Let s assume that the first row of the data table contains the columns heading We then add those as parameters of the data table e Pene cle dd a 33 Problem 4 7 How to get value of a parameter from any specific row in the data table 34 Problem 4 8 How to execute a script for all Global Data Table iterations when the script is set to run for only one iteration eh 35 Problem 4 9 How to get the number of columns that contain data 35 Problem 6 1 How to access an environment variable 47 Problem 6 2 How can we check if an environment variable exists 47 Problem 6 3 How is an environment variable defined at run time 47 Problem 6 4 How can environment variables be exported to an XML file 48 Problem 6 5 How are QTP record and run settings changed using Environment variables 49 QuickTest Professional Unplugged A 2 Problem 6 6 How is an envi
23. ble ParamName amp 12345678901 Problem 4 5 How to check if a parameter exists in a specific sheet Check if a parameter exists in data table Function isParameterExists sheetName paramName On error resume next isParameterExists TRUE Err clear ParamTotal DataTable GetSheet sheetName GetParameter paramName In case of error the parameter does not exist If err number lt gt then isParameterExists False End if End Function Problem 4 6 How to export contents of a WebTable to a data sheet Let s assume that the first row of the data table contains the columns heading We then add those as parameters of the data table Variable declaration Dim i j Dim rowCount colCount Dim cellText objTable QuickTest Professional Unplugged 34 DataTables gt gt Data table formatting Get table object Set objTable Browser Page WebTable Get the row count of the webtable rowCount objTable RowCount Get the column count of the webtable header row colCount objTable ColumnCount 1 create a output sheet Set outSheet DataTable AddSheet Output Create Parameters based on the 1st row of the web table For i 2 to colCount cellText objTable GetCellData 1 i Note in case the CellText contains space in between then QTP will automatically convert it to a character outSheet AddParameter cellText Next Skip first row as we assumed it to be a header row For i 2 to rowCount
24. e eee ee eee 311 Checking for Broken images on a Web Page 314 Using a Browser Object as a Window Object 314 Custom Browser Applications eee eee ene 316 QuickTest Professional Unplugged 27 28 29 Working with HP Quality Center 319 Q ahty Center at ed copus Sole Sae o A Ed eta Stai ele ote e 319 Connecting OTP witlim i anus de RC CERE RC ER RP eee T 319 MCP AUIS eoe dae tes Sa WT e EAR ee cote ellen a o a Sana 321 Relative Paths d 06 S nerien dais ed a CRUS qe 321 Resolving Relative Paths i es said a eT Sade ores 321 OCU CODEC eu ita PE Heel eres ARE CI VS 322 QC Open Test Architecture OTA iue dete aa ta See pe 324 The I DConnection Objecte a is xo px R ah ag SR ee ee eee 324 The Command and Recordset Objects 327 The AttachmentFactory Collection cece eee eee eee eee 328 Simple way of Downloading files from QC 330 Uploading Attachments to QC ORT e RES saad Cre VR 331 Getting the Current Test Located do En 332 Enumerating All Tests present in a TestLab folder 332 Enumerating all the Tests in a Test Lab Tab 334 Getting the Current Test Set Location 335 Advanced OUP soi aas aoi TA RO ce BE UA AUS CRI RC Re 337 Synchronizing Script Executi
25. ence ra n Re RN dett 29 Design time data talas SN Mos satus S Mese V AES 29 Run time data table no ue sae suh obs ebria A 29 When to use the global or a local data table 29 Setting data table iterations s 4s emere IHE eae patada PS VIN UBI 30 Data table objeettmodel sa douces tina d pte ORE Ra A res 32 QuickTest Professional Unplugged Data table formatting c cursus eem chs es as adds Lei AAA NRI RTA a 32 5 Actions eenen A AA aa d Ta oe 37 Input and Output Parameters ss eee eeu bates 37 Types OL ACHONS 0 A weed ance ena STH Wash aR Mat EN ER GER 40 Inserting Calls to ACASO oe PS QUI E 40 Insert Callto NeW gas y ete Desa tia ces enses oa s ae ls veste ea 41 Tns rt Call to Existing a R Capi t ra eGR Ae Re Re taa 42 Insetb Gallio COD c ute seis ehe Cd Sepe eerie ds E eee a 43 6 QTP Environment Variables 45 Types of Environment variables lt 3 2b baee a UE MI aaa eee Ea VE 45 Environment ODJeot 10 00 cum rr Re RESET AREA SO REFUS 46 7 NIC Gy OBIS oes A eee Geek KR AIR OR RETIRO lw AOA es 55 The Crypt OBJECT coved eee Byes ae die ete rh S VY ete e diris 55 he Optional Step Objeet aa v eta era da eared eae daa eee and as 56 The P tbFinder Objects arrainena or RP ate BRNO dece tot Aa ete Ripe vete oodd 56 The RandomNu mber Object exer er Ew A RE RR ee 57 AMG sedis Objectes seu S AE ES ae AEN Vade TN 57 The Web Obj cte a 59 The System tl OBJECT sra a
26. erations C Run one iteration only c to row C Run from row When error occurs during run session pop up message box y Dbject synchronization timeout 20000 milliseconds Disable Smart Identification during the run session Save image of desktop when error occurs if test is run by Mercury Business Process Monitor Cancel Apply Help Figure 4 4 Global data iterations NOTE We can use an external spreadsheet as a Data table by specifying the location of the file in the Resource Tab as shown in the Figure 4 4 We can set the iteration settings for an Action call by going into the keyword view and then right clicking on the Action and selecting Action Call Properties as shown in the Figure 4 5 QuickTest Professional Unplugged DataTables gt gt Setting data table iterations 31 Figure 4 5 Action Call Properties Keyword View The Action call properties dialog can be used to set the iterations as shown in the Figure 4 6 Figure 4 6 Action Call Properties dialog QuickTest Professional Unplugged 32 DataTables gt gt Data table object model Data table object model QTP provides an object model to access various properties and methods in a data table There are three types of objects O DataTable Represents all the global and local data tables in the test O DTSheet Represents a single sheet in the test O DTParameter Represents a single column in a
27. gelnbox IE Session Cookies Helper essen 413 VB2 OTPAPIGCOnVErCE vs d dam ree SATA vier eet ad utu du ae a 413 IB Web Developers rusa ex raa ey eaa ae neut ua vd a eee 413 destDesien stadio TDS x Toate vitet quond AP eek A Us de tuis 415 RAD Regular Expression Designers c4 cot v vA RERO PETER CURE AA AEG 416 Appendix A Problems discussed in the book A I Appendix B Index sss s s s sese eee AS RE SR SS B 1 QuickTest Professional Unplugged xii Preface I started with Web testing Automation in mid 2004 by creating a project in Visual Basic 6 using the Internet explorer COM Automation The project was a great success but with every change to the application the Automation Code had to be updated and recompiled Trying to find a solution to this maintenance issue I stumbled upon QuickTest Professional 8 0 QTP QuickTest Professional is a Test Automation tool and uses VBScript as its scripting language QTP is a record and playback tool which can record events we perform on an application and replay them back QTP is an object based tool which recognizes each element of the application as an object and provides various methods to work on them All this makes look QTP an easy to use test tool The myth about Record amp Playback is that it makes people think that they do not need development skills for QTP but to create effective Automation Frameworks one needs to view QTP as a development tool and not as a testing
28. it iniia tapi Buster BB irtee chat ol Lined Test Beriani ice 1 Step Name Steps To Recreate a reni Summers Sinn Pinna nd Nri pras Capua Liuissda eval 9 Seep Lasch www matr cim Step D Cid on Te Lop Hk x 3 Emir th erie ki ana T Pnaund 7113 reg d Enter pasword as tarin Step5 Check on the Log button Seep 6 Clear the beer Running the above code will display the file as shown below Figure 16 2 Embedding File in test results Inserting Snapshots in Test Results This section describes various ways of inserting screen snapshots into the Test Results Method 1 Configure QTP to save a screen snapshot for every step Go to Zoo s Options Run Tab and set the option for Save step screen capture to results to Always as shown in the Figure 16 3 QuickTest Professional Unplugged Test Results gt gt Accessing Test Results at the end 167 These techniques have the following advantages over the ReportEvent method O Support for relative paths O Inserts HTML step information without having to use amp lt and amp gt etc HTML tags The Test Results produced using the script above is shown in the Figure 16 4 Figure 16 4 Custom Test results LAT nardo rrr DENIS NITE p Ex pe FeaTe2 Aaa 57 h Teri Linked Test ducers Rur Tine Deris Step Mame Desktop Image Lesen Teel Dernier 1 9 vB ione fais Step Passed EE a Perap pri Gaci Deisis Hcauh Depan image Test Puau
29. lt Browser Browser Page Page chkStatus oPg WebEdit username Check Checkpoint username If chkStatus Then MsgBox Passed Else MsgBox Failed End If Restrore the old filter value Reporter Filter oldFilter QuickTest Professional Unplugged Test Results gt gt Reporting Custom Steps 161 Reporting Custom Steps We can insert our own steps in the Test Results using the following statement Reporter ReportEvent lt EventStatus gt lt ReportStepName gt lt Details gt The lt EventStatus gt should use one of the following QTP built in variables O micPass Reports a step with passed status O micFail Reports a step with failed status O micWarning Reports a step with warning status micDone Reports a step with no status Get the actual link href actualLink Browser Browser Page Page Link Login GetROProperty L hret 1 If actualLink http mywebsite com login do Then Reporter ReportEvent micPass Validate Link Login Correct Link Else Reporter ReportEvent micFail Validate Login Wrong Link amp actualLink End if While the lt ReportStepName gt and Details parameters are plain text strings it is possible to embed HTML tags into these strings as follows HTML text to be entered sHTML amp 1t A target _New href http www mywebsite com Click Me lt A gt 8gt Add to reporter Reporter ReportEvent micDone Link sHTML QTP also
30. n 21 77 Object Spy 19 367 ObjRepType 342 Oct 132 On Error Resume Next 107 OnReplayError 342 Open Test Architecture OTA 324 Optional arguments in VBScript 144 Using an Array of Key Value pairs 146 Using an Array of Key Value pairs 147 Using an Array of values 145 Using Null Empty values 144 OptionalStep Object 56 Outlook Application 270 Outlook Object model 269 Outlook Security Dialogs 276 P PathFinder Locate 57 330 PathFinder Object 56 PostMessage 184 Print Statement 372 Clearing the Print Window 373 Hiding the Print Window 372 Programmatically Capturing the Print Log text 374 Showing the Print window 373 Q QCUtil 370 QuickTest Professional Unplugged QCUtil Object 322 Quality Center 319 ResolveRelativePath 321 QuickTest Application 168 189 192 325 337 338 345 R RandomNumber Object 57 Recovery_LoginProxy 103 Recovery object 105 RegExp 117 RegisterUserFunc Object 60 RegularExpression 17 Regular Expressions 111 ReleaseDC 173 Replace 127 ReplaceMultipleByOne 141 ReplayType 156 Reporter Filter 160 Reporter LogEvent 166 Reporter ReportEvent 161 Reporter ReportPath 164 RepositoriesCollection 377 rfDisableAll 160 rfEnableAll 160 rfEnableErrorsAndWarnings 160 rfEnableErrorsOnly 160 Right 124 RTrim 127 RTrimW 119 RunAction 39 S Scripting Dictionary 71 148 149 166 169 257 298 349 354 Scripting FileSystemObject 48 161 167 168 169 240 255 329 345 347 405 Seconds 132
31. nci Cork im Prefexzonal Pp Bee mx bel Tol mi De Tho Pa A 24E vontak Dina Fim Bha Ya s D T Deita C REL uz E LE Lapeortar imparta L art lap pg LE Banach NOTE The images inserted using above method are also visible when results are viewed from Quality Center This was considered a impossible task till QTP 10 Accessing Test Results at the end QTP creates the results in the test results folder We may want to access these results at the end of the test script to save them to another location or to send them through email Let s say we want to copy the Results xml file which is created in the Report folder We can write the following code to perform this task in a QTP script Report a pass event Reporter ReportEvent micPass Testing Report Testing Exporting of Report Get the result directory sResultDir lt Environment ResultDir Copy the file to destination Set fso CreateObject Scripting FileSystemObject fso CopyFile sResultDir NReportMResults xml C Copy_ Results xml True Set fso Nothing QuickTest Professional Unplugged Appendix A Problems discussed in the book Problem 3 1 Working with Test Object properties 16 Problem 3 2 Changing Test Object properties at run time 17 Problem 3 3 Getting Run time Object properties during test execution 17 Problem 4 1 How to access a parameter from the glob
32. ng with the Command Tab 94 Working with the Variables Tab 93 Working with the Watch Expression Tab 92 DefaultObjRepType 343 DefaultTSRFilePath 343 Descriptive programming 77 Browser identification Issue 87 Browser Identification using a unique OpenURL Property 88 Browser identification using OpenTitle 87 Converting an OR based script to a DP based script 81 Enumerating ChildObjects 80 Implicit Properties 78 Problems with Ordinal Identifiers 84 Using a VBScript DP object repository 83 Using description objects 78 Using Description Strings 80 When to use Descriptive Programming 78 Working with Multiple Browser 86 Desktop CaptureBitmap 164 DisableReplayUsingAlgorithm 342 Document Object 197 DotNetFactory 377 Net Arrays Revisited 387 Accessing the Registry 386 Converting Images to other File Formats 390 Evaluating Keyboard Control Key Status 386 Getting Computer Information 385 Getting user Input using NET Forms 392 Passing Enums 383 Passing Parameters to NET Objects 382 Passing Parameters to Class Constructors 381 Ping an IP Address 386 Playing a Wav File 385 Sending Emails using NET 389 Using the DotNetFactory Object 381 Working with NET Arrays 384 Working with Net Date and Time Formatting 388 Working with Net Queues 388 Working with Net Stacks 387 Working with the Clipboard 385 DownloadAttachments 329 QuickTest Professional Unplugged Dynamic Arrays 142 E Encrypt 55 EnumerateAllTestSets 334 EnumerateAllTestsin
33. nt to understand in what situations the global or a local data table should be used Consider the following two scenarios Scenario 1 Log into the application book 1 ticket log out Repeat the scenario for many users Scenario 2 Log into the application book 3 tickets and log out Scenario 1 The Global data table is better suited for this scenario where we have the user name password and tickets details as the parameters and we execute the scenario using a single action which does everything or multiple actions Login booking and logout QuickTest Professional Unplugged 30 DataTables gt gt Setting data table iterations Scenario 2 A Local data table is better suited for this scenario Here a good approach would be to split the test into three actions login booking and logout Login and logout can use the username and password parameters from the global data table and booking can use ticket detail parameters from its local data table and the action will be executed for all rows in its local data table Setting data table iterations To run a test case for some number of iterations we need to set the iterations of global data table in the Test Settings dialog which is invoked using 7est Settings Run Tab Figure 4 4 shows the iteration settings for the global table These settings are specific to script Test Settings x Properties Run Resources Parameters Environment Web Recovery Data T able it
34. o RAR SS GS 151 Synchronization POIDS redi us ia id ia d RE Ry aed 151 Ist Method Using the Sync method lees 151 2nd Method Using the Wait statement 152 3rd Method WaitProperty method 152 Checking Object Existence cosa wesw ved Bre a Se I a ae 152 Browser Vs Page Syl oda ans ite nang So edged aoe ee P Ee QUE RIS 153 IP VOUS EE 153 Replay Opinions sania hati ext Sse Gaels a Re Dt ed ot eee ome 155 I6 Test Results va dde E ieee SAR REP Raw a SWEETS RE 159 Filtering Steps in a Report ss Drain 3 ORO NOS Rieder has 160 Reporting Custom Steps ios cetus svou Ur e n D eb Pee ane Geechee PRA 161 Inserting Files in Test Results i ea bi er Cer es de UE E om e e 161 Inserting Snapshots in Test Results 162 Converting XML Results to HTML oo etu qua pr aA EP OE S RA E RR Wu VS 164 Configuring QTP to generate HTML results 164 The O TP Reporter Object soos ua vct A derat dee 165 Accessing Test Results at the end ono cae te eee AE ERI IS 167 17 Working with APIs 171 Exter object PETITS 171 VBAPI Definition Syntax iive A coved R a a ad 171 OTP ART Dcdo 17153 Fete TTT A 172 OTPAP Inman ves asa A A tho E e a 176 API using COM Objects in YRO ae CER Re ER CERO rn 176 Runumnmo API using e T e satis tats pee es SE
35. on betweendifferent machines sun 337 Enumerating the Setting Variables 338 Setting Persistencer veria osten A ee a A a ies 343 Stop and Re Run OTP using Code ac see a 344 Adding Recovery Scenarios at Run time 345 Executing code when Script ends sesak kaka 346 Making an Object visible on a Web Page 348 Advanced Text Checkpoints copia pase ed PS en an pe RU ae cane 348 Extending Test Objects using Classes llle 355 Using JScript in OTR sid A Rt RR RUE GE Gee ROREM e aes 357 Passing variable number of arguments to a function 358 SCOPE GIN ErCNCeS osa a aA RR ET 358 Using Try Cate block lt 50 ood ti eens a ee wie WORT R 359 Working with JScript Atfaysa dlls eae nd tev SACCO ERES SU PE HS e 360 Working with JS classes ee eoe ke a CUR RC RC aL d 3 RG GS AR 360 Object Class Mapping scx cu eer d ee a a See rna XR A ASIE TR n 361 What s New in QTP 9 2 ies rr Rhe RATS Ie RRS Certo 365 IDE Enhancerfient sco tee oss eco oe ERR e p UR b p e ados AA S 365 ODESSA ei atcur aux Ui tU Ert EL 367 Web Drag and Drop Support cag pex EX ee V EY HEU S ORE eo 368 Ia UR es e e200 A AS PAM teers duet aso Pac ANA 368 New Configuration Options sc xem xa en rupe nee Ea Pen ru e e 369 Object Repository Enhancements eee 370 QuickTest Professional Unplugged Added and Enhanced Utility
36. or reviewing my work in progress and providing me with many useful comments and suggestions Mark smith Terry Horwath and Siddharth N Kanoujia Mark works as a freelance contractor and can be contacted on Ouicktest gmail com Terry has not only worked as a reviewer but also as a Technical editor for this book Terry has worked with automated testing tools since the early 90 s when he started designing solutions with Segue s QA Partner 1 0 He transitioned to Mercury Interactive tools in 1999 and has worked exclusively with QuickTest Professional since 2005 He can be contacted on thorwath lakefolsom com Siddharth has worked as a editor for this book and has done a great job making sure that contents of this book are lucid and unambiguous for the beginners He is an Assistant Professor in the Department of English at Hindu College University of Delhi He can be contacted on kandidsid gmail com I would especially like to thank my family and friends who have always motivated me while I was working on this book Quotes From Reviewers I find this to be a very pragmatic hand Y on book for those who want to extend their OTP skills beyond basic expert view programming This book is written by a QTP master for those who wish to eventually become masters themselves Terry Tarun Lalwani has singlehandedly helped thousands of people to expand their knowledge of QuickTest Professional Here is a book the automated testing community has been cr
37. ow can we get the value of a Windows Environment variable Note that QTP environment variables differ from Windows environment variables 172 Problem 17 3 How can we check select an item in a List box using a Windows API 172 Problem 17 4 How can we get the background color of a text box helpful when a color for a mandatory field is different than an optional color n s uuasaaaaaaaa 173 Problem 17 5 How can we simulate a keyboard event using the Windows APIs 173 Problem 17 6 How can we prevent a PC from being locked by its screen saver 175 Problem 17 7 How can we maximize a window or a browser 176 Problem 17 8 How can we download a file from a URL to disk 176 Problem 18 1 How can we use AOM to run a QTP test case 189 Problem 18 2 How can we use AOM to change the starting and ending iterations for cremari aH MP LEE 190 Problem 18 3 How can we use AOM to launch QTP on a remote machine 192 Problem 21 1 How can we copy an XML file and save it to another XML file 232 Problem 21 2 How can we get an entire XML file into a string and then save it to another XML file using that Ssmng 7 Ee eer RR ew NER e E aaa 233 Problem 21 3 How can we create the following XML code at run time in QTP and then sayeat toan XME AE p02 adie Ss Oye d PER cho Sa RA o Siete O 233 Problem 21 4 How can we load environment variables from mul
38. qu dd 107 3 Regular Expressions vos is Wa aS Ro CR Rr ARA AA RRA lll Regular Expression Characters Se aWwehaou XAR 112 When to use Regular Expressions in QTP 115 Testing a Regular Expression Using Code 117 Using a Regular Expression to Select a WebList or WebRadioGroup Value 118 Extracting Information Using a Regular Expression 118 Replacing Data from a String Using a Regular Expression 119 ld VBSCHIBE A SX RO EE NG IATA EIA 123 SUES nora cd dre ie TA AN eB cu ode cud aw AR Sui 123 Conversion function ti ta Ex ERR REVERSE Gu er AN Ra ac ds 131 Dats ane Time LUCHO 3 9 ce riot A es Sa Ua ARAS AAA 132 1 EA Er D SAL A tt ES TO E O Ecl LS 135 TypeName ci ad eee EA ee ee eate 135 Var VDC ig tude ain bad SO rr 135 CARL cM hxc Ad e Smee kad St ale S Gone Gated T 135 CreateObject ua oe Od secs AAA AA Bae Wee b UR ACRES 136 GetObjee t bee d Loos utter teh p eR wt aeo e EA eek ea pde an 136 Working AS as ananena Ace ed E rr LUE 142 bixed lengtb arrays evi dines EXE ga rx ed AS KT da 142 QuickTest Professional Unplugged vi Dynamic ATLAS T cases tas potete a dixe eae T Vd CI EE 142 Execute Statement saca toes seed PAE eae ew es Ue aoe eee ee 143 Eval function essa oer RO ta DP To A Nog tig area tel iu iem dole 144 Optional arguments in VBScript 20 0 0 cee eee ene 144 I5 SVNCHFONIZALION 030 a T Se D Y
39. ronment variable cleared or destroyed 51 Problem 6 7 How an object is passed using an environment variable 51 Problem 6 8 How an array is passed using Environment variables 52 Problem 6 9 How are environment variables loaded from an external XML file 52 Problem 8 1 How can we check if a checkpoint passed or failed 64 Problem 9 1 How are global variables defined at run time 72 Problem 12 1 How can we get the status of an Action as Pass Fail at the end of the ACTON so cse E pr Deleg tuo NE Soo duties E Za Ryo Cees ae 102 Problem 13 1 What will the regular expression be for a domain which can have 55 66 55 66 possible value of test app com qa app com www app com 114 Problem 14 1 How can we find the current page and the total page values from the String A ene eee nee tone eee ed ims a ee visti 125 Problem 14 2 How can we count the number of if phrases in the if if 2 PS SUTTER Ln eU Ua c te Mh ig citi Sag he Wi ace Md ci aT cele get ed nach 125 Problem 14 3 Given a complete file path specification extract the filename file path and drive letter from the specification 0 4 sae ee 0e ide Wad heaves nee Sa t Zoek ead 127 Problem 14 4 Let s revisit the page number extraction problem again How can we Problem 14 6 How can the number of business working days be calculated bet
40. s of QTP Working with external tools Microsoft Word Outlook Excel Integrating QTP Scripts with Quality Center Real life Automation problems and their solutions Quotes from reviewers find this to be a very pragmatic hand s on book for those who want to extend their QTP skills beyond basic expert view programming This book is written by a QTP master for those who wish to eventually become masters themselves Terry Tarun Lalwani has singlehandedly helped thousands of people to expand their knowledge of QuickTest Professional Here is a book the automated testing community has been crying out for This book will help QTP practitioners from beginner to expert have used QTP from V6 0 and during the review learnt something from every chapter Mark For support amp queries please use http Knowledgelnbox com forums
41. s well O A Cross X icon denotes a failed step O An Exclamation icon denotes a warning step O A Tick Y icon denotes a passed step QuickTest Professional Unplugged 160 Test Results gt gt Filtering Steps in a Report A step without any of these symbols denotes an information step QTP assigns status to a step based on one of the follow situations Checkpoint Checkpoint can cause a step to pass or fail Smart Identification If Smart identification is used to identify an object then that step is assigned the warning icon Error If a step encounters any error it will be assigned the failed icon Custom events Custom events are used to directly assign a step an explicit status Filtering Steps in a Report It is possible to control what types of steps are written to the test results using the following statement Reporter Filter lt Filter Value gt The lt Filter Value gt must use one of the following QTP built in variables rfEnableAll Report all steps This is the default setting rfEnableErrorsAndWarnings Only report error failed and warning steps rfEnableErrorsOnly Only report error steps rfDisableAll Does not report any steps The following code shows how to suppress a single checkpoint s pass fail status Store the old filter value oldFilter Reporter Filter Disable reporting of all events Reporter Filter rfDisableAll Set oPg
42. sheet Each object has certain functions available and certain properties associated with it These are explained in detail in the QTP user manual Data table formatting When data is entered into the data table it automatically formats the value using the best possible matching format For example if 12345678901 is entered into a cell then it would be auto formatted to 1 23456789E 010 In situations where the formats are important the data should be entered with care If data entered in the cell start with a single quote then it is always treated as a text and no format conversion is performed We can also define a specific format by right clicking the cell or an entire column and then picking a specific format from the popup context menu Problem 4 1 How to access a parameter from the global data sheet There are a variety of ways to access a parameter from the global data table most of which are presented in the following code snippet Methods of getting a Data Table value val DataTable Value ParamName dtGlobalSheet val DataTable Value ParamName Global By giving the sheet index starting from 1 for the global sheet val DataTable Value ParamName 1 Sheet name or id is a optional parameter and is assumed to be as for global data sheet in case not provided val DataTable Value ParamName Value property is the default property of the DataTable object so DataTable ParamName dtGlobalSheet
43. sibility for specifying which marks are owned by which companies or organizations Copyright 2008 Mercury Interactive Israel Ltd Reproduced with permission LIMIT OF LIABILITY DISCLAIMER OF WARRANTY THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL ACCOUNTING OR OTHER PROFESSIONAL SERVICES IF PROFESSIONAL ASSISTANCE IS REQUIRED THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS ACITATION AND ORA POTENTIALSOURCE OF FURTHER INFORMATION DOES NOTMEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE FURTHER READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ QuickTest Professional Unplugged Contents A oa an E Waele V S GRA VA QNIN V a NTE
44. ter 1 to 18 cover features related to QTP while the chapters in the Advanced section cover integration interaction of QTP with various external tools like Outlook Word Excel and Quality Center The book discusses a lot of issues that are commonly faced while using various features of QTP and their resolution This book discusses almost all the topics of QTP which one would require to create complex frameworks QuickTest Professional Unplugged xiii Who This Book Is For This book is for Test engineers Test Analysts Test Consultants Test Managers and anyone who is interested in learning advanced techniques of problem solving in QTP This book is also for beginners who have just started with QTP and want to be experts in its use The book assumes that one has the basic knowledge of QTP and VBScript if not than it is advised that one should go through the basic help first As the main focus of this book is to view the tool from a developer s eye the book does not teach how to record and replay script in QTP Also the book does not discuss about the Keyword view of QTP which is for non technical people who don t want to code in QTP Feedback and Queries For any feedback or queries you contact the author at ttp Knowledgelnbox com contact me or post a query on the KnowledgeInbox forums http Knowledgeinbox com forums QuickTest Professional Unplugged xiv Acknowledgements The following individuals deserve a special mention f
45. tiple XML files 234 Problem 21 5 How can we modify the contents of an XML nle7 nnn nanannannaan 236 Problem 21 6 How can we export a part of XML to a DataTable 237 Problem 21 7 How can we extract XML from a URL or Web browser 238 Problem 21 8 How can we compare two XML documents for equality 238 Problem 21 9 How can we compare two xml file with different ordering of nodes 238 Problem 22 1 How can we execute a query to access all records 246 QuickTest Professional Unplugged A 3 A 4 Problem 22 2 How can we determine the number of rows altered by an update or a LT UT UA e Saleen OPA Raa A A Rb A E 248 Problem 23 1 How can we invoke and terminate an instance of Excel 254 Problem 23 2 How can we create a new excel sheet and then save 1t 254 Problem 23 3 How can we determine if an Excel file exists and if not how to Create ONET us aua uacua O co etd dE ar a E quu e Dd quta D a A s 255 Problem 23 4 How can we access all non blank row values in a specific column 256 Problem 23 5 How can we search for a text string and then update another cell s valuen that rW oos Vase e Ow Ta aE E quei E Ree Gees eae bee a ER RA CEA HINTS 256 Problem 23 6 How can we use an Excel sheet as a QTP output Data Table 231 Problem 23 7 How can we allow a user to select a file to be opened 258
46. verting VBA to VBScript 0 00 258 Performance Enhancements NNUS RUE RA ERES SES 264 24 Working with Microsoft Outlook 269 Outlook Object model NE tuo S ERE AMOR dut atis 269 Launching the Outlook Application eee eese 270 QuickTest Professional Unplugged vii viii 25 26 Logging in to the Namespace SERRE Cx debes 270 Enumerating the top level folder 270 Getting a Folder interactively from a user 272 Getting the default folders SP WIRD eue Sua iw Pre NATUR 272 Reading e mail Messages 445 ty ida hos a UR DR Da ce VH SNR A E an 273 Accessing e mail Message Properties 274 Downloading attachments iw wes eas ood E qa eee eae T EE 275 Sending an E mail Message 275 Outlook Security Dialogs TEE EUR aaa 276 Getting addresses from e mail messages 279 Extended Email Address CAS OTROS NA RD 279 Clicking links inside an e mail message 280 Launching QTP using an email trigger 281 Working with Microsoft Word 285 Word Automation Object Model ses een 285 Working with Microsoft Internet Explorer 295 Launching Internet Explorer IB 5 as ea
47. ween two dates i e difference should exclude the weekends 133 Problem 14 7 Get a sub string in a string between two specified characters 136 Problem 14 8 Function to get a substring from a start character ina string 137 Problem 14 9 Write a function that reads a string word by word where two words would be separated by one or more SpacCes ss err eee 138 Problem 14 10 Create a function TrimAll which trims not only spaces but other Problem 14 11 Create a FilterStr function which takes a string and character set as input and will filter the string based on the characters in the character set 139 Problem 14 12 Create two functions one which returns the path portion and another the file name when passed a fully qualified path or filename 140 Problem 14 13 Write a function that compares two string ignoring new line line feeds QuickTest Professional Unplugged Problem 14 14 Write a function that replaces repeated occurrences of a given character ds eee dca ky jee cotes pd el sue utile E atu ate Soo Chale aes 141 Problem 14 15 How can we get the UBound LBound values of multi dimensional dIPd cast eas es e e et Te od enc See te ea een 143 Problem 14 16 How can we declare and initialize a read only variable at run time 144 Problem 17 1 How can we determine if the topmost window on the desktop is a Problem 17 2 H
48. while QTP displays the parameter as the column titles Therefore when viewed using Excel the 2nd row starts the 1st row of data in the DataTable The DataTable shown above has only 2 data rows enabled Note that QTP makes a data row enabled by marking the borders of the row in the actual spreadsheet A row with no data but with marked borders is still considered as an enabled row by QTP To delete an enabled row we must select the row and delete it from the context menu which appears on right clicking the row QuickTest Professional Unplugged DataTables gt gt Design and run time data table 29 Design and run time data table Design time data table As the name suggest the data table during the script design time is known as design time data table Any changes to this are saved when the script is saved Run time data table The run time data table contains a copy of the design time data table when a script is executed It may contain values that are changed during script execution and are presented in the test result summary The changes made to the data table during run time are not saved to design time data table Figure 4 3 shows arun time data table from the test results summary ER pem jai eh L Kd EH amp L tra TELE LUR rei er acord aa Peaewon G LUR rte fest mior ZH a en E xh bba CAY ELTE Figure 4 3 Run time data table When to use the global or a local data table It is importa
49. ying out for This book will help QTP practitioners from beginner to expert I have used OTP from V6 0 and during the review I learnt something from every chapter Mark After long brainstorming sessions with Tarun over almost each and every sentence I realized that I am truly in the presence of a genius Tarun has with his dedication and perseverance made possible a book which will go a long way in helping people understand the ins and outs of OTP Siddharth QuickTest Professional Unplugged Chapter 4 DataTables A DataTable provides a way to create data driven test cases It is similar to MS Excel spreadsheets and can be used to run an Action multiple times Each test case has one global data sheet which is accessible to all actions inside that test case and each action has its own private data table also known as local data table The name local data table is somewhat misleading because it is in fact possible to access any action s local data table from any other action but the way of accessing the data becomes a bit different Lel ais Tean ide bea Pesdencionel D pde eer poet Jer Bep Eba Tee ie Cake AR FO ORE Steud amp m ae o Bal acm 7 e ar hiamh p DD AZ last BR as N nnn Peri C D E F G H L i E 1 west Weit i F Ex fer E 5 amp T E E if i BZ 13 leh Gibal A East 7 fal Figure 4 1 DataTable Figure 4 1 shows a sample DataTable with 2 parameters Username

Download Pdf Manuals

image

Related Search

Related Contents

Denver TCD 29-Silan French  Elo Touch Solution 3243L  Système Bosch - Gamme Performance  Panasonic VB-44225 Corded Phone (pandbsvb44225)  Philips TriActive vacuum cleaner nozzle FC6089  e+p B 330  

Copyright © All rights reserved.
Failed to retrieve file