While learning an object, QuickTest can assign a value to the test object's Index property 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.
Index property values are object-specific. Therefore, if you use Index:=3 to describe a WebEdit test object, QuickTest searches for the fourth WebEdit object in the page. However, if you use Index:=3 to describe a WebElement object, 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 a page contains the following objects:
- an image with the name Apple
- an image with the name UserName
- a WebEdit object with the name UserName
- an image with the name Password
- a WebEdit object with the name Password
The following statement refers to the third item in the list, as this is the first WebEdit object on the page with the name UserName:
WebEdit("Name:=UserName", "Index:=0")
In contrast, the following statement refers to the second item in the list, as that is the first object of any type (WebElement) with the name UserName:
WebElement("Name:=UserName", "Index:=0")
No comments:
Post a Comment