Exemple #1
0
        public void OpenBrowser()
        {
            //HomePage home = new HomePage(driver);

            // Gets the URL of the home page from App.config
            url = ConfigurationManager.AppSettings["HomeUrl"];
            log.Info("Got the url from config file");

            // Maximise Window
            driver.Manage().Window.Maximize();
            log.Info("Browser maximized");

            // Navigates to the URL
            driver.Url = url;
            log.Info("Browsing to the URL");

            // Scrolls the page till the bottom
            IJavaScriptExecutor javaScript = (IJavaScriptExecutor)driver;

            javaScript.ExecuteScript("window.scrollTo(0,document.body.scrollHeight)");
            log.Info("Scrolling the page till bottom");

            // Finds the 'Contact Us' Button
            WebDriverWait wait       = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
            IWebElement   btnContact = wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("contactUsMail")));

            btnContact.Click();

            // Switch to Alert and accept
            wait.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert = driver.SwitchTo().Alert();

            alert.Text.ShouldBe("You tried contacting us");
            alert.Accept();
        }
        public static bool IsAlertPresent(this WebApplication webApplication, int timeOutInMs)
        {
            Thread.Sleep(timeOutInMs);
            var alert = ExpectedConditions.AlertIsPresent().Invoke(webApplication.WebDriver);

            return(alert != null);
        }
Exemple #3
0
        public void Signups()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20));

            IWebElement Signup = driver.FindElement(By.LinkText("Sign up"));

            Signup.Click();

            wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.Id("sign-username")));
            IWebElement Username = driver.FindElement(By.Id("sign-username"));

            Username.SendKeys(username);


            IWebElement Password = driver.FindElement(By.Id("sign-password"));

            Password.SendKeys(passwords);

            IWebElement SignupButton = driver.FindElement(By.XPath("//button[contains(text(),'Sign up')]"));

            SignupButton.Click();

            wait.Until(ExpectedConditions.AlertIsPresent());

            String AlertMsg = driver.SwitchTo().Alert().Text;

            Console.WriteLine(AlertMsg);

            Thread.Sleep(3000);

            Assert.AreEqual("Sign up successful.", AlertMsg);

            driver.SwitchTo().Alert().Accept();
        }
        public void CleanEnvironment()
        {
            var okrListPageObject = new OKRListPageObject(driver);

            okrListPageObject.UsersComboBox.SelectByText(MANAGER_USERNAME);

            var approveOKRPageObject = new ApproveOKRPageObject(driver);
            var lastCreatedOKR       = okrListPageObject.OKRsList.Last();

            // Last created OKR is placed to the bottom of OKRs list
            if (lastCreatedOKR.TitleLabel.Text == TESTOKR_NAME)
            {
                approveOKRPageObject.SettingsButton.Click();
                approveOKRPageObject.SettingsMenu.DeleteMenuItem.Click();
                var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(EXPLICIT_WAIT_SECONDS));
                wait.Until(ExpectedConditions.AlertIsPresent());
                driver.SwitchTo().Alert().Accept();
            }
            else
            {
                throw new Exception(TEARDOWN_EXCEPTION_TEXT);
            }

            driver.Quit();
        }
Exemple #5
0
        public void Method()
        {
            IAlert alert = driver.SwitchTo().Alert();
            //если диалоговое окно появляется не мгновенно, то нужно использовать ожидание:
            IAlert newAlert       = wait.Until(ExpectedConditions.AlertIsPresent());
            IAlert newLambdaAlert = wait.Until(x => x.SwitchTo().Alert());
            //так же можно получить текст из Alert`a или ввести текст в него
            var alertText = this.foundAlert.Text;

            this.foundAlert.SendKeys("some text");
            this.foundAlert.Accept();  //Ok
            this.foundAlert.Dismiss(); //Cancel , но есть кнопки Cancel нету,
            //то .Dismiss() - это закрытие диалога крестиком или нажатие клавишу Escape
            this.foundAlert.SetAuthenticationCredentials("Admin", "Admin");

            //Иногда окна Alert появляются неожиданно. В Selenium есть capability:
            var options = new ChromeOptions();

            options.UnhandledPromptBehavior = UnhandledPromptBehavior.Dismiss;
            options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept;
            options.UnhandledPromptBehavior = UnhandledPromptBehavior.AcceptAndNotify;  // Accept, но потом  выбрасывает UnhanledAlertException - и это правильно
            options.UnhandledPromptBehavior = UnhandledPromptBehavior.Default;
            options.UnhandledPromptBehavior = UnhandledPromptBehavior.DismissAndNotify; // Dismiss, но потом  выбрасывает UnhanledAlertException - и это правильно
            options.UnhandledPromptBehavior = UnhandledPromptBehavior.Ignore;           //ничего не делает. и все сценарии "упадут"
            //или можно так, наверное
            options.AddArgument("-disable-notifications");
            options.AddAdditionalCapability("unexpectedAlertException", "dismiss");
        }
Exemple #6
0
        public void What_Is_Implicit_Wait_And_Explicit_Wait()
        {
            //Implicit wait- Asking the browser to wait for amount of time driver should wait while searching for an element if it is not present immediately
            //If the element is found beofre the time seciified the next step will be executed without waiting for remaining time mentioned in implicit wait.
            chromedriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

            //Explicit Wait- Specific wait
            OpenQA.Selenium.Support.UI.WebDriverWait wait = new OpenQA.Selenium.Support.UI.WebDriverWait(chromedriver, TimeSpan.FromSeconds(10));
            wait.Message = "";                                       //Gets for sets the message to be displayed when time expires
            wait.IgnoreExceptionTypes();                             //Configures this instance to ignore the specific exceptions while waiting on the condition
            wait.PollingInterval = TimeSpan.FromMilliseconds(100);   //Gets or sets how often the condition should be evaluated. The deafult timeout is 500milliseond
            wait.Until(x => x.FindElements(By.XPath("")).Count > 1); //Condtion till the wait should be applied. Throws exception when timeout expires.
            //wait.Until(ExpectedConditions.)
            wait.Until(ExpectedConditions.AlertIsPresent());
            //An expectation for checking that an element is present on the DOM of a page
            //This does not necessarily mean that the element is visible.
            //// Returns:
            //     The OpenQA.Selenium.IWebElement once it is located.
            wait.Until(ExpectedConditions.ElementExists(By.Id("elem")));

            // Summary:
            //     An expectation for checking that an element is present on the DOM of a page and
            //     visible. Visibility means that the element is not only displayed but also has
            //     a height and width that is greater than 0.
            // Returns:
            //     The OpenQA.Selenium.IWebElement once it is located and visible.
            wait.Until(ExpectedConditions.ElementIsVisible(By.Id("elem")));

            wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("elem")));

            wait.Until(ExpectedConditions.TextToBePresentInElement(chromedriver.FindElement(By.Id("elem")), ""));
            // An expectation for checking the title of a page.
            wait.Until(ExpectedConditions.TitleIs(""));
            wait.Until(ExpectedConditions.UrlContains(""));
        }
        public void OpenEmail()
        {
            wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
            wait.Until(e => GetEmailList());
            var emails     = GetEmailList();
            var randomMail = emails.First();


            wait.Timeout         = TimeSpan.FromSeconds(20);
            wait.PollingInterval = TimeSpan.FromSeconds(1);
            wait.Until((Func <IWebDriver, bool>)((e) =>
            {
                if (SeleniumDriver.Instance.WindowHandles.Count < 2)
                {
                    action.DoubleClick(randomMail).Perform();
                }
                else
                {
                    return(true);
                }

                return(false);
            }));

            SeleniumDriver.Close();

            IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent());

            alert.Accept();

            SeleniumDriver.Instance.SwitchTo().Window(SeleniumDriver.Instance.WindowHandles.Last());
        }
