Search code examples
microsoft-ui-automation

UI Automation - Select object based on multiple Identifiers


I am new to this. I am using UI Automation to automate my application. Is there a way to identify element based on multiple identifier. currently the below syntax only able to identify based on one identifier.

AutomationElement okbtn = dialogbox.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "OK"));

I would like to take identify element by both NameProperty and ControlTypeProperty.

Is this possible?


Solution

  •         Condition cMenuItem = new AndCondition(
                new PropertyCondition(AutomationElement.LocalizedControlTypeProperty,"text"),
                new PropertyCondition(AutomationElement.NameProperty,"Appointment"));
    
            AutomationElement aeMenuItem = aeTaskMenu.FindFirst(TreeScope.Descendants, cMenuItem);