Beispiel #1
0
        public void CommandTimeoutNotANumberException()
        {
            string commandTimeout = Config.GetValueForSection(ConfigSection.SeleniumMaqs, "SeleniumCommandTimeout");

            Config.AddTestSettingValues(
                new Dictionary <string, string>
            {
                { "SeleniumCommandTimeout", "TestString" }
            },
                "SeleniumMaqs");

            try
            {
                var commandTimeoutFromMethod = SeleniumConfig.GetCommandTimeout();
                Assert.Fail($"We should throw an argument exception before we get to this assert.  Value was {commandTimeoutFromMethod}");
            }
            finally
            {
                Config.AddTestSettingValues(
                    new Dictionary <string, string>
                {
                    { "SeleniumCommandTimeout", commandTimeout }
                },
                    "SeleniumMaqs");
            }
        }
Beispiel #2
0
        public void GetCommandTimeout()
        {
            #region GetCommandTimeout

            TimeSpan initTimeout = SeleniumConfig.GetCommandTimeout();

            #endregion GetCommandTimeout

            Assert.AreEqual(TimeSpan.FromSeconds(61).Ticks, initTimeout.Ticks);
        }
Beispiel #3
0
        /// <summary>
        /// Override the web driver we user for these tests
        /// </summary>
        /// <returns>The web driver we want to use - Web driver override</returns>
        protected override IWebDriver GetBrowser()
        {
            var firefoxOptions = WebDriverFactory.GetDefaultFirefoxOptions();

            firefoxOptions.AddArgument("--headless");
            IWebDriver driver = WebDriverFactory.GetFirefoxDriver(SeleniumConfig.GetCommandTimeout(), firefoxOptions);

            driver.Manage().Window.Size = new Size(701, 199);

            return(driver);
        }
Beispiel #4
0
        public void OpenEdgeBrowser()
        {
            IWebDriver driver = null;

            try
            {
                driver = WebDriverFactory.GetBrowserWithDefaultConfiguration(BrowserType.Edge);
                driver.Navigate().GoToUrl(Config.GetValueForSection(ConfigSection.SeleniumMaqs, "WebSiteBase"));
            }
            catch
            {
                // May need to run headless on some systems
                var headlessEdgeOptions = WebDriverFactory.GetDefaultEdgeOptions();
                headlessEdgeOptions.AddArgument("--no-sandbox");
                headlessEdgeOptions.AddArguments("--headless");

                driver = WebDriverFactory.GetEdgeDriver(SeleniumConfig.GetCommandTimeout(), headlessEdgeOptions);
                driver.Navigate().GoToUrl(Config.GetValueForSection(ConfigSection.SeleniumMaqs, "WebSiteBase"));
            }
            finally
            {
                driver?.KillDriver();
            }
        }
        protected override IWebDriver GetBrowser()
        {
            if (string.Equals(Config.GetValueForSection(ConfigSection.RemoteSeleniumCapsMaqs, "RunOnSauceLabs"), "YES", System.StringComparison.OrdinalIgnoreCase))
            {
                var name         = this.TestContext.FullyQualifiedTestClassName + "." + this.TestContext.TestName;
                var sauceOptions = new Dictionary <string, object>
                {
                    ["screenResolution"] = "1280x1024",
                    ["build"]            = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAUCE_BUILD_NAME")) ? BuildDate : Environment.GetEnvironmentVariable("SAUCE_BUILD_NAME"),
                    ["name"]             = name
                };

                var remoteCapabilitySection = Config.GetSection(ConfigSection.RemoteSeleniumCapsMaqs);
                if (remoteCapabilitySection != null)
                {
                    foreach (var keyValue in remoteCapabilitySection)
                    {
                        if (remoteCapabilitySection[keyValue.Key].Length > 0)
                        {
                            sauceOptions.Add(keyValue.Key, keyValue.Value);
                        }
                    }
                }

                var browserOptions = new ChromeOptions
                {
                    UseSpecCompliantProtocol = true,
                    PlatformName             = "Windows 10",
                    BrowserVersion           = "latest"
                };
                browserOptions.AddAdditionalCapability("sauce:options", sauceOptions, true);

                var remoteCapabilities = browserOptions.ToCapabilities();

                return(new RemoteWebDriver(new Uri(Config.GetValueForSection(ConfigSection.SeleniumMaqs, "HubUrl")), remoteCapabilities, SeleniumConfig.GetCommandTimeout()));
            }

            return(base.GetBrowser());
        }
Beispiel #6
0
        protected override IWebDriver GetBrowser()
        {
            if (string.Equals(Config.GetValueForSection(ConfigSection.SeleniumMaqs, "RunOnSauceLabs"), "YES", StringComparison.OrdinalIgnoreCase))
            {
                var name    = this.TestContext.FullyQualifiedTestClassName + "." + this.TestContext.TestName;
                var options = SeleniumConfig.GetRemoteCapabilitiesAsObjects();

                var sauceOptions = options["sauce:options"] as Dictionary <string, object>;
                sauceOptions.Add("screenResolution", "1280x1024");
                sauceOptions.Add("build", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SAUCE_BUILD_NAME")) ? BuildDate : Environment.GetEnvironmentVariable("SAUCE_BUILD_NAME"));
                sauceOptions.Add("name", name);

                var browserOptions = new ChromeOptions
                {
                    UseSpecCompliantProtocol = true,
                    PlatformName             = "Windows 10",
                    BrowserVersion           = "latest"
                };

                browserOptions.SetDriverOptions(options);

                var remoteCapabilities = browserOptions.ToCapabilities();

                return(new RemoteWebDriver(new Uri(Config.GetValueForSection(ConfigSection.SeleniumMaqs, "HubUrl")), remoteCapabilities, SeleniumConfig.GetCommandTimeout()));
            }

            return(base.GetBrowser());
        }
Beispiel #7
0
        public void GetCommandTimeout()
        {
            TimeSpan initTimeout = SeleniumConfig.GetCommandTimeout();

            Assert.AreEqual(TimeSpan.FromSeconds(200).Ticks, initTimeout.Ticks);
        }