What is the difference between Index and Location in Object Identification In QTP

Showing Answers 1 - 2 of 2 Answers

Uday Kumar. A

  • Oct 5th, 2006
 

If QTP does not identify the object by mandatory properties and assistive properties, then it will go for selectors. Here the selectors are two types:1.Index and 2.Location.

By using Index, QTP addes the index at the end of the logical name to uniquely identify the object. Ex. If i have two OK button in the same page, then for the first object it assigns as OK_1 ane for the second object as OK_2 etc......

By using location, QTP identifies the objects in application, because two objects does not placed at the same location.

  Was this answer useful?  Yes

satyendra22

  • Oct 5th, 2006
 

In addition to recording the mandatory and assistive properties specified in the Object Identification dialog box, QuickTest can also record a backup ordinal identifier for each test object. The ordinal identifier assigns the object a numerical value that indicates its order relative to other objects with an otherwise identical description (objects that have the same values for all properties specified in the mandatory and assistive property lists). This ordered value enables QuickTest to create a unique description when the mandatory and assistive properties are not sufficient to do so. ---------------------------------------------------------------------------------------------------------------------------------There are two types of ordinal identifiers that QuickTest can use to identify an object: Index?Indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description. ................................................Location?Indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description. ---------------------------------------------------------------------------------------------------------------------------------Identifying an Object Using the Index Property -----------------------------------------------------------------------During recording, QuickTest can assign a value to the Index test object property of an object in order to uniquely identify the object. The value is based on the order in which the object appears within the source code. The first occurrence is 0. Note that Index property values are object-specific. Thus, if you use Index:=3 to describe a WebEdit test object, QuickTest searches for the fourth WebEdit object in the page. If you use Index:=3 to describe a WebElement object, however, QuickTest searches for the fourth Web object on the page regardless of the type, because the WebElement object applies to all Web objects. For example, suppose you have a page with the following objects: an image with the name Applean image with the name UserNamea WebEdit object with the name UserNamean image with the name Passworda WebEdit object with the name PasswordThe description below refers to the third item in the list above, as it is the first WebEdit object on the page with the name UserName. WebEdit("Name:=UserName", "Index:=0") The following description, however, refers to the second item in the list above, as that is the first object of any type (WebElement) with the name UserName. WebElement("Name:=UserName", "Index:=0") Identifying an Object Using the Location Property --------------------------------------------------------------------During recording, QuickTest can assign a value to the Location test object property of an object in order to uniquely identify the object. The value is based on the order in which the object appears within the window, frame, or dialog box, in relation to other objects with the same properties. The first occurrence of the object is 0. Values are assigned in columns from top to bottom, and left to right. For example, the radio buttons in the dialog box below are numbered according to their location property. Note that Location property values are object-specific. Thus, if you use Location:=3 to describe a WinButton test object, QuickTest searches from top to bottom, and left to right for the fourth WinButton object in the page. If you use Location:=3 to describe a WinObject object, however, QuickTest searches from top to bottom, and left to right for the fourth standard object on the page regardless of the type, because the WinObject object applies to all standard objects. For example, suppose you have a dialog box with the following objects: a button object with the name OKa button object with the name Add/Removea check box object with the name Add/Removea button object with the name Helpa check box object with the name Check spellingThe description below refers to the third item in the list above, as it is the first check box object on the page with the name Add/Remove. WinCheckBox("Name:=Add/Remove", "Location:=0") The following description, however, refers to the second item in the list above, as that is the first object of any type (WinObject) with the name Add/Remove. WinObject("Name:=Add/Remove", "Location:=0")

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions