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 Silk4NET 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, Silk4NET 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, Silk4NET 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.