UI Automated フレームワークでいくつかのカスタム コントロールをテストしようとしています。私のコントロールの 1 つは TextBox の基本クラスを持ち、もう 1 つは Control を継承しています。テストで最初のコントロールを見つけることができますが、TreeScope とプロパティ条件をどのように組み合わせても、ウィンドウ内で 2 番目のカスタム コントロールを見つけることができません。
次のように、XAML でカスタム コントロールを宣言します。
<Grid>
<test:CustomTextBox Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="customTextBox1" VerticalAlignment="Top" Width="120" />
<test:CustomUserControl Height="25" HorizontalAlignment="Left" Margin="12,62,0,0" Name="customUserControl1" VerticalAlignment="Top" Width="119" />
</Grid>
以下のようなサンプルテストがあります。
[Test]
public void TestUsingValuePattern()
{
// Getting RootElement...
AutomationElement rootElement = AutomationElement.RootElement;
Assert.IsNotNull(rootElement);
// Searching for Test Window...
AutomationElement windowElement = rootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "TestWindow"));
Assert.IsNotNull(windowElement);
// Searching for Custom TextBox control...
AutomationElement customElement1 = windowElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "customTextBox1"));
Assert.IsNotNull(customElement1);
// Searching for Custom User control
AutomationElement customElement2 = windowElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "customUserControl1"));
Assert.IsNotNull(customElement2);
}
2 番目のアサーションは常に null を返すため、テストの実行を開始することさえできません。この問題を解決するために私ができることについて何か提案はありますか?