how do I select ComboBox\'s SelectedIndex = -1?
I wrote a code to automate testing:
AutomationElement aeBuildMachine = null;
int count =
There isn't a big change but only a few to notice,
treescope.subtree
worked for me instead of children.The code sample would be like this,
public static void SelectValueInComboBox(string comboBox, string value)
{
var comboBoxElement = HelperMethods.FindElementFromAutomationID(comboBox);
if (comboBoxElement == null)
throw new Exception("Combo Box not found");
ExpandCollapsePattern expandPattern = (ExpandCollapsePattern)comboBoxElement.GetCurrentPattern(ExpandCollapsePattern.Pattern);
AutomationElement comboboxItem = comboBoxElement.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.NameProperty, value));
SelectionItemPattern selectPattern = (SelectionItemPattern)comboboxItem.GetCurrentPattern(SelectionItemPattern.Pattern);
selectPattern.Select();
}