/// <summary> /// Clicks the specified button on the <see cref="MessageBox"/> with the specified parameters. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="title">The title of message box to search for.</param> /// <param name="icon">The MessageBox icon to look for.</param> /// <param name="message">The message to search for.</param> /// <param name="resultButton">The result button to click.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the MessageBox (default is 5).</param> public static void MessageBoxButtonClick(this WisejWebDriver driver, string title, MessageBoxIcon icon, string message, DialogResult resultButton, int timeoutInSeconds = 5) { MessageBox messageBox = driver.GetMessageBox(title, icon, message, true, timeoutInSeconds); messageBox.ButtonClick(resultButton); }
/// <summary> /// Clicks the specified button on the <see cref="MessageBox"/> with the specified icon. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="icon">The MessageBoxIcon to look for.</param> /// <param name="resultButton">The result button to click.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the MessageBox (default is 5).</param> public static void MessageBoxWithIconButtonClick(this WisejWebDriver driver, MessageBoxIcon icon, DialogResult resultButton, long timeoutInSeconds = 5) { MessageBox messageBox = driver.GetMessageBoxWithIcon(icon, true, timeoutInSeconds); messageBox.ButtonClick(resultButton); }
/// <summary> /// Clicks a <see cref="Button"/>. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="path">The widget path.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the Button (default is 5).</param> public static void ButtonClick(this WisejWebDriver driver, string path, long timeoutInSeconds = 5) { Button button = driver.WidgetGet <Button>(path, timeoutInSeconds); Assert.IsTrue(button.Enabled, string.Format("Button {0} isn't enabled.", path)); button.Click(); }
/// <summary> /// Clicks the specified button on the <see cref="MessageBox"/> with the specified title. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="title">The MessageBox title to search for.</param> /// <param name="resultButton">The result button to click.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the MessageBox (default is 5).</param> public static void MessageBoxWithTitleButtonClick(this WisejWebDriver driver, string title, DialogResult resultButton, long timeoutInSeconds = 5) { MessageBox messageBox = driver.GetMessageBoxWithTitle(title, true, timeoutInSeconds); messageBox.ButtonClick(resultButton); }
/// <summary> /// Clicks the specified button on the <see cref="MessageBox"/>. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="resultButton">The result button to click.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the MessageBox (default is 5).</param> public static void MessageBoxButtonClick(this WisejWebDriver driver, DialogResult resultButton, int timeoutInSeconds = 5) { MessageBox messageBox = driver.GetMessageBox(true, timeoutInSeconds); messageBox.ButtonClick(resultButton); }
private static void MessageBoxCheckNotExistCore(this WisejWebDriver driver, string title, MessageBoxIcon icon, string message, int timeoutInSeconds) { MessageBox messageBox = driver.WaitForMessageBox(message, title, icon, timeoutInSeconds); Assert.IsNull(messageBox, GetMessage("MessageBox {0} should not exist.", title, message)); }
private static void AlertBoxCheckNotExistsCore(this WisejWebDriver driver, MessageBoxIcon icon, string message, int timeoutInSeconds) { AlertBox alertBox = driver.WaitForAlertBox(message, icon: icon, timeoutInSeconds: timeoutInSeconds); Assert.IsNull(alertBox, GetMessage("AlertBox with {0} should not exist.", icon, message)); }
/// <summary> /// Returns a widget of type <typeparamref name="T"/> newly fetched from the browser. /// </summary> /// <typeparam name="T">The type of the widget to return.</typeparam> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="path">The widget path.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param> /// <returns>An widget newly fetched from the browser.</returns> /// <remarks> /// Removes an existing widget from the cache and fetches a fresh widget from the browser. /// </remarks> public static T WidgetRefresh <T>(this WisejWebDriver driver, string path, long timeoutInSeconds = 5) { T widget = (T)driver.Refresh(path, timeoutInSeconds); Assert.IsNotNull(widget, string.Format("{0} {1} not found.", typeof(T).Name, path)); return(widget); }
/// <summary> /// Checks the widget value matches the specified string. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="path">The widget path.</param> /// <param name="value">The value to check.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param> public static void CheckValueIs(this WisejWebDriver driver, string path, string value, int timeoutInSeconds = 5) { IHaveValue iHaveValue = driver.WidgetGet <IHaveValue>(path, timeoutInSeconds); CheckValueCore(iHaveValue, path, value); }
private static void AlertBoxAssertNotExistsCore(this WisejWebDriver driver, bool ignoreIcon, MessageBoxIcon icon, string message, long timeoutInSeconds) { AlertBox alertBox = driver.WaitForAlertBox(ignoreIcon, icon, message, timeoutInSeconds); Assert.IsNull(alertBox, GetMessage("AlertBox with {0} should not exist.", ignoreIcon, icon, message)); }
/// <summary> /// Returns an <see cref="IWidget"/> newly fetched from the browser. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="path">The widget path.</param> /// <param name="widgetType">The widget type name.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param> /// <returns>An widget newly fetched from the browser.</returns> /// <remarks> /// Removes an existing widget from the cache and fetches a fresh widget from the browser. /// </remarks> public static IWidget WidgetRefresh(this WisejWebDriver driver, string path, string widgetType, long timeoutInSeconds = 5) { IWidget widget = driver.Refresh(path, timeoutInSeconds); Assert.IsNotNull(widget, string.Format("{0} {1} not found.", widgetType, path)); return(widget); }
private static MessageBox GetMessageBoxCore(this WisejWebDriver driver, string title, MessageBoxIcon icon, string message, int timeoutInSeconds) { MessageBox messageBox = driver.WaitForMessageBox(message, title, icon, timeoutInSeconds); Assert.IsNotNull(messageBox, GetMessage("MessageBox {0} not found.", title, message)); return(messageBox); }
/// <summary> /// Closes a Form. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="name">The form name.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the Form (default is 5).</param> public static void FormClose(this WisejWebDriver driver, string name, long timeoutInSeconds = 5) { Form form = driver.WidgetGet <Form>(name, timeoutInSeconds); form.AssertIsDisplayed(name); form.Close(); form.AssertIsDisposed(name); }
private static AlertBox AlertBoxGetCore(this WisejWebDriver driver, MessageBoxIcon icon, string message, int timeoutInSeconds) { AlertBox alertBox = driver.WaitForAlertBox(message, icon: icon, timeoutInSeconds: timeoutInSeconds); Assert.IsNotNull(alertBox, GetMessage("AlertBox with {0} not found.", icon, message)); return(alertBox); }
/// <summary> /// Returns a <see cref="MessageBox"/> with the specified parameters. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="title">The title of message box to search for.</param> /// <param name="icon">The MessageBox icon to look for.</param> /// <param name="message">The message to search for.</param> /// <param name="assertIsEnabled">If set to <c>true</c>, asserts the MessageBox is enabled (default is <c>true</c>).</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the MessageBox (default is 5).</param> /// <returns>The first matching MessageBox.</returns> public static MessageBox GetMessageBox(this WisejWebDriver driver, string title, MessageBoxIcon icon, string message, bool assertIsEnabled = true, int timeoutInSeconds = 5) { MessageBox messageBox = driver.GetMessageBoxCore(title, icon, message, timeoutInSeconds); if (assertIsEnabled) { Assert.IsTrue(messageBox.Enabled, GetMessage("MessageBox {0} isn't enabled.", title, message)); } return(messageBox); }
/// <summary> /// When debugging tests, suspends the current thread for a specified time.. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="millisecondsTimeout">The number of milliseconds for which the thread is blocked /// (defaults is 1000 milliseconds.)</param> public static void SleepDebugTest(this WisejWebDriver driver, int millisecondsTimeout = 1000) { if (millisecondsTimeout == 0 || millisecondsTimeout == Timeout.Infinite) { millisecondsTimeout = 1000; } if (System.Diagnostics.Debugger.IsAttached) { driver.Sleep(millisecondsTimeout); } }
// TODO: add match type (enum) // Exact (default) // contains // StartsWith // EndsWith // RegEx #region WidgetGet /// <summary> /// Returns an <see cref="IWidget"/> matching the specified parameters. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="path">The widget path.</param> /// <param name="widgetType">The widget type name.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param> /// <param name="assertIsDisplayed">If set to <c>true</c>, asserts the widget is displayed (default is <c>true</c>).</param> /// <returns>An <see cref="IWidget"/> that matches the specified search parameters.</returns> public static IWidget WidgetGet(this WisejWebDriver driver, string path, string widgetType, long timeoutInSeconds = 5, bool assertIsDisplayed = true) { IWidget widget = driver.FindWidget(path, timeoutInSeconds); Assert.IsNotNull(widget, string.Format("{0} {1} not found.", widgetType, path)); if (assertIsDisplayed) { widget.AssertIsDisplayed(path); } return(widget); }
/// <summary> /// Returns a widget of type <typeparamref name="T"/> that matches the specified parameters. /// </summary> /// <typeparam name="T">The type of the widget to return.</typeparam> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="path">The widget path.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param> /// <param name="assertIsDisplayed">If set to <c>true</c>, asserts the widget is displayed (default is <c>true</c>).</param> /// <returns>A widget of type <typeparamref name="T"/> that matches the specified parameters.</returns> public static T WidgetGet <T>(this WisejWebDriver driver, string path, long timeoutInSeconds = 5, bool assertIsDisplayed = true) { T widget = (T)driver.FindWidget(path, timeoutInSeconds); Assert.IsNotNull(widget, string.Format("{0} {1} not found.", typeof(T).Name, path)); if (assertIsDisplayed && widget is IWidget) { ((IWidget)widget).AssertIsDisplayed(path); } return(widget); }
/// <summary> /// Asserts the text of the widget with the given path, matches the specified string. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="path">The widget path.</param> /// <param name="text">The text to match.</param> /// <param name="widgetType">The widget type name.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param> public static void WidgetWaitAssertTextIs(this WisejWebDriver driver, string path, string text, string widgetType, long timeoutInSeconds = 5) { driver.Wait(() => { IWidget waitWidget = driver.WidgetRefresh(path, widgetType, timeoutInSeconds); return(Equals(text, waitWidget.Text)); }, false, timeoutInSeconds); IWidget widget = driver.WidgetGet(path, widgetType, timeoutInSeconds); WidgetAssertTextIsCore(widget, text); }
/// <summary> /// Returns a <see cref="MessageBox"/> with the specified message. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="message">The MessageBox message to search for.</param> /// <param name="assertIsEnabled">If set to <c>true</c>, asserts the MessageBox is enabled (default is <c>true</c>).</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the MessageBox (default is 5).</param> /// <returns>The first matching MessageBox.</returns> public static MessageBox GetMessageBoxWithMessage(this WisejWebDriver driver, string message, bool assertIsEnabled = true, long timeoutInSeconds = 5) { MessageBox messageBox = driver.GetMessageBoxCore(string.Empty, true, MessageBoxIcon.None, message, timeoutInSeconds); if (assertIsEnabled) { Assert.IsTrue(messageBox.Enabled, GetMessage("MessageBox {0} isn't enabled.", string.Empty, message)); } return(messageBox); }
/// <summary> /// Returns a <see cref="MessageBox"/> with the specified icon. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="icon">The MessageBoxIcon to look for.</param> /// <param name="assertIsEnabled">If set to <c>true</c>, asserts the MessageBox is enabled (default is <c>true</c>).</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the MessageBox (default is 5).</param> /// <returns>The first matching MessageBox.</returns> public static MessageBox GetMessageBoxWithIcon(this WisejWebDriver driver, MessageBoxIcon icon, bool assertIsEnabled = true, int timeoutInSeconds = 5) { MessageBox messageBox = driver.GetMessageBoxCore(null, icon, null, timeoutInSeconds); if (assertIsEnabled) { Assert.IsTrue(messageBox.Enabled, GetMessage("MessageBox {0} isn't enabled.", string.Empty, string.Empty)); } return(messageBox); }
private static void AlertBoxCloseCore(this WisejWebDriver driver, MessageBoxIcon icon, string message, int timeoutInSeconds) { AlertBox alertBox = driver.AlertBoxGetCore(icon, message, timeoutInSeconds); Assert.IsNotNull(alertBox, GetMessage("AlertBox with {0} not found.", icon, message)); IWidget closeButton = alertBox.CloseButton; Assert.IsNotNull(closeButton, GetMessage("AlertBox close button with {0} not found.", icon, message)); Assert.IsTrue(closeButton.Enabled, GetMessage("AlertBox close button with {0} isn\'t enabled.", icon, message)); closeButton.Click(); }
/// <summary> /// Sets the text of the widget with the given path, and waits until it matches. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="path">The widget path.</param> /// <param name="text">The text to match.</param> /// <param name="widgetType">The widget type name.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param> public static void WidgetSetTextAssertSync(this WisejWebDriver driver, string path, string text, string widgetType, long timeoutInSeconds = 5) { IHaveValue valueWidget = driver.WidgetRefresh(path, widgetType, timeoutInSeconds) as IHaveValue; if (valueWidget == null) { throw new ArgumentException("Widget does not support Value property", nameof(path)); } valueWidget.Value = text; driver.Wait(() => { IWidget waitWidget = driver.WidgetRefresh(path, widgetType, timeoutInSeconds); return(Equals(text, waitWidget.Text)); }, false, timeoutInSeconds); IWidget widget = driver.WidgetGet(path, widgetType, timeoutInSeconds); WidgetAssertTextIsCore(widget, text); }
/// <summary> /// Closed an <see cref="AlertBox"/> matching the specified message. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="message">The AlertBox message to search for (default is an empty string).</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the AlertBox (default is 5).</param> public static void AlertBoxClose(this WisejWebDriver driver, string message = "", int timeoutInSeconds = 5) { driver.AlertBoxCloseCore(MessageBoxIcon.None, message, timeoutInSeconds); }
/// <summary> /// Closed an <see cref="AlertBox"/> matching the specified icon. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="icon">The AlertBox icon to look for.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the AlertBox (default is 5).</param> public static void AlertBoxClose(this WisejWebDriver driver, MessageBoxIcon icon, int timeoutInSeconds = 5) { driver.AlertBoxCloseCore(icon, null, timeoutInSeconds); }
/// <summary> /// Checks an <see cref="AlertBox"/> matching the specified message does not exist. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="message">The AlertBox message to search for (default is an empty string).</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the AlertBox (default is 0).</param> public static void AlertBoxCheckNotExists(this WisejWebDriver driver, string message = "", int timeoutInSeconds = 0) { driver.AlertBoxCheckNotExistsCore(MessageBoxIcon.None, message, timeoutInSeconds); }
/// <summary> /// Restores a Form. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="name">The form name.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the Form (default is 5).</param> public static void FormRestore(this WisejWebDriver driver, string name, long timeoutInSeconds = 5) { Form form = driver.WidgetGet <Form>(name, timeoutInSeconds); form.Restore(); }
/// <summary> /// Returns a <see cref="AlertBox"/> matching the specified icon. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="icon">The AlertBox icon to look for.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the AlertBox (default is 5).</param> /// <returns>The first matching AlertBox.</returns> public static AlertBox AlertBoxGet(this WisejWebDriver driver, MessageBoxIcon icon, int timeoutInSeconds = 5) { return(driver.AlertBoxGetCore(icon, null, timeoutInSeconds)); }
/// <summary> /// Returns a <see cref="AlertBox"/> matching the specified message. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="message">The AlertBox message to search for (default is an empty string).</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the AlertBox (default is 5).</param> /// <returns>The first matching AlertBox.</returns> public static AlertBox AlertBoxGet(this WisejWebDriver driver, string message = "", int timeoutInSeconds = 5) { return(driver.AlertBoxGetCore(MessageBoxIcon.None, message, timeoutInSeconds)); }
/// <summary> /// Checks an <see cref="AlertBox"/> matching the specified icon does not exist. /// </summary> /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param> /// <param name="icon">The AlertBox icon to look for.</param> /// <param name="timeoutInSeconds">The number of seconds to wait for the AlertBox (default is 0).</param> public static void AlertBoxCheckNotExists(this WisejWebDriver driver, MessageBoxIcon icon, int timeoutInSeconds = 0) { driver.AlertBoxCheckNotExistsCore(icon, null, timeoutInSeconds); }