Exemplo n.º 1
0
        public void CloseDriver_should_close_the_opened_browser_instance()
        {
            WebDriverOptions options = new WebDriverOptions()
            {
                BrowserName = WebDriverOptions.browser_Firefox,
                IsRemote = false,
            };

            string specialTitle = "SwdBrowser.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);

            SwdBrowser.Initialize(options);

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

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

            SwdBrowser.CloseDriver();

            specialWindows = GetDesktopWindowsWithSpecialTitle(specialTitle);
            specialWindows.Length.Should().Be(0, "Expected no windows with title <{0}> after the driver was closed", specialTitle);
        }
Exemplo n.º 2
0
        public static void Initialize(WebDriverOptions browserOptions)
        {
            if (_driver != null)
            {
                _driver.Quit();
                if (OnDriverClosed != null)
                {
                    OnDriverClosed();
                }
                Started = false;
            }

            bool wasRemoteDriverCreated = false;

            _driver  = WebDriverUtils.Initialize(browserOptions, out wasRemoteDriverCreated);
            isRemote = wasRemoteDriverCreated;

            Started = true;

            // Fire OnDriverStarted event
            if (OnDriverStarted != null)
            {
                OnDriverStarted();
            }
        }
Exemplo n.º 3
0
        public static void Initialize(WebDriverOptions browserOptions)
        {
            if (_driver != null)
            {
                _driver.Quit();
                if (OnDriverClosed != null)
                {
                    OnDriverClosed();
                }
                Started = false;
            }

            _driver = WebDriverUtils.Initialize(browserOptions);

            Started = true;

            // Fire OnDriverStarted event
            if (OnDriverStarted != null)
            {
                OnDriverStarted();
            }
        }
        internal void SetBrowserStartupSettings(WebDriverOptions browserOptions)
        {
            Action action = new Action(() =>
            {
                chkUseRemoteHub.Checked = browserOptions.IsRemote;

                var index = ddlBrowserToStart.Items.IndexOf(browserOptions.BrowserName);

                ddlBrowserToStart.SelectedIndex = index;

                txtRemoteHubUrl.Text = browserOptions.RemoteUrl;
            });

            if (this.InvokeRequired)
            {
                this.Invoke(action);
            }
            else
            {
                action();
            }
        }
        private void btnStartWebDriver_Click(object sender, EventArgs e)
        {
            var isRemoteDriver = chkUseRemoteHub.Checked;
            var startSeleniumServerIfNotStarted = chkAutomaticallyStartServer.Checked;
            var shouldMaximizeBrowserWindow = chkMaximizeBrowserWindow.Checked;

            var browserOptions = new WebDriverOptions()
            {
                BrowserName = ddlBrowserToStart.SelectedItem as string,
                IsRemote = isRemoteDriver,
                RemoteUrl = txtRemoteHubUrl.Text,
            };

            Presenter.StartNewBrowser(browserOptions, startSeleniumServerIfNotStarted, shouldMaximizeBrowserWindow);
        }
Exemplo n.º 6
0
        public static void Initialize(WebDriverOptions browserOptions)
        {
            if (_driver != null)
            {
                _driver.Quit();
                if (OnDriverClosed != null) OnDriverClosed();
                Started = false;
            }

            bool wasRemoteDriverCreated = false;
            _driver = WebDriverUtils.Initialize(browserOptions, out wasRemoteDriverCreated);
            isRemote = wasRemoteDriverCreated;

            Started = true;

            // Fire OnDriverStarted event
            if (OnDriverStarted != null)
            {
                OnDriverStarted();

            }
        }
Exemplo n.º 7
0
        public static void RunDefaultBrowser()
        {
            WebDriverOptions options = new WebDriverOptions()
            {
                BrowserName = WebDriverOptions.browser_Firefox
                //BrowserName = WebDriverOptions.browser_PhantomJS,
            };

            SwdBrowser.Initialize(options);
        }
