Custom Attributes for Web Applications

HTML defines a common attribute ID that can represent a stable identifier. By definition, the ID uniquely identifies an element within a document. Only one element with a specific ID can exist in a document.

However, in many cases, and especially with AJAX applications, the ID is used to dynamically identify the associated server handler for the HTML element, meaning that the ID changes with each creation of the Web document. In such a case the ID is not a stable identifier and is not suitable to identify UI controls in a Web application.

A better alternative for Web applications is to introduce a new custom HTML attribute that is exclusively used to expose UI control information to Silk Test Workbench.

Custom HTML attributes are ignored by browsers and by that do not change the behavior of the AUT. They are accessible through the DOM of the browser. Silk Test Workbench allows you to configure the attribute that you want to use as the default attribute for identification, even if the attribute is a custom attribute of the control class. To set the custom attribute as the default identification attribute for a specific technology domain, click Tools > Options > Record and select the technology domain.

Example: Changing ID

The application developer just needs to add the additional HTML attribute to the Web element.

Original HTML code:
<A HREF="http://abc.com/control=4543772788784322..." <IMG
src="http://abc.com/xxx.gif" width=16 height=16> </A>
HTML code with the new custom HTML attribute AUTOMATION_ID:
<A HREF="http://abc.com/control=4543772788784322..."
AUTOMATION_ID = "AID_Login" <IMG src="http://abc.com/xxx.gif"
width=16 height=16> </A>
When configuring the custom attributes, Silk Test Workbench uses the custom attribute to construct a unique locator whenever possible. Web locators look like the following:
…//DomLink[@AUTOMATION_ID='AID_Login'
One example of a changing ID is the Google Widget Toolkit (GWT), where the ID often holds a dynamic value which changes with every creation of the Web document:
ID = 'gwt-uid-<nnn>'
In this case <nnn> changes frequently.