Beispiel #1
0
        /// <summary>
        /// Dismisses the alert.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="text">The text to enter.</param>
        public override void DismissAlert(AlertBoxAction action, string text)
        {
            var alert = this.driver.Value.SwitchTo().Alert();

            if (text != null)
            {
                alert.SendKeys(text);
            }

            switch (action)
            {
            case AlertBoxAction.Cancel:
            case AlertBoxAction.Close:
            case AlertBoxAction.Ignore:
            case AlertBoxAction.No:
                alert.Dismiss();
                break;

            case AlertBoxAction.Ok:
            case AlertBoxAction.Retry:
            case AlertBoxAction.Yes:
                alert.Accept();
                break;
            }
        }
        /// <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();
        }
Beispiel #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 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 = this.CreateMockWebDriverExpectingInitialization();

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

            this.TestBrowserWith(driver, browser =>
            {
                browser.DismissAlert(action, null);
            });

            alerter.VerifyAll();
            locator.VerifyAll();
        }
Beispiel #4
0
        /// <summary>
        /// Dismisses the alert.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="text">The text to enter.</param>
        public override void DismissAlert(AlertBoxAction action, string text)
        {
            var localBrowser = this.window.Value;

            if (text != null)
            {
                localBrowser.PerformDialogAction(BrowserDialogAction.PromptText, text);
                return;
            }

            // Get the action
            var browserAction = BrowserDialogAction.None;

            switch (action)
            {
            case AlertBoxAction.Cancel:
                browserAction = BrowserDialogAction.Cancel;
                break;

            case AlertBoxAction.Close:
                browserAction = BrowserDialogAction.Close;
                break;

            case AlertBoxAction.Ignore:
                browserAction = BrowserDialogAction.Ignore;
                break;

            case AlertBoxAction.No:
                browserAction = BrowserDialogAction.No;
                break;

            case AlertBoxAction.Ok:
                browserAction = BrowserDialogAction.Ok;
                break;

            case AlertBoxAction.Retry:
                browserAction = BrowserDialogAction.Retry;
                break;

            case AlertBoxAction.Yes:
                browserAction = BrowserDialogAction.Yes;
                break;
            }

            localBrowser.PerformDialogAction(browserAction);
        }
        /// <summary>
        /// Dismisses the alert.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="text">The text to enter.</param>
        public override void DismissAlert(AlertBoxAction action, string text)
        {
            var alert = this.driver.Value.SwitchTo().Alert();

            if (text != null)
            {
                alert.SendKeys(text);
            }

            switch (action)
            {
                case AlertBoxAction.Cancel:
                case AlertBoxAction.Close:
                case AlertBoxAction.Ignore:
                case AlertBoxAction.No:
                    alert.Dismiss();
                    break;
                case AlertBoxAction.Ok:
                case AlertBoxAction.Retry:
                case AlertBoxAction.Yes:
                    alert.Accept();
                    break;
            }
        }
Beispiel #6
0
 /// <summary>
 /// Dismisses the alert.
 /// </summary>
 /// <param name="action">The action.</param>
 /// <param name="text">The text to enter.</param>
 public abstract void DismissAlert(AlertBoxAction action, string text);
Beispiel #7
0
        /// <summary>
        /// Dismisses the alert.
        /// </summary>
        /// <param name="action">The action.</param>
        /// <param name="text">The text to enter.</param>
        public override void DismissAlert(AlertBoxAction action, string text)
        {
            var localBrowser = this.window.Value;

            if (text != null)
            {
                localBrowser.PerformDialogAction(BrowserDialogAction.PromptText, text);
                return;
            }

            // Get the action
            var browserAction = BrowserDialogAction.None;
            switch (action)
            {
                case AlertBoxAction.Cancel:
                    browserAction = BrowserDialogAction.Cancel;
                    break;
                case AlertBoxAction.Close:
                    browserAction = BrowserDialogAction.Close;
                    break;
                case AlertBoxAction.Ignore:
                    browserAction = BrowserDialogAction.Ignore;
                    break;
                case AlertBoxAction.No:
                    browserAction = BrowserDialogAction.No;
                    break;
                case AlertBoxAction.Ok:
                    browserAction = BrowserDialogAction.Ok;
                    break;
                case AlertBoxAction.Retry:
                    browserAction = BrowserDialogAction.Retry;
                    break;
                case AlertBoxAction.Yes:
                    browserAction = BrowserDialogAction.Yes;
                    break;
            }

            localBrowser.PerformDialogAction(browserAction);
        }
        /// <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();
        }
		/// <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 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 = this.CreateMockWebDriverExpectingInitialization();
			driver.Setup(d => d.SwitchTo()).Returns(locator.Object);

			this.TestBrowserWith(driver, browser =>
			{
				browser.DismissAlert(action, null);
			});

            alerter.VerifyAll();
            locator.VerifyAll();
        }
Beispiel #10
0
 public void DismissAlert(AlertBoxAction action, string text)
 {
     browser.DismissAlert(action, text);
 }