Esempio n. 1
0
        public static bool Alert(this IWebDriver driver, int seconds = 20)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(seconds));

            try
            {
                wait.Until(ExpectedConditions.AlertIsPresent());
                //element = driver.FindElement(by);
                WriteConsole.DarkCyan(String.Format("Element found --> {0}"));
                Report.Log(LogStatus.Pass, "Check Alert Box", String.Format("Element found --> {0}"));
                return(true);
            }
            catch (Exception e)
            {
                WriteConsole.DarkMagenta(String.Format("Exception of checking visable : {0} [{1}]", "alert", e.Message.ToString()));
                Report.Log(LogStatus.Warning, "Check Alert Box", String.Format("Exception of checking visable : {0} [{1}]", "alert", e.Message.ToString()));
                return(false);
            }
        }
Esempio n. 2
0
        public static IWebElement PresenceAll(this IWebDriver driver, By by, int seconds = 20)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(seconds));
            IWebElement   element;

            try
            {
                wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(by));
                element = driver.FindElement(by);
                WriteConsole.DarkCyan(String.Format("Element found --> {0}", by.ToString()));
                Report.Log(LogStatus.Pass, "Check Element PresenceAll", String.Format("Element found --> {0}", by.ToString()));
                return(element);
            }
            catch (Exception e)
            {
                WriteConsole.DarkMagenta(String.Format("Exception of checking visable : {0} [{1}]", by.ToString(), e.Message.ToString()));
                Report.Log(LogStatus.Warning, "Check Element PresenceAll", String.Format("Exception of Wait : {0} [{1}]", by.ToString(), e.Message.ToString()));
                return(null);
            }
        }
Esempio n. 3
0
        // Will wait for seconds by default
        public static IWebElement Exist(this IWebDriver driver, By by)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
            IWebElement   element;

            try
            {
                wait.Until(ExpectedConditions.ElementExists(by));
                element = driver.FindElement(by);
                WriteConsole.DarkCyan(String.Format("Element found --> {0}", by.ToString()));
                Report.Log(LogStatus.Pass, "Check Element Exist", String.Format("Element found --> {0}", by.ToString()));
                return(element);
            }
            catch (Exception e)
            {
                WriteConsole.DarkMagenta(String.Format("Exception of Wait : {0} [{1}]", by.ToString(), e.Message.ToString()));
                Report.Log(LogStatus.Warning, "Check Element Exist", String.Format("Exception of Wait : {0} [{1}]", by.ToString(), e.Message.ToString()));
                return(null);
            }
        }