Identifying an Object Using the Location Property

While learning an object, QuickTest can assign a value to the test object's Location property 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 identical properties. The first occurrence of the object is 0. Values are assigned in columns from top to bottom, and left to right.

Location property values are object-specific. Therefore, 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. However, if you use Location:=3 to describe a WinObject object, 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 a dialog box contains the following objects:

  • a button object with the name OK
  • a button object with the name Add/Remove
  • a check box object with the name Add/Remove
  • a button object with the name Help
  • a check box object with the name Check spelling

The following statement refers to the third item in the list, as this is the first check box object on the page with the name Add/Remove.

WinCheckBox("Name:=Add/Remove", "Location:=0")

In contrast, the following statement, refers to the second item in the list, as that is the first object of any type (WinObject) with the name Add/Remove.

WinObject("Name:=Add/Remove", "Location:=0")

No comments: