Thursday, March 20, 2008

FAQ - Automation - QTP (171 to 180)

171. In how many ways we can add check points to an application using QTP.

We can add checkpoints while recording the application or we can add after recording is completed using Active screen (Note : To perform the second one The Active screen must be enabled while recording).

172. How to Merge Object repositories?

With QTP 8.2 ,there is QTP Plus setup. It provides Repositories Merge Utility. The Object Repository Merge Utility enables user to merge Object repository files into a single Object repository file.

173. Explain the need to use analog recording in qtp?

This mode records exact mouse and Key Board operations you perform in relation to the screen /Application Window. This mode is useful for the operation which you can record at Object Level, such as drawing a picture, recording signature. The steps recorded using Analog Mode is saved in separated data file, Quick Tests add to your Test a Run Analog File statement that calls the recorded analog File. This file is stored with your action in which these Analog Steps are created. The Step recorded in Analog mode can not be edited within QT.

174. When and Why to use Descriptive programming?

Below are some of the situations when Descriptive Programming can be considered useful:
The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application,

Ex. “Logout <>”.
When object repository is getting huge due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing an object.
When you don’t want to use object repository at all.

175. Well the first question would be why not Object repository?

Consider the following scenario which would help understand why not object repository Scenario

1: Suppose we have a web application that has not been developed yet. Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing scenario

2: Suppose an application has 3 navigation buttons on each and every page. Let the buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page. Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well. When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.

176. How do I check if property exists or not in the collection?

The answer is that it’s not possible. Because whenever we try to access a property which is not defined its automatically added to the collection. The only way to determine is to check its value that is use a if statement “if obj_ChkDesc(“html tag”).value = empty then”.

177. How to browse through all the properties of a properties collection?

Two ways
                                For each desc in obj_ChkDesc
                                RE = desc.regularexpression
                                For i=0 to obj_ChkDesc.count - 1
                                Name= obj_ChkDesc(i).Name
                                Value= obj_ChkDesc(i).Value
                                RE = obj_ChkDesc(i).regularexpression

178. How can I check if a parameter exists in Datatable or not?

The best way would be to use the below code:
on error resume next
if err.number<> 0 then
‘Parameter does not exist
‘Parameter exists
end if

179. 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 explain some expects of Excel COM APIscode:
Set xlApp=Createobject(”Excel.Application”)
set xlWorkBook=xlApp.workbooks.add
set xlWorkSheet=xlWorkbook.worksheet.add
xlWorkSheet.Range(”A1:B10″).interior.colorindex = 34 ‘Change the color of the cells
xlWorkSheet.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 A
colsCount=xlWorkSheet.Evaluate(”COUNTA(1:1)”) ‘Will count the # of non blank columns in 1st row xlWorkbook.SaveAs “C:\Test.xls”
Set xlWorkSheet=Nothing
Set xlWorkBook=Nothing
set xlApp=Nothing

180. SMART Identification

Smart Identification is nothing but an algorithm used by QTP when it is not able to recognize one of the object. A very generic example as per the QTP manual would be, A photograph of a 8 year old girl and 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 to recognize 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.

No comments: