コード例 #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;
            }
        }
コード例 #2
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();
        }
コード例 #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();
        }
コード例 #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);
        }
コード例 #5
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;
            }
        }
コード例 #6
0
ファイル: BrowserBase.cs プロジェクト: DavidPx/specbind
 /// <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);
コード例 #7
0
ファイル: CodedUIBrowser.cs プロジェクト: NickMcG/specbind
        /// <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);
        }
コード例 #8
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();
        }
コード例 #9
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();
        }
コード例 #10
0
 public void DismissAlert(AlertBoxAction action, string text)
 {
     browser.DismissAlert(action, text);
 }