Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
QTP 8.2 Tips and Tricks

QTP 8.2 Tips and Tricks

|Views: 456|Likes:
Published by umadasdey

More info:

Published by: umadasdey on Apr 27, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





QTP 8.2 Tips & Tricks
Well this post is about tips on various topics. I will try to cover as many as i have in mind and would try tosummarize the tips that people have given on the forum
Data Table
Two Types of data tablesGlobaldata sheet: Accessible to all theactions Local data sheet: Accessible to the associated action only
DataTable("Column Name",dtGlobalSheet) for Global data sheetDataTable("Column Name",dtLocalSheet) for Local data sheetIf we change any thing in the Data Table at Run-Time the data is changed only in the run-time data table.The run-time data table is accessible only through then test result. The run-time data table can also beexported using DataTable.Export or DataTable.ExportSheet
How can I save the changes to my DataTable in the test itself?
Well QTPdoes notallow anything for saving therun timechanges to the actual data sheet. The only work  around is to share the spreadsheet and then access it using the Excel COM Api's.
How can I check if a parameter exists in DataTable or not?
The best way would be to use the below code:code:on error resume nextval=DataTable("ParamName",dtGlobalSheet)if err.number<> 0 then'Parameter does not existelse'Parameter existsend if <!--[if !supportEmptyParas]--> <!--[endif]-->
How can I make some rows colored in the data table?
Well you can't do it normally but you can use Excel COM API's do the same. Below code will explainsome expects of Excel COM APIscode:Set xlApp=Createobject("Excel.Application")set xlWorkBook=xlApp.workbooks.addset xlWorkSheet=xlWorkbook.worksheet.addxlWorkSheet.Range("A1:B10").interior.colorindex = 34 'Change the color of the cellsxlWorkSheet.Range("A1:A10").value="text" 'Will set values of all 10 rows to "text"xlWorkSheet.Cells(1,1).value="Text" 'Will set the value of first row and first colrowsCount=xlWorkSheet.Evaluate("COUNTA(A:A)") 'Will count the # of rows which have non blank value in the column AcolsCount=xlWorkSheet.Evaluate("COUNTA(1:1)") 'Will count the # of non blank columns in 1st row
xlWorkbook.SaveAs "C:\Test.xls"xlWorkBook.CloseSet xlWorkSheet=NothingSet xlWorkBook=Nothingset xlApp=Nothing<!--[if !supportEmptyParas]--> <!--[endif]-->
SMART Identification
Smart Identification is nothing but an algorithm used by QTP when it is not able to recognize one of theobject. A very generic example as per theQTP manual would be, A photograph of a8 year old girland boy and QTP records identification properties of that girl when she was 8, now when both are 10 years old then QTP would not be able torecognize the girl. But there is something that is still the same that is there is only one girl in the photograph. So it kind of PI (Programmed intelligence) not AI.
When should I use SMART Identification?
Something that people don't think about too much. But the thing is that you should disable SI whilecreating your test cases. So that you are able to recognize the objects that are dynamic or inconsistent intheir properties. When the script has been created, the SI should be enabled, so that the script does not failin case of small changes. But the developer of the script should always check for the test results to verifyif the SI feature was used to identify a object or not. Sometimes SI needs to be disabled for particular objects in the OR, this is advisable when you use SetTOProperty to change any of the TO properties of anobject and especially ordinal identifiers like index, location and creationtime.
Descriptive Programming
Descriptive programming is nothing but a technique using which operations can be performedon the AUTobject, which are not present in the OR. For more details refer tohttp://bondofus.tripod.com/QTP/DP_in_QTP.doc(right click and use save as...)
Recovery ScenariosWhat is a Recovery Scenario?
Recovery scenario gives you an option to take some action for recovering from a fatal error in the test. Theerror could range in from occasional to typical errors. Occasional error would be like "Out of paper" popup error while printing something and typical errors would be like "object is disabled" or "object notfound". A test case have more then one scenario associated with it and also have the priority or order inwhich it should be checked.
What does a Recovery Scenario consists of?
Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any popupwindow, any test error, particular stateof an object or anyapplication error .Action: Action defines what needs to be done if scenario has been triggered. It can consist of amouse/keyboard event, close application, call arecovery function defined in library file or restart windows. You can have a series of all the specifiedactions.Post-recovery operation: Basically defined what need to be done after the recovery action has been taken.It could be to repeat the step, move
to next step etc....
When to use a Recovery Scenario and when to us on error resume next?
Recovery scenarios are used when you cannot predict at what step the error can occur or when you knowthat error won't occur in your QTP script but could occur in the world outside QTP, again the example would be "out of paper", as thiserror is caused by printer device driver. "Onerror resume next" should be used when you know if an error is expected and dont want to raise it, youmay want to have different actionsdepending upon the error that occurred. Use err.number & err.description to get more details about theerror.
Library Files or VBScript FilesHow do we associate a library file with a test ?
Library files are files containing normal VBScript code. The file can contain function, sub procedure,classes etc.... You can also use executefilefunction to include a file at run-time also. To associate a library file with your script go to Test->Settings...and add your library file to resourcestab.
When to associate a library file with a test and when to use execute file?
When we associate a library file with the test, then all the functions within that library are available to allthe actions present in the test. Butwhen we use Executefile function to load a library file, then the function are available in the action thatcalled executefile. By associated a library toa test we share variables across action (global variables basically), using association also makes it possibleto execute code as soon as the scriptruns because while loading the script on startup QTP executes all the code on the global scope. We can useexecutefile in a library file associatedwith the test to load dynamic files and they will be available to all the actions in the test.
Add-insTest and Run-time ObjectWhat isthe difference betweenTest Objects and Run Time Objects ?
Test objects are basic and generic objects that QTP recognize. Run time object means the actual object towhich a test object maps.
Can i change properties of a test object
Yes. You can use SetTOProperty to change the test object properties. It is recommended that you switch

Activity (6)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
cvpazhani liked this
Praveen Reddy liked this
krish_varam liked this
Banashree Das liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->