I've tried to get the patterns of all automation elements in that I can use ExpandCollapsePattern
but i can't use the SelectionItemPattern
to invoke SelectItemPattern
.
Exception:
Exception: "Unsupported Pattern"
Here is my code:
foreach (AutomationElement a in automationlist)
{
if (a.Current.AutomationId == "PersonalCountryCmb")
{
ExpandCollapsePattern pattern = (ExpandCollapsePattern)a.GetCurrentPattern(ExpandCollapsePattern.Pattern);
pattern.Expand();
try
{
SelectionItemPattern pattern1 = (SelectionItemPattern)a.GetCurrentPattern(SelectionItemPattern.Pattern);
pattern1.Select();
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}
}
}