The Open Agent includes a sophisticated locator generator mechanism that guarantees locators are unique at the time of recording and are easy to maintain. Depending on your application and the frameworks that you use, you might want to modify the default settings to achieve the best results and stable recognition of the controls in your application. You can use any property that is available in the respective technology as a custom attribute, given that the property is either a number, like an integer or a double, a string, an item identifier, or an enumeration value.
A well-defined locator relies on attributes that change infrequently and therefore requires less maintenance. Using a custom attribute is more reliable than other attributes like caption or index, since a caption will change when you translate the application into another language, and the index might change when another object is added.
In xBrowser, WPF, Java SWT, and Swing applications, you can also retrieve arbitrary properties, such as a WPFButton that defines myCustomProperty, and then use those properties as custom attributes. To achieve optimal results, the application developers can add a custom automation ID to the controls that you want to interact with in your test. In Web applications, the application developers can add an attribute to controls that you want to interact with, such as <div myAutomationId=”my unique element name” />. This approach can eliminate the maintenance associated with locator changes. Or, in Java SWT, the UI developer can define a custom attribute, for example testAutomationId, for a widget that uniquely identifies the widget in the application. You can then add that attribute to the list of custom attributes, in this case testAutomationId, and you can then identify controls by that unique ID. This approach can eliminate the maintenance associated with locator changes.
If more than one objects have the same custom attribute value assigned, all the objects with that value will be returned when you call the custom attribute. For example, if you assign the unique ID loginName to two different text boxes, both text boxes will be returned when you call the loginName attribute.
To define which custom attributes of a locator should be used for the recognition of the controls in your AUT: