Пример #1
0
        /// <summary>
        /// Tests the alert scenario.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="acceptResult">if set to <c>true</c> the result should accept; otherwise it should dismiss.</param>
        private static void TestAlertScenario(AlertBoxAction action, bool acceptResult)
        {
            var alerter = new Mock <IAlert>(MockBehavior.Strict);

            if (acceptResult)
            {
                alerter.Setup(a => a.Accept());
            }
            else
            {
                alerter.Setup(a => a.Dismiss());
            }

            var locator = new Mock <ITargetLocator>(MockBehavior.Strict);

            locator.Setup(l => l.Alert()).Returns(alerter.Object);

            var driver = new Mock <IWebDriver>(MockBehavior.Strict);

            driver.Setup(d => d.SwitchTo()).Returns(locator.Object);

            var logger = new Mock <ILogger>(MockBehavior.Loose);

            var browser = new SeleniumBrowser(new Lazy <IWebDriver>(() => driver.Object), logger.Object);

            browser.DismissAlert(action, null);

            alerter.VerifyAll();
            driver.VerifyAll();
            locator.VerifyAll();
        }
Пример #2
0
        public void TestDismissAlertEntersTextAndAcceptsWhenOkIsChoosen()
        {
            var alerter = new Mock <IAlert>(MockBehavior.Strict);

            alerter.Setup(a => a.SendKeys("My Text"));
            alerter.Setup(a => a.Accept());

            var locator = new Mock <ITargetLocator>(MockBehavior.Strict);

            locator.Setup(l => l.Alert()).Returns(alerter.Object);

            var driver = new Mock <IWebDriver>(MockBehavior.Strict);

            driver.Setup(d => d.SwitchTo()).Returns(locator.Object);

            var logger = new Mock <ILogger>(MockBehavior.Loose);

            var browser = new SeleniumBrowser(new Lazy <IWebDriver>(() => driver.Object), logger.Object);

            browser.DismissAlert(AlertBoxAction.Ok, "My Text");

            alerter.VerifyAll();
            driver.VerifyAll();
            locator.VerifyAll();
        }
Пример #3
0
        /// <summary>
        /// Tests the alert scenario.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="acceptResult">if set to <c>true</c> the result should accept; otherwise it should dismiss.</param>
        private static void TestAlertScenario(AlertBoxAction action, bool acceptResult)
        {
            var alerter = new Mock<IAlert>(MockBehavior.Strict);

            if (acceptResult)
            {
                alerter.Setup(a => a.Accept());
            }
            else
            {
                alerter.Setup(a => a.Dismiss());
            }
            
            var locator = new Mock<ITargetLocator>(MockBehavior.Strict);
            locator.Setup(l => l.Alert()).Returns(alerter.Object);

            var driver = new Mock<IWebDriver>(MockBehavior.Strict);
            driver.Setup(d => d.SwitchTo()).Returns(locator.Object);

            var logger = new Mock<ILogger>(MockBehavior.Loose);

            var browser = new SeleniumBrowser(new Lazy<IWebDriver>(() => driver.Object), logger.Object);

            browser.DismissAlert(action, null);

            alerter.VerifyAll();
            driver.VerifyAll();
            locator.VerifyAll();
        }
Пример #4
0
        public void TestDismissAlertEntersTextAndAcceptsWhenOkIsChoosen()
        {
            var alerter = new Mock<IAlert>(MockBehavior.Strict);
            alerter.Setup(a => a.SendKeys("My Text"));
            alerter.Setup(a => a.Accept());

            var locator = new Mock<ITargetLocator>(MockBehavior.Strict);
            locator.Setup(l => l.Alert()).Returns(alerter.Object);

            var driver = new Mock<IWebDriver>(MockBehavior.Strict);
            driver.Setup(d => d.SwitchTo()).Returns(locator.Object);

            var logger = new Mock<ILogger>(MockBehavior.Loose);

            var browser = new SeleniumBrowser(new Lazy<IWebDriver>(() => driver.Object), logger.Object);

            browser.DismissAlert(AlertBoxAction.Ok, "My Text");

            alerter.VerifyAll();
            driver.VerifyAll();
            locator.VerifyAll();
        }