/// <summary> /// Will select all text of the textBox and replace it with the requested string. /// </summary> /// <param name="textBox"></param> /// <param name="newValue"></param> public static void ClearAndSetTextBoxValue( AutomationElement textBox, string newValue ) { textBox.SetFocus(); AutomationHelper.InputKeyGesture(new KeyGesture(Key.A, ModifierKeys.Control)); AutomationHelper.InputTextString(newValue); }
/// <summary> /// Will press the given key gesture, and verify that the requested element is focused. /// </summary> /// <param name="gesture"></param> /// <param name="element"></param> public static void PressKeyCheckFocus( KeyGesture gesture, AutomationElement newElement) { AutomationHelper.InputKeyGesture(gesture); // Wait for new element to take focus. WaitForFocus(newElement); // Check if the new element was correctly assigned focus. TestServices.Assert(newElement.Current.HasKeyboardFocus, "Gesture [{0}+{1}] failed; {2} should have focus, but {3} does.", gesture.Modifiers.ToString(), gesture.Key.ToString(), newElement.Current.AutomationId, AutomationElement.FocusedElement.Current.AutomationId); }