Hi Guys,
I am working with UI testing in WPF.
As we know for UI testing we need to know the controls name or unique ID in WPF.
Let me give examples sequentially,
1.
<Window x:Class="CustomControlProj.MainWindow"
xmlns="http:
xmlns:x="http:
xmlns:uc="clr-namespace:CustomControlLibrary;assembly=CustomControlLibrary">
I can identify window by name "u1" above.
2. <TextBox Name="text1" Grid.Row="2" Grid.Column="2" Text="{Binding ElementName=nud, Path=DecimalPlaces}"/>
I can get it using "text1" Name propert's value.
3. For Custom Controls,
<Viewbox Grid.Row="3" Grid.ColumnSpan="3" Width="400">
<uc:NumericUpDown x:Name="nud" Change=".01" Margin="10"/>
</Viewbox>
Here, NumericUpDown is CustomControl, I can identify it using OnCreateAutomationProperty of custom control class.
Butt......
4. If I have items control then how to identify unique id (Automation ID)...???
<ItemsControl Grid.Column="0" Grid.Row="1" FontWeight="Normal" ItemsSource="{Binding Path=Configurations, Mode=TwoWay}" Width="Auto">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid
Margin="20,20,20,20"
Width="Auto"
VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock
Foreground="Black"
HorizontalAlignment="Left"
Text="{Binding Path=Title, Mode=TwoWay}" />
<TextBox
Width="230"
FontWeight="Normal"
Text="{Binding Path=Value, Mode=TwoWay}"
Focusable="True"
Name="ADTConfiguration"
HorizontalAlignment="Left"
VerticalAlignment="Center">
</TextBox>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Here, ItemsControl does not have the OncreateAutomationUI for ItemsControl control.
I need to fetch unique id for Items Control in WPF window for UI Automation?
Thank you :)