I created a small WPF application (just to find out how Coded UI Testing works). My application contained ItemsControl , but UIMap Coding UI Test Builder could not find the corresponding control.
XAML :
<ItemsControl ItemsSource="{Binding Path=Customers, Mode=OneTime}" AutomationProperties.AutomationId="CustomersItemsControl"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock AutomationProperties.AutomationId="{Binding Path=Id, StringFormat='Customer_{0}', Mode=OneWay}" Margin="5"> <TextBlock.Text> <MultiBinding StringFormat="{}{1}, {0}"> <Binding Path="FirstName" /> <Binding Path="LastName" /> </MultiBinding> </TextBlock.Text> </TextBlock> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>
The problem is that even if WPF has ItemsControlAutomationPeer , the Coded Test Builder cannot find the control added to the UIMap. The only way I got TreeWalker.ControlViewWalker to get root AutomationElement and then use TreeWalker.ControlViewWalker (I used the code found in this answer ), however this solution donβt give me access to the control itself, just AutomationElement . Ideally, since for The control has AutomationPeer, I was wondering if there is a better way to get this control (even if it is not possible for UIMap).
Also side notes. I already realized that Visual Studio ignores TextBlock when doing Coded UI Testing, because there can be so many released. Now I'm more worried about getting to the ItemsControl itself, and not from the individual TextBlock created from it.
source share