I face a problem with ui-automation in WPF. I can not find items control through query in my test
rootElement.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.AutomationIdProperty, "AID_Positions")))
Its always return null. In the interface inspector, I see that the property is full and has correct value "AID_Positions".
My xaml
<ItemsControl
Grid.Row="1"
Grid.Column="1"
VirtualizingStackPanel.IsVirtualizing="True"
ScrollViewer.CanContentScroll="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
// data
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate>
<Border
SnapsToDevicePixels="True">
<ScrollViewer
AutomationProperties.AutomationId="AID_Positions">
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
I set 'AutomationProperties.AutomationId' property to ScrollViewer. What am I doing wrong?