c# - How can I tell if an element matches a PropertyCondition in Microsoft UI Automation? -
i'm trying find automationelement in particular row of gridview (so there many identical elements). i'm iterating on elements in row, , i'd use matcher see if particular element matches condition i'm passing it. i'm starting simple propertyconditions.
here's test:
[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)); } }
and here's code:
public class conditionmatcher : imatchconditions { public bool matches(automationelement element, condition condition) { var propertycondition = (propertycondition) condition; return propertycondition.value.equals(element.getcurrentpropertyvalue(propertycondition.property)); } }
unfortunately test fails. controltype of root element (the desktop) indeed controltype.pane, bizarrely propertycondition.value "50033".
any ideas how can test propertycondition outside of findfirst / findall?
(my workaround create own condition type , test instead, i'd check i'm not misunderstanding / doing stupid.)
found it.
public class conditionmatcher : imatchconditions { public bool matches(automationelement element, condition condition) { return new treewalker(condition).normalize(element) != null; } }
not obvious, works both matching , non-matching conditions. looked , thought bit. else!
Comments
Post a Comment