For additional information on dynamic locator attributes, see Dynamic Locator Attributes.
To identify components within Silverlight 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 //SLButton[@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. | //SLButton[@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. | //SLButton[@caption="Ok"] |
className | The simple .NET class name (without namespace) of the Silverlight control. Using the className attribute can help to identify a custom control that is derived from a standard Silverlight control that Silk Test Workbench recognizes. | //SLButton[@className='MyCustomButton'] |
name | The name of a control. Can be provided by the developer of the application under test. | //SLButton[@name="okButton"] |
During recording, Silk Test Workbench creates a locator for a Silverlight 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 Workbench uses the automationId, if it is unique, when creating the locator.
XAML Code for the Object | Locator to Find the Object from Silk Test |
---|---|
<Button>Ok</Button> | //SLButton[@caption="Ok"] |
<Button Name="okButton">Ok</Button> | //SLButton[@automationId="okButton"] |
<Button AutomationProperties.AutomationId="okButton">Ok</Button> | //SLButton[@automationId="okButton"] |
<Button AutomationProperties.Name="okButton">Ok</Button> | //SLButton[@name="okButton"] |