GridView の特定の行で AutomationElement を見つけようとしています (そのため、同一の要素が多数あります)。行内の要素を反復処理しています。マッチャーを使用して、特定の要素が渡した条件と一致するかどうかを確認したいと考えています。私は単純な PropertyConditions から始めています。
これが私のテストです:
[TestFixture]
public class ConditionMatcherBehaviour
{
[Test]
public void ShouldMatchAPropertyConditionByItsValue()
{
var conditionMatcher = new ConditionMatcher();
var condition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Pane);
Assert.True(conditionMatcher.Matches(AutomationElement.RootElement, condition));
}
}
コードは次のとおりです。
public class ConditionMatcher : IMatchConditions
{
public bool Matches(AutomationElement element, Condition condition)
{
var propertyCondition = (PropertyCondition) condition;
return propertyCondition.Value.Equals(element.GetCurrentPropertyValue(propertyCondition.Property));
}
}
残念ながら、テストは失敗します。ルート要素 (デスクトップ) の ControlType は確かに ControlType.Pane ですが、奇妙なことに PropertyCondition.Value は "50033" です。
FindFirst / FindAllの外でPropertyConditionをテストする方法についてのアイデアはありますか?
(私の回避策は、独自の条件タイプを作成してテストすることですが、何かを誤解していないか、愚かなことをしていないかを確認したいと思います。)