/// <summary> /// Focus a control, send it a keygesture, and check the proper result via GetText. /// </summary> /// <param name="target">The AutomationElement to focus on, or null to keep current focus.</param> /// <param name="keyGesture">The key gesture to send the target.</param> /// <param name="textElement">The AutomationElement to check the text of (via TextPattern).</param> /// <param name="desiredValue">The expected string.</param> public static void CheckKeyResult( AutomationElement target, KeyGesture keyGesture, AutomationElement textElement, string desiredValue ) { if (target != null) { target.SetFocus(); AutomationHelper.WaitForFocus(target); } InputKeyGesture(keyGesture); string actualValue = AutomationHelper.GetText(textElement); TestServices.Assert(actualValue.Equals(desiredValue), "Key gesture ({0}) failed. DesiredResult: {1} ActualResult: {2}", keyGesture.DisplayString, desiredValue, actualValue); }