Custom Attributes

This functionality is supported only if you are using the Open Agent.

Add custom attributes to a test application to make a test more stable. You can use custom attributes with the following technologies:
  • Java SWT
  • Swing
  • WPF
  • xBrowser
  • Windows Forms
  • SAP

For example, in Java SWT, the developer implementing the GUI can define an attribute (for example, silkTestAutomationId) for a widget that uniquely identifies the widget in the application. A tester using Silk Test Classic 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 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 will change whenever another widget is added before the one you have defined already.

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 fields, both fields will return when you call the loginName attribute.

First, enable custom attributes for your application and then create the test.

Recording tests that use dynamic object recognition

Using custom class attributes becomes even more powerful when it is used in combination with dynamic object recognition. For example, If you create a button in the application that you want to test using the following code:

Button myButton = Button(parent, SWT.NONE);
myButton.setData("SilkTestAutomationId", "myButtonId");

To add the attribute to your XPath query string in your test case, you can use the following query:

Window button = Desktop.Find(".//PushButton[@SilkTestAutomationId='myButton']")