public static string SelectRandomRecordFromLookup( TestContext testContext, UserContext context, ClientLogicalControl control, string keyFieldCaption) { var form = control.InvokeCatchLookup(); if (form == null) { throw new InvalidOperationException("No Lookup Form found"); } try { var randomKey = SelectRandomRecord(form, keyFieldCaption); testContext.WriteLine( "Selected Random Record from Lookup:{0} Key:{1} Value:{2}", control.Caption, keyFieldCaption, randomKey); return(randomKey); } finally { ClosePage(testContext, context, form); } }
public static ClientLogicalForm InvokeCatchLookup(this ClientLogicalControl control) { var rootForm = control.GetRootForm(); return(rootForm.Session.CatchLookupForm(() => rootForm.Session.InvokeInteraction( new InvokeActionInteraction(control, SystemAction.Lookup)))); }
/// <summary> /// Gets the root form of a control. /// </summary> /// <remarks> /// This is needed because the <see cref="ClientLogicalForm.Session"/> property is not set on intermediary forms in the hierarchy. /// </remarks> /// <param name="control">The control.</param> /// <returns>The root form.</returns> private static ClientLogicalForm GetRootForm(this ClientLogicalControl control) { while (control.Parent != null && control != control.Parent) { control = control.Parent; } return((ClientLogicalForm)control); }
public static void WriteControlCaptions <T>(this ClientLogicalControl control) where T : ClientLogicalControl { var all = control.ContainedControls.OfType <T>(); foreach (var c in all) { Debug.WriteLine(c.Caption); } }
public static ClientActionControl Action(this ClientLogicalControl control, string actionCaption) { try { return(control.ContainedControls.OfType <ClientActionControl>().First(c => c.Caption.Replace("&", "").EndsWith(actionCaption))); } catch (InvalidOperationException exception) { control.WriteControlCaptions <ClientActionControl>(); throw new ArgumentOutOfRangeException(string.Format("Could not find an Action with caption {0}", actionCaption), exception); } }
public static ClientLogicalControl Control(this ClientLogicalControl control, string controlCaption) { try { return(control.ContainedControls.First(c => c.Caption.Replace("&", "").EndsWith(controlCaption) && (c.GetType() != typeof(ClientActionControl)))); } catch (InvalidOperationException exception) { control.WriteControlCaptions <ClientLogicalControl>(); throw new ArgumentOutOfRangeException(string.Format("Could not find a control with caption {0}", controlCaption), exception); } }
/// <summary> /// Save the specified value with entry delay and ignore any warning dialogs /// </summary> /// <param name="context">the current test contest</param> /// <param name="userContext">the user context</param> /// <param name="control">the control to be updated</param> /// <param name="value">the value</param> /// <param name="ignoreAction">the name of the action, default is Yes</param> public static void SaveValueAndIgnoreWarning( TestContext context, UserContext userContext, ClientLogicalControl control, string value, string ignoreAction = "Yes") { InvokeActionAndCloseAnyDialog( context, userContext, () => SaveValueWithDelay(control, value), ignoreAction); }
public static ClientLogicalControl Control(this ClientLogicalControl control, string controlCaption) { try { return(control .ContainedControls .First(c => c.HasCaption(controlCaption))); } catch (InvalidOperationException exception) { control.WriteControlCaptions <ClientLogicalControl>(); throw new ArgumentOutOfRangeException(string.Format("Could not find a control with caption {0}", controlCaption), exception); } }
public static void SelectOption(this ClientLogicalControl control, string text) { try { var selectControl = control .ContainedControls .OfType <ClientSelectionControl>() .First(c => c.Items.Any(i => i.Text.Replace("&", "").Equals(text))); var item = selectControl.Items.First(i => i.Text.Replace("&", "").Equals(text)); selectControl.SaveValue(item.Value); } catch (InvalidOperationException exception) { throw new ArgumentOutOfRangeException(string.Format("Could not find an Selection Control with item text {0}", text), exception); } }
/// <summary>Save a value for the control.</summary> /// <param name="control">The control.</param> /// <param name="newValue">The new Value.</param> public static void SaveValue(this ClientLogicalControl control, object newValue) { control.GetRootForm().Session.InvokeInteraction(new SaveValueInteraction(control, newValue)); }
/// <summary>Invokes the specified control and returns the expected dialog.</summary> /// <remarks>The consumer specifies the expected form type to retrieve. If this could not be matched, the invocation is performed but null is returned.</remarks> /// <param name="control">The control.</param> /// <returns>The expected dialog.</returns> public static ClientLogicalForm InvokeCatchDialog(this ClientLogicalControl control) { var rootForm = control.GetRootForm(); return(rootForm.Session.CatchDialog(() => rootForm.Session.InvokeInteraction(new InvokeActionInteraction(control)))); }
/// <summary>Invokes the specified control.</summary> /// <remarks>The consumer specifies the expected form type to retrieve. If this could not be matched, the invocation is performed but null is returned.</remarks> /// <param name="control">The control.</param> public static void Invoke(this ClientLogicalControl control) { control.GetRootForm().Session.InvokeInteraction(new InvokeActionInteraction(control)); }
public static string SelectRandomRecordFromLookup( TestContext testContext, UserContext context, ClientLogicalControl control, string keyFieldCaption) { var form = control.InvokeCatchLookup(); if (form == null) { throw new InvalidOperationException("No Lookup Form found"); } try { var randomKey = SelectRandomRecord(form, keyFieldCaption); testContext.WriteLine( "Selected Random Record from Lookup:{0} Key:{1} Value:{2}", control.Caption, keyFieldCaption, randomKey); return randomKey; } finally { ClosePage(testContext, context, form); } }
public static void SaveValueWithDelay(ClientLogicalControl control, object value) { control.SaveValue(value); DelayTiming.SleepDelay(DelayTiming.EntryDelay); }
/// <summary> /// Save the specified value with entry delay and ignore any warning dialogs /// </summary> /// <param name="context">the current test contest</param> /// <param name="userContext">the user context</param> /// <param name="control">the control to be updated</param> /// <param name="value">the value</param> /// <param name="ignoreAction">the name of the action, default is Yes</param> public static void SaveValueAndIgnoreWarning(TestContext context, UserContext userContext, ClientLogicalControl control, string value, string ignoreAction = "Yes") { var dialog = userContext.CatchDialog(() => SaveValueWithDelay(control, value)); if (dialog != null) { try { var action = dialog.Action(ignoreAction); if (action != null) { action.Invoke(); context.WriteLine("Dialog Caption: {0} Message: {1} was ignored with Action: {2} ", dialog.Caption, dialog.FindMessage(), ignoreAction); } } catch (InvalidOperationException) { context.WriteLine("Dialog Caption: {0} Message: {1} Action: {2} was not found.", dialog.Caption, dialog.FindMessage(), ignoreAction); throw; } } }
private static bool HasCaption(this ClientLogicalControl control, string caption) { return(control.Caption.Replace("&", "").Equals(caption)); }