예제 #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 static void RunDefaultBrowser()
        {
            var browserProfile = new Profile();

            browserProfile.ProfileConfig.activation.browserName = "Firefox";

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

            WebSpyBrowser.Initialize(options);
        }
        public void StartDriver(WebDriverOptions browserOptions, bool shouldMaximizeBrowserWindow)
        {
            MyLog.Write("StartDriver - Entered");

            wasBrowserStarted = false;

            view.DisableDriverStartButton();

            Exception threadException;

            bool isSuccessful = UIActions.PerformSlowOperation(
                "Operation: Start new WebDriver instance",
                () =>
            {
                WebSpyBrowser.Initialize(browserOptions);
                wasBrowserStarted = true;

                if (shouldMaximizeBrowserWindow)
                {
                    WebSpyBrowser.Maximize();
                }
            },
                out threadException,
                null,
                TimeSpan.FromMinutes(10)
                );

            view.EnableDriverStartButton();

            if (isSuccessful)
            {
                SetDesiredCapabilities(browserOptions);
                view.DriverWasStarted();
            }
            else if (threadException != null)
            {
                throw threadException;
            }

            MyLog.Write("StartDriver - Exited");
        }
예제 #4
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();
        }