public static bool Click(AutomationElement element) { try { if (AutomationElement.IsInvokePatternAvailableProperty.In(element)) { element.As<InvokePattern>(InvokePattern.Pattern).Invoke(); } else if (AutomationElement.IsTogglePatternAvailableProperty.In(element)) { element.AsTogglePattern().Toggle(); } else if (AutomationElement.IsSelectionItemPatternAvailableProperty.In(element)) { element.AsSelectionItem().Select(); } return true; } catch (Exception e) { Console.WriteLine(e); return false; } }
private static void SingleSelect(AutomationElement element) { var selectionItem = element.AsSelectionItem(); try { Clicker.MouseClick(element); } catch { } if (!selectionItem.Current.IsSelected) selectionItem.Select(); }
private static bool IsSelected(AutomationElement tabItem) { return tabItem.AsSelectionItem().Current.IsSelected; }
private static void MultipleSelect(AutomationElement element) { element.AsSelectionItem().AddToSelection(); }
private static bool IsSelected(AutomationElement element) { return element.AsSelectionItem().Current.IsSelected; }