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.
|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 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 Classic 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 a automationId and a name, Silk Test Classic uses the automationId when creating the locator.
The following table shows how an application developer can define a Silverlight button with the text Ok in the XAML code of the application:
|XAML Code for the Object||Locator to Find the Object from Silk Test|