Exemple #8
0
 /// <summary>
 /// Takes care of disposing the web driver.
 /// </summary>
 public override void KillDriver()
 {
     if (driverInstance != null)
     {
         try
         {
             try
             {
                 ExpectedConditions.AlertIsPresent()(driverInstance)?.Dismiss();
                 driverInstance.Dispose();
             }
             catch
             {
                 if (Factory.TestSuiteRunner.Configuration.TestRunOptions.TryToKillWhenNotResponding)
                 {
                     TryToKill(driverInstance);
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         catch (Exception ex)
         {
             Factory.LogError(ex);
         }
         finally
         {
             driverInstance = null;
         }
     }
 }
Exemple #9
0
        public static string GetAlertText()
        {
            WebDriverWait wait  = new WebDriverWait(Instance, TimeSpan.FromSeconds(5));
            var           alert = wait.Until(ExpectedConditions.AlertIsPresent());

            return(alert.Text);
        }
        public void ConfirmBoxTest()
        {
            string trueText = "Press a button!";

            //Wait for the alert to be displayed
            javaAlertsPage.ConfirmBoxButtonClick();

            //Wait for the alert to be displayed
            IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent());

            //Store the alert text in a variable
            string alertText = alert.Text;

            javaAlertsAssertsPage.AssertAlertMessage(trueText, alertText);

            //Press the OK button
            alert.Accept();

            javaAlertsAssertsPage.AssertConfirmMessage("Ok");

            javaAlertsPage.ConfirmBoxButtonClick();
            alert = wait.Until(ExpectedConditions.AlertIsPresent());

            //Press the Cancel button
            alert.Dismiss();

            javaAlertsAssertsPage.AssertConfirmMessage("Cancel");
        }
Exemple #11
0
        private void ExecuteCleanup()
        {
            StopWatchedAction(() =>
            {
                if (driverInstance == null)
                {
                    return;
                }

                Factory.LogInfo("Cleaning session");

                ExpectedConditions.AlertIsPresent()(driverInstance)?.Dismiss();
                driverInstance.Manage().Cookies.DeleteAllCookies();

                if (!(driverInstance.Url.Contains("chrome:") || driverInstance.Url.Contains("data:") || driverInstance.Url.Contains("about:")))
                {
                    ((IJavaScriptExecutor)driverInstance).ExecuteScript("if(typeof(Storage) !== undefined) { localStorage.clear(); }");
                    ((IJavaScriptExecutor)driverInstance).ExecuteScript("if(typeof(Storage) !== undefined) { sessionStorage.clear(); }");
                }

                driverInstance.Navigate().GoToUrl("about:blank");
            }, s =>
            {
                Factory.LogInfo($"Session cleaned in {s.ElapsedMilliseconds} ms.");
            });
        }
        public void Alert()
        {
            GetDriver().FindElement(By.Id("alertJS")).Click();

            var wait = new WebDriverWait(GetDriver(), new System.TimeSpan(10000));

#pragma warning disable CS0618
            var alert = wait.Until(ExpectedConditions.AlertIsPresent());
#pragma warning restore CS0618
            alert.Text.Is("test");
            alert.Accept();

            GetDriver().FindElement(By.Id("confirmJS")).Click();

#pragma warning disable CS0618
            var confirm = wait.Until(ExpectedConditions.AlertIsPresent());
#pragma warning restore CS0618
            confirm.Text.Is("test");
            confirm.Dismiss();

            GetDriver().FindElement(By.Id("promptJS")).Click();

#pragma warning disable CS0618
            var prompt = wait.Until(ExpectedConditions.AlertIsPresent());
#pragma warning restore CS0618
            prompt.SendKeys("abc");
            prompt.Accept();
        }
        public static void Main(String[] args)
        {
            IWebDriver driver = new FirefoxDriver();

            //Page to load completely with in three seconds
            driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10);

            driver.Url = "https://www.cleartrip.com";


            /* Console.WriteLine("before sleep");
             * Thread.Sleep(5000);
             * Console.WriteLine("after sleep");
             */
            /*  driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromMilliseconds(1);
             * IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
             * js.ExecuteAsyncScript("alert('Hello Lankesh');");
             */

            /*
             * driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(1);
             * driver.FindElement(By.Id("FromTag")).SendKeys("Bangalore");
             */

            WebDriverWait wt = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wt.Until(ExpectedConditions.ElementToBeClickable(By.Id("SearchBtn")));
            driver.FindElement(By.Id("SearchBtn")).Click();

            WebDriverWait ft = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            ft.PollingInterval = TimeSpan.FromSeconds(2);
            ft.Until(ExpectedConditions.AlertIsPresent());
        }
        public void Method()
        {
            wait.Until(ExpectedConditions.TitleIs("webdriver - Поиск в Google"));
            wait.Until(ExpectedConditions.TitleContains("webdriver - Поиск в"));
            wait.Until(ExpectedConditions.UrlContains("login.php"));
            wait.Until(ExpectedConditions.UrlToBe("http://pagination.js.org/"));
            var regex = @"\d";

            wait.Until(ExpectedConditions.UrlMatches(regex));
            wait.Until(ExpectedConditions.AlertIsPresent());
            //В С# я не нашел  wait.Until(ExpectedConditions.NumberOfWindowsToBe());
            //нужно проверять то, что у элемента есть какой-то класс, вместо того, чтобы проверять стиль элемента.
            //как правило, разработчики не меняют стили напрямую, они присваивают классы.
            wait.Until(x => x.FindElement(By.CssSelector("locator")).GetAttribute("class").Contains("error"));
            wait.Until(ExpectedConditions.TextToBePresentInElement(element, "text"));
            wait.Until(ExpectedConditions.ElementToBeSelected(element, false));
            wait.Until(ExpectedConditions.ElementToBeClickable(element));
            //ElementToBeClickable - не  соответствует своему названию. Сдесь проверяется то, что
            //елемент 1.Видимый, 2.Не disabled. И конечно, здесь нет никаких проверок, что эта кнопка НЕ ЗАКРЫТА никаким другим
            //элементом а если она прозрачная, то она будет считаться невидимой. Так, что название этого метода просто напросто врет.
            //По-настоящему ИНТЕРАКТИВНОСТЬ ОНО НЕ ПРОВЕРЯЕТ.
            //условие количества элементов с локатором
            var elements = driver.FindElements(By.CssSelector("locator"));

            wait.Until(x => elements.Count == 10);
            //но здесь мы возвращаем коллекцию элементов.
            var returnedElements = wait.Until(x =>
            {
                var elements2 = x.FindElements(By.CssSelector("locaotr"));
                return(elements2.Count == 10 ? elements2 : null);
            });
            //хз что это...
            var wait2 = new DefaultWait <IWebElement>(element);
        }
 /// <summary>
 /// Wait for alert to be present for given timeout
 /// </summary>
 /// <param name="timeOutSeconds"></param>
 public static void WaitForAlertPresent(TimeSpan timeOutSecs)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(DriverInstance.Instance, timeOutSecs);
         wait.Until(ExpectedConditions.AlertIsPresent());
         LoggerInstance.log.Info("Driver explicitly waits" + timeOutSecs + " seconds for alert to be present");
     }
     catch (NoAlertPresentException alertNotPresent)
     {
         LoggerInstance.log.Info(alertNotPresent.Message, alertNotPresent);
     }
     catch (WebDriverTimeoutException webdriverTimeOut)
     {
         LoggerInstance.log.Error(webdriverTimeOut.Message, webdriverTimeOut);
     }
     catch (TimeoutException timeOut)
     {
         LoggerInstance.log.Error(timeOut.Message, timeOut);
     }
     catch (Exception e)
     {
         LoggerInstance.log.Error(e.Message, e);
     }
 }
Exemple #16
0
        public void ClickOkOnAlert()
        {
            WebDriverWait wait    = new WebDriverWait(webDriver, TimeSpan.FromSeconds(15));
            var           element = wait.Until(ExpectedConditions.AlertIsPresent());

            element.Accept();
        }
Exemple #17
0
        static void Main(string[] args)
        {
            string id = Convert.ToString(ConfigurationManager.AppSettings["ID"]);
            string pw = Convert.ToString(ConfigurationManager.AppSettings["PW"]);

            Console.WriteLine("ID : " + id);

            if (string.IsNullOrEmpty(id))
            {
                Console.WriteLine("ID value is Empty. Check GmarketDailyCheck.exe.config");
                Console.ReadLine();
                Environment.Exit(0);
            }

            IWebDriver driver = new ChromeDriver();


            try
            {
                driver.Url = "https://signinssl.gmarket.co.kr/LogOut/LogOut";

                IWebElement element;
                //element = driver.FindElement(By.Id("css_login_box"));
                //element.Click();

                WebDriverWait waitForElement = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                waitForElement.Until(ExpectedConditions.ElementIsVisible(By.Id("id")));

                element = driver.FindElement(By.Id("id"));
                element.SendKeys(id);
                element = driver.FindElement(By.Id("pwd"));
                element.SendKeys(pw);
                element = driver.FindElement(By.CssSelector("button[title='login']"));
                element.Click();

                driver.Navigate().GoToUrl("http://promotion.gmarket.co.kr/Event/pluszone.asp");

                waitForElement = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                waitForElement.Until(ExpectedConditions.ElementIsVisible(By.Id("AttendRulletFrame")));

                driver.SwitchTo().Frame(driver.FindElement(By.Id("AttendRulletFrame")));
                element = driver.FindElement(By.CssSelector("a.button_start"));
                element.Click();

                AdditionalAttendBonus(driver);
            }
            catch (UnhandledAlertException e)
            {
                IAlert alert = ExpectedConditions.AlertIsPresent().Invoke(driver);
                driver.SwitchTo().Alert().Accept();

                AdditionalAttendBonus(driver);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }
        public void Delete()
        {
            DeleteButton.Click();
            var driver = DriverFactory.Driver;

            new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(ExpectedConditions.AlertIsPresent());
            driver.SwitchTo().Alert().Accept();
        }
Exemple #19
0
        public static void AcceptAlert()
        {
            DriverWait.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert = Driver.SwitchTo().Alert();

            Logger.LogMsg(Severity.WARN, string.Format("There is an alert with text >>> {0}", alert.Text));
            alert.Accept();
        }
        public static void WaitForAlert()
        {
            ObjectRepository.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
            var wait = GetWebDriverWait(60);

            wait.Until(ExpectedConditions.AlertIsPresent());
            ObjectRepository.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(ObjectRepository.Config.GetElementLoadTimeOut()));
        }
Exemple #21
0
        /*-------------------------------------------------------------------*/

        protected override void Execute(IWebDriver webDriver)
        {
            var wait  = new WebDriverWait(webDriver, _timeout);
            var alert = wait.Until(ExpectedConditions.AlertIsPresent());

            alert.SetAuthenticationCredentials(_username, _password);
            alert.Accept();
        }
Exemple #22
0
      protected IAlert getAlert()
      {
          IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent());

          driver.SwitchTo().Alert();

          return(alert);
      }
Exemple #23
0
        protected IAlert WaitUntilAlertIsPresent(int timeoutSeconds = DefaultWaitSeconds)
        {
            var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(timeoutSeconds));

            wait.Message = "Alert did not pop up before timeout.";
            wait.Until(ExpectedConditions.AlertIsPresent());
            return(Driver.SwitchTo().Alert());
        }
        public void Init()
        {
            var capability = new DesiredCapabilities();

            if (ConfigurationManager.GetSection("capabilities/" + this.profile) is NameValueCollection caps)
            {
                foreach (var key in caps.AllKeys)
                {
                    capability.SetCapability(key, caps[key]);
                }
            }

            if (ConfigurationManager.GetSection("environments/" + this.device) is NameValueCollection devices)
            {
                foreach (var key in devices.AllKeys)
                {
                    capability.SetCapability(key, devices[key]);
                }
            }

            var username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME") ?? ConfigurationManager.AppSettings.Get("user");

            var accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY") ?? ConfigurationManager.AppSettings.Get("key");

            capability.SetCapability("browserstack.user", username);
            capability.SetCapability("browserstack.key", accesskey);

            var appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID");

            if (appId != null)
            {
                capability.SetCapability("app", appId);
            }

            var browserstackLocalArgs = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("key", accesskey)
            };

            if ((capability.GetCapability("browserstack.local") != null) && (capability.GetCapability("browserstack.local").ToString() == "true"))
            {
                this.browserStackLocal = new Local();
                this.browserStackLocal.start(browserstackLocalArgs);
            }

            this.Driver = new IOSDriver <IOSElement>(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability);
            var wait = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(30));

            try
            {
                wait.Until(ExpectedConditions.AlertIsPresent());
                this.Driver.SwitchTo().Alert().Accept();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #25
0
        private void AcceptAlert()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(1));

            wait.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert = driver.SwitchTo().Alert();

            alert.Accept();
        }
Exemple #26
0
        public string OpActionSendEnumKeyToAlert(string operationText)
        {
            IAlert alert;

            alert = ExpectedConditions.AlertIsPresent().Invoke(testStuff.driver); //zamiast może być try catch z no alert present exception

            if (alert != null)
            {
                switch (operationText)
                {
                case "Escape":
                    testStuff.driver.SwitchTo().Alert().SendKeys(OpenQA.Selenium.Keys.Escape);
                    return("ok");

                case "Enter":
                    testStuff.driver.SwitchTo().Alert().SendKeys(OpenQA.Selenium.Keys.Enter);
                    return("ok");

                case "Tab":
                    testStuff.driver.SwitchTo().Alert().SendKeys(OpenQA.Selenium.Keys.Tab);
                    return("ok");

                default:
                    return("SendKey(): Can't recognize key code " + operationText);
                }
            }
            else
            {
                testStuff.Log("SendEnumKeyToAlert(): exception caught \"NoAlertPresentException\". Next: return \"ok\".");
                return("ok"); //to jest dziwne, ale zakładam, że intencją jest najczęściej pozbycie się alertu
            }

            /*
             * try
             * {
             *  switch (operationText)
             *  {
             *      case "Escape":
             *          testStuff.driver.SwitchTo().Alert().SendKeys(OpenQA.Selenium.Keys.Escape);
             *          return "ok";
             *      case "Enter":
             *          testStuff.driver.SwitchTo().Alert().SendKeys(OpenQA.Selenium.Keys.Enter);
             *          return "ok";
             *      case "Tab":
             *          testStuff.driver.SwitchTo().Alert().SendKeys(OpenQA.Selenium.Keys.Tab);
             *          return "ok";
             *      default:
             *          return "SendKey(): Can't recognize key code " + operationText;
             *  }
             * }
             * catch (NoAlertPresentException)
             * {
             *  testStuff.Log("SendEnumKeyToAlert(): exception caught \"NoAlertPresentException\".");
             *  return "SendEnumKeyToAlert(): NoAlertPresentException";
             * }
             */
        }
Exemple #27
0
        public void checkAlert()
        {
            IAlert alert = ExpectedConditions.AlertIsPresent().Invoke(driver);

            if (alert != null)
            {
                driver.SwitchTo().Alert().Accept();
            }
        }
        public static void HandleAlert()
        {
            WebDriverWait wait1 = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wait1.Until(ExpectedConditions.AlertIsPresent());
            IAlert alert1 = driver.SwitchTo().Alert();

            alert1.Accept();
            driver.SwitchTo().DefaultContent();
        }
Exemple #29
0
        public string ClickForAlert()
        {
            JSAlert.Click();
            WebDriverWait wait  = new WebDriverWait(_driver, TimeSpan.FromSeconds(5));
            IAlert        alert = wait.Until(ExpectedConditions.AlertIsPresent());
            string        text  = alert.Text;

            alert.Accept();
            return(text);
        }
Exemple #30
0
        public void ensureSignUpCompleted()
        {
            Driver.FindElement(By.XPath("//button[contains(text(), 'Sign up')]")).Click();

            WebDriverWait wait     = new WebDriverWait(Driver, TimeSpan.FromSeconds(5));
            IAlert        alertBox = wait.Until(ExpectedConditions.AlertIsPresent());

            Assert.Equal("Sign up successful.", alertBox.Text);
            alertBox.Dismiss();
        }