Пример #1
0
        public static void HandlerModalDialogs()
        {
            try
            {
                WaitForAlert(GetWebDriver);

                var alert = GetWebDriver.SwitchTo().Alert();
                alert.Accept();

                BrowserSleep();
                WaitForPageToLoad();
            }
            catch (Exception)
            {
                SwitchToDefaultContent();
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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();
            }
        }
Пример #4
0
 public static IWebElement GetElementWait(By by, string controlName = "")
 {
     return(GetWebDriver.FindElementWait(by, controlName));
 }
Пример #5
0
 public static void SwitchToDefaultContent()
 {
     GetWebDriver.SwitchTo().DefaultContent();
 }
Пример #6
0
 public static void BrowserSleep(int sleepTime = 1)
 {
     GetWebDriver.Sleep(sleepTime);
 }
Пример #7
0
 /// <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 + ")");
 }
Пример #8
0
 /// <summary>
 /// This method allow Scrolling in the web page
 /// </summary>
 public static void ScrollUp()
 {
     GetWebDriver.SwitchTo().ParentFrame();
     ((IJavaScriptExecutor)GetWebDriver).ExecuteScript("scroll(0,-250)");
 }
Пример #9
0
 /// <summary>Gets the elements.</summary>
 /// <param name="by">The by.</param>
 /// <returns></returns>
 public static ReadOnlyCollection <IWebElement> GetElements(By by)
 {
     return(GetWebDriver.FindElements(by));
 }