Locator Attributes for Identifying Controls with UI Automation

The supported locator attributes for controls in Windows-based applications that have implemented UI Automation provider interfaces include:
  • automationId
  • caption
  • className
  • name
  • All dynamic locator attributes
Note: Attribute names are case sensitive. 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 additional information on dynamic locator attributes, see Dynamic Locator Attributes.

To identify controls in Windows-based applications that have implemented UI Automation provider interfaces within scripts, you can specify the automationId, caption, className, name or any dynamic locator attribute. The automationId can be set by the application developer. For example, a locator with an automationId might look like //UIAButton[@automationId="okButton"].

We recommend using the automationId because it is typically the most useful and stable attribute.

Attribute Type Description Example
automationId An identifier that is provided by the developer of the application under test. The Visual Studio designer automatically assigns an automationId to every control that is created with the designer. The application developer uses this ID to identify the control in the application code. //UIAButton[@automationId="okButton"]
caption The text that the control displays. When testing a localized application in multiple languages, use the automationId or name attribute instead of the caption. //UIAButton[@caption="Ok"]
className The class name (without namespace) of the UI Automation control. Using the className attribute can help to identify a custom control that is derived from a standard UI Automation control that Silk Test Classic recognizes. //UIAButton[@className='MyCustomButton']
name The name of a control. Can be provided by the developer of the application under test. //UIAButton[@name="okButton"]

During recording, Silk Test Classic creates a locator for a UI Automation control by using the automationId, name, caption, or className attributes in the order that they are listed in the preceding table. For example, if a control has an automationId and a name, Silk Test Classic uses the automationId, if it is unique, when creating the locator.

To find out which additional custom attributes you could use for the UI Automation controls in your AUT, you can use the Verify Properties dialog box. To do so, hover the mouse cursor over a UI Automation control during recording, and click Ctrl+Alt. You can then see which properties are available for the control. For example, for some applications, the attribute value is useful.