Пример #1
0
 /// <summary>
 /// Will set the requested string as the text of the textBox, and then simulate
 /// the requested keypress.
 /// </summary>
 /// <param name="textBox"></param>
 /// <param name="newValue"></param>
 /// <param name="inputKey"></param>
 public static void SetNewTextBoxValue(
     AutomationElement textBox,
     string newValue,
     Key inputKey
     )
 {
     ClearAndSetTextBoxValue(textBox, newValue);
     AutomationHelper.InputKey(inputKey);
 }
Пример #2
0
        /// <summary>
        /// Will press the key, and verify that the requested element is focused.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="element"></param>
        public static void PressKeyCheckFocus(
            Key key,
            AutomationElement newElement)
        {
            AutomationHelper.InputKey(key);

            // Wait for new element to take focus.
            WaitForFocus(newElement);

            // Check if the new element was correctly assigned focus.
            TestServices.Assert(newElement.Current.HasKeyboardFocus,
                                "Key {0} failed; {1} should have focus, but {2} does.",
                                key.ToString(),
                                newElement.Current.AutomationId,
                                AutomationElement.FocusedElement.Current.AutomationId);
        }