예제 #1
0
        public void CloseDriver_should_close_the_opened_browser_instance()
        {
            Profile browserProfile = new Profile();

            browserProfile.ProfileConfig.activation.browserName = WebDriverOptions.browser_Firefox;

            WebDriverOptions options = new WebDriverOptions()
            {
                BrowserProfile = browserProfile,
                IsRemote       = false,
            };

            string specialTitle = "WebSpyBrowser.CloseDriver TEST TEST";

            string[] specialWindows = new string[] { };

            specialWindows = GetDesktopWindowsWithSpecialTitle(specialTitle);
            specialWindows.Length.Should().Be(0, "Expected no windows with title <{0}> at the beginning", specialTitle);

            WebSpyBrowser.Initialize(options);

            string changeTitleScript = string.Format("document.title = '{0}'", specialTitle);

            WebSpyBrowser.ExecuteJavaScript(changeTitleScript);

            specialWindows = GetDesktopWindowsWithSpecialTitle(specialTitle);
            specialWindows.Length.Should().Be(1, "Expected only 1 window with title <{0}> after new driver was created", specialTitle);

            WebSpyBrowser.CloseDriver();

            specialWindows = GetDesktopWindowsWithSpecialTitle(specialTitle);
            specialWindows.Length.Should().Be(0, "Expected no windows with title <{0}> after the driver was closed", specialTitle);
        }
예제 #2
0
        public void Enumerate_Windows_Popup()
        {
            Helper.RunDefaultBrowser();
            Helper.LoadTestFile("page_opens_several_tabs.html");

            Helper.ClickId("openTab2");
            Helper.ClickId("openTab3");
            Helper.ClickId("openJavaScriptPopup");


            BrowserWindow[] actualWindows = WebSpyBrowser.GetBrowserWindows();

            string[] expectedWindowTitles = new string[]
            {
                "Page Tab1",
                "JavaScript Popup",
                "Page Tab3",
                "Page Tab2"
            };

            string[] actualTitles = actualWindows.Select(w => w.Title).ToArray();

            actualTitles.Should().Contain(expectedWindowTitles);

            WebSpyBrowser.CloseDriver();
        }
예제 #3
0
        public void Get_Frames_Tree()
        {
            string[] expectedTitles = new string[]
            {
                "DefaultContent",
                "firstFrame",
                "secondFrame",
                "secondFrame.idIframeInsideSecondFrame",
                "thirdFrame",
                "thirdFrame.0"
            };


            Helper.RunDefaultBrowser();
            Helper.LoadTestFile("page_with_frames.html");


            BrowserPageFrame        rootFrame = WebSpyBrowser.GetPageFramesTree();
            List <BrowserPageFrame> allFrames = rootFrame.ToList();

            string[] actualTitles = allFrames.Select(i => i.ToString()).ToArray();

            actualTitles.Should().Equal(expectedTitles);

            WebSpyBrowser.CloseDriver();
        }
        public void StopDriver()
        {
            MyLog.Write("StopDriver - Entered");
            view.DisableDriverStartButton();

            view.DriverIsStopping();

            Exception threadException;

            UIActions.PerformSlowOperation(
                "Operation: Stop WebDriver instance",
                () =>
            {
                Presenters.WebSpyMainPresenter.StopVisualSearch();
                WebSpyBrowser.CloseDriver();
            },
                out threadException,
                null,
                TimeSpan.FromMinutes(10)
                );

            if (threadException != null)
            {
                MyLog.Exception(threadException);
            }

            view.EnableDriverStartButton();

            wasBrowserStarted = false;
            MyLog.Write("StopDriver - Exited");
        }
예제 #5
0
        public void Initialize_should_be_able_to_start_new_browser()
        {
            Profile browserProfile = new Profile();

            browserProfile.ProfileConfig.activation.browserName = WebDriverOptions.browser_HtmlUnitWithJavaScript;

            WebDriverOptions options = new WebDriverOptions()
            {
                BrowserProfile = browserProfile,
                IsRemote       = true,
                RemoteUrl      = "http://localhost:4444/wd/hub/",
            };

            bool isSeleniumServerAvailable = true;

            try
            {
                WebSpyBrowser.TestRemoteHub(options.RemoteUrl);
            }
            catch (Exception e)
            {
                isSeleniumServerAvailable = false;
                Console.WriteLine("FAILED: " + e.Message);
            }

            if (!isSeleniumServerAvailable)
            {
                WebSpyBrowser.RunStandaloneServer("start_selenium_server.bat");
            }

            WebSpyBrowser.Initialize(options);

            var rempteDriver = (RemoteWebDriver)WebSpyBrowser.GetDriver();

            rempteDriver.Capabilities.BrowserName.Should().Be("htmlunit");

            WebSpyBrowser.CloseDriver();
        }