Exemplo n.º 1
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());
        }