/// <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); }
// 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); }