Microsoft UI Automation (つまり) を使用AutomationElement
して、アプリケーションに対して自動受け入れテストを実行しています。これはうまくいきましたが、自動化フレームワークにさらされていないように見える状況に遭遇しました。
私はItemsControl
(その派生コントロールの 1 つを使用することもできますが、たとえばListBox
)を持っており、CollectionViewSource
項目をグループ化するために使用しています。デモ用の完全なウィンドウを次に示します。
<Window x:Class="GroupAutomation.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Orchestra">
<Window.Resources>
<!-- Take some simple data -->
<XmlDataProvider x:Key="SampleData" XPath="Orchestra/Instrument">
<x:XData>
<Orchestra xmlns="">
<Instrument Name="Flute" Category="Woodwind" />
<Instrument Name="Trombone" Category="Brass" />
<Instrument Name="French horn" Category="Brass" />
</Orchestra>
</x:XData>
</XmlDataProvider>
<!-- Add grouping -->
<CollectionViewSource Source="{Binding Source={StaticResource SampleData}}" x:Key="GroupedView">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="@Category" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</Window.Resources>
<!-- Show it in an ItemsControl -->
<ItemsControl ItemsSource="{Binding Source={StaticResource GroupedView}}" HorizontalAlignment="Left" Margin="4">
<ItemsControl.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}" FontWeight="Bold" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ItemsControl.GroupStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Padding="4" Margin="4" Background="#FFDEDEDE">
<StackPanel>
<Label Content="{Binding XPath=@Name}" />
<Button Content="Play" />
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Window>
これにより、カテゴリにグループ化されたアイテムを含むウィンドウが生成され、各アイテムには、UI オートメーションでクリックしたいボタンがあります。
(ソース: brizzly.com )
ただし、UISpy.exeを見る(または で移動するAutomationElement
) と、グループしか表示されません (Raw ビューであっても):
(ソース: brizzly.com )
ご覧のとおり、グループはありますが、アイテムが含まれていないため、ボタンを探す場所がありません。WPF 3.5 SP1 と WPF 4.0 の両方でこれを試しましたが、同じ結果が得られました。
グループ化されたアイテムで UI オートメーションを使用することは可能ですか?