Example #1
0
        public void WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnCancelShouldKeepIEOpen()
        {
            using (var ie = new IE(OnBeforeUnloadJavaDialogURI))
            {
                var returnDialogHandler = new ReturnDialogHandler();
                ie.AddDialogHandler(returnDialogHandler);

                var hWnd = ie.hWnd;

                // can't use ie.Close() here cause this will cleanup the registered
                // returnDialogHandler which leads to a timeout on the WaitUntilExists
                var internetExplorer = (IWebBrowser2)ie.InternetExplorer;
                internetExplorer.Quit();

                returnDialogHandler.WaitUntilExists();
                returnDialogHandler.CancelButton.Click();

                Thread.Sleep(2000);
                Assert.IsTrue(IE.Exists(new AttributeConstraint("hwnd", hWnd.ToString())));

                // finally close the ie instance
                internetExplorer.Quit();
                returnDialogHandler.WaitUntilExists();
                returnDialogHandler.OKButton.Click();
            }
        }
Example #2
0
        private static bool IsIEWindowOpen(string partialTitle)
        {
            // Give windows some time to do work before checking
            Thread.Sleep(1000);

            return(IE.Exists(Find.ByTitle(partialTitle)));
        }
Example #3
0
        private static void IEExistsAsserts(Constraint findByUrl)
        {
            Assert.IsFalse(IE.Exists(findByUrl));

            using (new IE(MainURI))
            {
                Assert.IsTrue(IE.Exists(findByUrl));
            }

            Assert.IsFalse(IE.Exists(findByUrl));
        }
Example #4
0
        public void IEExistsByHWND()
        {
            var hwnd = "0";

            Assert.IsFalse(IE.Exists(Find.By("hwnd", hwnd)), "hwnd = 0 should not be found");

            using (var ie = new IE(MainURI))
            {
                hwnd = ie.hWnd.ToString();
                Assert.IsTrue(IE.Exists(Find.By("hwnd", hwnd)), "hwnd of ie instance should be found");
            }

            Assert.IsFalse(IE.Exists(Find.By("hwnd", hwnd)), "hwnd of closed ie instance should not be found");
        }
Example #5
0
        public void ShouldCancelCloseBrowser()
        {
            using (var ie = new IE())
            {
                var hwnd = ie.hWnd.ToString();

                // GIVEN
                var command = "window.close();";
                using (new UseDialogOnce(ie.DialogWatcher, new CloseIEDialogHandler(false)))
                {
                    // WHEN
                    ie.Eval(command);
                }

                // THEN
                Assert.That(IE.Exists(Find.By("hwnd", hwnd)), Is.True, "Expected IE");
            }
        }