Exemplo n.º 8
0
        public static void Initialize(WebDriverOptions browserOptions)
        {
            if (_driver != null)
            {
                _driver.Quit();
                if (OnDriverClosed != null) OnDriverClosed();
                Started = false;
            }

            _driver = WebDriverUtils.Initialize(browserOptions);

            Started = true;

            // Fire OnDriverStarted event
            if (OnDriverStarted != null)
            {
                OnDriverStarted();
            }
        }
Exemplo n.º 9
0
        public void Initialize_should_be_able_to_start_new_browser()
        {
            WebDriverOptions options = new WebDriverOptions()
            {
                 BrowserName = WebDriverOptions.browser_HtmlUnitWithJavaScript,
                 IsRemote = true,
                 RemoteUrl = "http://localhost:4444/wd/hub/",
            };

            bool isSeleniumServerAvailable = true;

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

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

            SwdBrowser.Initialize(options);

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

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

            SwdBrowser.CloseDriver();
        }
Exemplo n.º 10
0
        private void btnStartWebDriver_Click(object sender, EventArgs e)
        {
            var browserOptions = new WebDriverOptions()
            {
                BrowserName = ddlBrowserToStart.SelectedItem as string,
                IsRemote = chkUseRemoteHub.Checked,
                RemoteUrl = txtRemoteHubUrl.Text,
            };

            Presenter.StartNewBrowser(browserOptions);
        }
        private void btnStartWebDriver_Click(object sender, EventArgs e)
        {
            WebDriverOptions browserOptions;
            var isRemoteDriver = chkUseRemoteHub.Checked;
            var startSeleniumServerIfNotStarted = chkAutomaticallyStartServer.Checked;
            var shouldMaximizeBrowserWindow = chkMaximizeBrowserWindow.Checked;
            if (dtAdditonalCapabilities.vendorBrowser != null && dtAdditonalCapabilities.vendorBrowser.Custom)
            {

                foreach (DataGridViewRow row in dtAdditonalCapabilities.dataGridView.Rows)
                {
                    string name = row.Cells[0].ToString();
                    string value = row.Cells[1].ToString();
                    if (String.Compare(name, "browser", true) == 0)
                    {
                        dtAdditonalCapabilities.vendorBrowser.Browser = value;
                    }
                    if (String.Compare(name, "version", true) == 0)
                    {
                        dtAdditonalCapabilities.vendorBrowser.Version = value;
                    }
                    if (String.Compare(name, "platform", true) == 0)
                    {
                        dtAdditonalCapabilities.vendorBrowser.Platform = value;
                    }
                    dtAdditonalCapabilities.vendorBrowser.HubUrl = txtRemoteHubUrl.Text;
                }

                browserOptions = new WebDriverOptions()
                {
                    BrowserName = dtAdditonalCapabilities.vendorBrowser.Browser,
                    BrowserPlatform = dtAdditonalCapabilities.vendorBrowser.Platform,
                    BrowserVersion = dtAdditonalCapabilities.vendorBrowser.Version,
                    IsRemote = isRemoteDriver,
                    RemoteUrl = txtRemoteHubUrl.Text,
                };

            }
            else
            {

                browserOptions = new WebDriverOptions()
                {
                    BrowserName = ddlBrowserToStart.SelectedItem as string,
                    IsRemote = isRemoteDriver,
                    RemoteUrl = txtRemoteHubUrl.Text,
                };

            }
            Presenter.StartNewBrowser(browserOptions, startSeleniumServerIfNotStarted, shouldMaximizeBrowserWindow);
        }
        private void btnStartWebDriver_Click(object sender, EventArgs e)
        {
            var shouldMaximizeBrowserWindow = chkMaximizeBrowserWindow.Checked;

            var browserOptions = new WebDriverOptions()
            {
                BrowserName = ddlBrowserToStart.SelectedItem as string,
                RemoteUrl = txtRemoteHubUrl.Text,
            };

            Presenter.StartNewBrowser(browserOptions, shouldMaximizeBrowserWindow);
        }
Exemplo n.º 13
0
        public static void RunDefaultBrowser()
        {
            var browserProfile = new Profile();
            browserProfile.ProfileConfig.activation.browserName = "Firefox";

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

            };

            SwdBrowser.Initialize(options);
        }