This is a mirror of official site: http://jasper-net.blogspot.com/

Assigning Unique AutomationId for Silverlight XAML Controls

| Wednesday, December 22, 2010
If you want to run coded UI tests or create action recordings for your Silverlight 4 application, you must have a unique automation property that identifies each control. For more information about how to set up your Silverlight application so that the controls are recognized, see How to: Set Up Your Silverlight Application for Testing.

Static XAML Definition
To specify a unique automation property for a control that is defined in your XAML file, you can set the AutomationProperties.AutomationId or AutomationProperties.Name implicitly or explicitly, as shown in the following examples. Setting either of these values gives the control a unique automation property that can be used to identify the control when you create a coded UI test or action recording.

Set the Property Implicitly

Set the AutomationProperties.AutomationId to ButtonX using the Name property in the XAML for the control.

<Button Name="ButtonX" Height="31" HorizontalAlignment="Left" Margin="23,26,0,0"  VerticalAlignment="Top" Width="140" Click="ButtonX_Click" />

Set the Property Explicitly

Set the AutomationProperties.AutomationId to ButtonX explicitly in the XAML for the control.

<Button AutomationProperties.AutomationId=“ButtonX” Height="31" HorizontalAlignment="Left" Margin="23,26,0,0"  VerticalAlignment="Top" Width="140" Click="ButtonX_Click" />

Read more: Vishnu's Blog

Posted via email from .NET Info

0 comments: