OpenQA.Selenium.AlertsTest.ShouldThrowAnExceptionIfAnAlertHasNotBeenDealtWith C# (CSharp) Méthode

ShouldThrowAnExceptionIfAnAlertHasNotBeenDealtWith() private méthode

private ShouldThrowAnExceptionIfAnAlertHasNotBeenDealtWith ( ) : void
Résultat void
        public void ShouldThrowAnExceptionIfAnAlertHasNotBeenDealtWith()
        {
            driver.Url = alertsPage;

            driver.FindElement(By.Id("alert")).Click();

            IAlert alert = driver.SwitchTo().Alert();
            try
            {
                string title = driver.Title;
            }
            catch (InvalidOperationException)
            {
                // this is an expected exception
            }

            // but the next call should be good.
            Assert.AreEqual("Testing Alerts", driver.Title);
        }