Including Custom Attributes in a Test

You can include custom attributes in a test to make a test more stable. For example, in Java SWT, the developer implementing the GUI can define an attribute, such as silkTestAutomationId, for a widget that uniquely identifies the widget in the application. A tester using Silk4J can then add that attribute to the list of custom attributes (in this case, silkTestAutomationId), and can identify controls by that unique ID.

Using a unique ID 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 will change whenever another widget is added before the one you have defined already.

Note: You cannot set custom attributes for Flex or Windows API-based client/server (Win32) applications.
To include custom attributes in a test, include the custom attributes directly in the test that you create. For example, to find the first text box with the unique ID 'loginName' in your application, you can use the following query:
myWindow.find(".//TextField[@silkTestAutomationId='loginName']")
Note: Attribute names are case sensitive, except for mobile applications, where the attribute names are case insensitive. Attribute values are by default case insensitive, but you can change the default setting like any other option. The locator attributes support the wildcards ? and *.
For example in a Web application, to add an attribute called "bcauid" type:
 <input type='button' bcauid='abc'
value='click me' />
Note: Attribute names are case sensitive, except for mobile applications, where the attribute names are case insensitive. Attribute values are by default case insensitive, but you can change the default setting like any other option. The locator attributes support the wildcards ? and *.