Setting Custom Attributes

Silk Test Workbench 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. You can use any property that is available in the respective technology as a custom attribute given that they are either numbers (integers, doubles), strings, item identifiers, or enumeration values.

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.

For the technology domains listed in the list box on the Custom Attributes tab, 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, add a custom automation ID to the elements that you want to interact with in your test. In Web applications, you can add an attribute to the element that you want to interact with, such as <div myAutomationId= "my unique element name" />. Or, in Java SWT, the developer implementing the GUI can define an attribute (for example testAutomationId) for a widget that uniquely identifies the widget in the application. A tester can then add that attribute to the list of custom attributes (in this case, testAutomationId), and can identify controls by that unique ID. This approach can eliminate the maintenance associated with locator changes.

If multiple objects share the same attribute value, such as a caption, Silk Test Workbench tries to make the locator unique by combining multiple available attributes with the "and" operation and thus further narrowing down the list of matching objects to a single object. Should that fail, an index is appended. Meaning the locator looks for the nth control with the caption xyz.

If more than one object is assigned the same custom attribute value, all the objects with that value will return when you call the custom attribute. For example, if you assign the unique ID, loginName to two different text fields, both fields will return when you call the loginName attribute.

  1. Click Tools > Options.
  2. Click the plus sign (+) next to Record in the Options menu tree.
    The Record options display in the right side panel.
  3. Click the technology domain for the application that you are testing. For example, if you are testing an SAP application, click SAP in the menu tree.
    Note: You cannot set custom attributes for Flex or Windows API-based client/server (Win32) applications.
  4. In the Custom attributes text box, type the attributes that you want to use. If custom attributes are available, the locator generator uses these attributes before any other attribute. The order of the list also represents the priority in which the attributes are used by the locator generator. If the attributes that you specify are not available for the objects that you select, Silk Test Workbench uses the default attributes for the application that you are testing.

    Separate attribute names with a comma.

    Note: To include custom attributes in a web application, add them to the html tag. For example type, <input type='button' bcauid='abc' value='click me' /> to add an attribute called bcauid.
    Note: To include custom attributes in a Java SWT control, use the org.swt.widgets.Widget.setData(String key, Object value) method.
    Note: To include custom attributes in a Swing control, use the putClientProperty("propertyName", "propertyValue") method.
  5. Click OK.