Пример #1
0
 public void TestClickNextBlog()
 {
     using (var browser = new IE("http://localhost:8888/Blog/My-New-iMac"))
     {
         var funnyDialog = new AlertDialogHandler();
         using (new UseDialogOnce(browser.DialogWatcher, funnyDialog))
         {
             browser.Link("MainContent_linkNextBlog").ClickNoWait();
             funnyDialog.WaitUntilExists();
             funnyDialog.OKButton.Click();
             Assert.IsTrue(funnyDialog.Message.Contains("I've told you I am writing:)"));
         }
         browser.WaitForComplete(3);
     }
 }
Пример #2
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.");
            }
        }
Пример #4
0
        //private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        //{
        //    var htmlText = this.webBrowser1.DocumentText;
        //    if (htmlText.Contains("</script><script>alert(1)</script>"))
        //        MessageBox.Show("ok: " + position);
        //    if (fuzzing)
        //        NavigateNext();
        //}
        private void StartFuzz()
        {
            var x = 0;
            var posX = 0;

            while (true)
            {
                var c = Encoding.ASCII.GetString(new byte[] { (byte)x });
                var c2 = Encoding.ASCII.GetString(new byte[] { (byte)(x + 10007) });
                var c3 = Encoding.ASCII.GetString(new byte[] { (byte)(x + 10099) });
                var c4 = Encoding.ASCII.GetString(new byte[] { (byte)(x + 23) });
                //c+= Encoding.ASCII.GetString(new byte[] { (byte)y });

                //var payload = "</script><script>a(1);</script>";
                var payload = "<iframe/**/src=test2>";
                payload = payload.Insert(posX % payload.Length, c);

                if(x==255)
                {
                    x = 0;
                    posX++;
                }

                if (posX >= payload.Length)
                    break;

                x++;

                var url = "http://localhost:2000/test?s=" + payload;

                this.GoToString(url);

                var k = this.browser.Html;
                AlertDialogHandler alertDialogHandler = new AlertDialogHandler();
                using (new UseDialogOnce(browser.DialogWatcher, alertDialogHandler))
                {
                    if (alertDialogHandler.Exists())
                        MessageBox.Show("sdf");
                }

                //if(k.ToLower().Contains("<iframe"))
                //    MessageBox.Show("sdf");

            }
        }
Пример #5
0
 public DialogHandler()
 {
     alertHandler = new AlertDialogHandler();
     confirmHandler = new ConfirmDialogHandler();
 }