public static void HandlerModalDialogs() { try { WaitForAlert(GetWebDriver); var alert = GetWebDriver.SwitchTo().Alert(); alert.Accept(); BrowserSleep(); WaitForPageToLoad(); } catch (Exception) { SwitchToDefaultContent(); } }
public static IWebElement GetElement(By by, string controlName = "") //TODO add controlName { try { return(GetWebDriver.FindElement(by)); } catch { string errorMessage = $"Control not found: {by}"; if (!string.IsNullOrEmpty(controlName)) { errorMessage = $"Control not found: [ {controlName} ] [ {by} ]."; } throw new NoSuchElementException(errorMessage); } }
public static void HandlerModalDialogsAndValidateText(string expectedMessage) { try { WaitForAlert(GetWebDriver); var alert = GetWebDriver.SwitchTo().Alert(); var alertMessage = alert.Text; var messageFailed = "The information message in Handler Modal dialog is not the expected [" + expectedMessage + "]."; var messagePassed = "The information message in Handler Modal dialog is correct."; ExceptionManager.AssertAreEqual(alertMessage, expectedMessage, messagePassed, messageFailed); alert.Accept(); BrowserSleep(); } catch (Exception) { SwitchToDefaultContent(); } }
public static IWebElement GetElementWait(By by, string controlName = "") { return(GetWebDriver.FindElementWait(by, controlName)); }
public static void SwitchToDefaultContent() { GetWebDriver.SwitchTo().DefaultContent(); }
public static void BrowserSleep(int sleepTime = 1) { GetWebDriver.Sleep(sleepTime); }
/// <summary> /// This method allow Scrolling in the web page /// </summary> public static void ScrollDown(int value = 250) { GetWebDriver.SwitchTo().ParentFrame(); ((IJavaScriptExecutor)GetWebDriver).ExecuteScript("scroll(0, " + value + ")"); }
/// <summary> /// This method allow Scrolling in the web page /// </summary> public static void ScrollUp() { GetWebDriver.SwitchTo().ParentFrame(); ((IJavaScriptExecutor)GetWebDriver).ExecuteScript("scroll(0,-250)"); }
/// <summary>Gets the elements.</summary> /// <param name="by">The by.</param> /// <returns></returns> public static ReadOnlyCollection <IWebElement> GetElements(By by) { return(GetWebDriver.FindElements(by)); }