Пример #1
0
        public static void Toggle(AutomationElement element, bool toggle)
        {
            TogglePattern currentPattern = AutomationPatternHelper.GetTogglePattern(element);
            ToggleState   indeterminate  = ToggleState.Indeterminate;

            if (toggle == true)
            {
                indeterminate = ToggleState.On;
            }
            else if (toggle == false)
            {
                indeterminate = ToggleState.Off;
            }
            while (currentPattern.Current.ToggleState != indeterminate)
            {
                currentPattern.Toggle();
            }
        }
Пример #2
0
        public static void AssertChecked(AutomationElement element, bool expected)
        {
            TogglePattern currentPattern = AutomationPatternHelper.GetTogglePattern(element);
            ToggleState   indeterminate  = ToggleState.Indeterminate;

            if (expected == true)
            {
                indeterminate = ToggleState.On;
            }
            else if (expected == false)
            {
                indeterminate = ToggleState.Off;
            }
            ToggleState toggleState = currentPattern.Current.ToggleState;

            if (indeterminate != toggleState)
            {
                throw new Exception(string.Format("ToggleState is not as expected. Expected: {0}, Actual: {1}. ({2})", indeterminate.ToString(), toggleState.ToString(), element.ToString()));
            }
        }