how do I select ComboBox\'s SelectedIndex = -1?
I wrote a code to automate testing:
AutomationElement aeBuildMachine = null;
int count =
I think this might be the easiest way for a simple generic ComobBox value setter this one is fine provided the list items in the ComboBox doesn't have duplicates.
private void SetCombobValueByUIA( AutomationElement ctrl, string newValue )
{
ExpandCollapsePattern exPat = ctrl.GetCurrentPattern(ExpandCollapsePattern.Pattern)
as ExpandCollapsePattern;
if( exPat== null )
{
throw new ApplicationException( "Bad Control type..." );
}
exPat.Expand();
AutomationElement itemToSelect = ctrl.FindFirst(TreeScope.Descendants, new
PropertyCondition(AutomationElement.NameProperty,newValue));
SelectionItemPattern sPat = itemToSelect.GetCurrentPattern(
SelectionItemPattern.Pattern) as SelectionItemPattern ;
sPat. Select();
}