Beispiel #1
0
        public void CloseSpecificBrowserAlert()
        {
            Assert.AreEqual(0, Ie.DialogWatcher.Count, "DialogWatcher count should be zero");

            var firstIE = Ie;

            firstIE.RunScript("document.title = 'firstIe'; ");

            using (var secondIe = new IE(TestPageUri, true))
            {
                secondIe.RunScript("document.title = 'secondIe'; ");
                // set up a second browser with an open dialog
                var secondAlertDialogHandler = new AlertDialogHandler();
                using (new UseDialogOnce(secondIe.DialogWatcher, secondAlertDialogHandler))
                {
                    secondIe.Button(Find.ByValue("Show alert dialog")).ClickNoWait();

                    secondAlertDialogHandler.WaitUntilExists(5);

                    // close the original message
                    var firstAlertDialogHandler = new AlertDialogHandler();
                    using (new UseDialogOnce(firstIE.DialogWatcher, firstAlertDialogHandler))
                    {
                        firstIE.Button(Find.ByValue("Show alert dialog")).ClickNoWait();

                        firstAlertDialogHandler.WaitUntilExists(5);

                        var message = firstAlertDialogHandler.Message;
                        firstAlertDialogHandler.OKButton.Click();

                        firstIE.WaitForComplete(5);

                        Assert.IsTrue(secondAlertDialogHandler.Exists(), "Original Alert Dialog should be open.");

                        Assert.AreEqual("This is an alert!", message, "Unexpected message");
                        Assert.IsFalse(firstAlertDialogHandler.Exists(), "Alert Dialog should be closed.");
                    }

                    // close the second message
                    secondAlertDialogHandler.OKButton.Click();

                    secondIe.WaitForComplete(5);

                    Assert.IsFalse(secondAlertDialogHandler.Exists(), "Alert Dialog should be closed.");
                }
            }
        }
		public void AlertDialogHandler()
		{
			Assert.AreEqual(0, Ie.DialogWatcher.Count, "DialogWatcher count should be zero");

			var alertDialogHandler = new AlertDialogHandler();
			using (new UseDialogOnce(Ie.DialogWatcher, alertDialogHandler))
			{
				Ie.Button(Find.ByValue("Show alert dialog")).ClickNoWait();

				alertDialogHandler.WaitUntilExists();

				var message = alertDialogHandler.Message;
				alertDialogHandler.OKButton.Click();

				Ie.WaitForComplete();

				Assert.AreEqual("This is an alert!", message, "Unexpected message");
				Assert.IsFalse(alertDialogHandler.Exists(), "Alert Dialog should be closed.");
			}
		}
 //
 // Some methods/functions declarations
 //
 public void SomeInitMethod()
 {
     dialogHandler = new AlertDialogHandler()
                     browse.AddDialogHandler(dialogHandler);
 }
Beispiel #4
0
 public DialogHandler()
 {
     alertHandler   = new AlertDialogHandler();
     confirmHandler = new ConfirmDialogHandler();
 }