Example #1
0
        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;
            }
        }