Exemplo n.º 1
0
        public static IWebDriver GetWebDriver(bool withEvents)
        {
            Func <IWebDriver> webDriverFunc;
            DriverOptions     options;

            switch (Config.Browser)
            {
            case BrowserType.Chrome:
                options = new ChromeOptions();
                // ((ChromeOptions) options).AddArgument("no-sandbox");
                // ((ChromeOptions) options).AddArgument("headless");
                options.SetLoggingPreference(LogType.Browser, LogLevel.All);
                webDriverFunc = () =>
                {
                    var driver = new ChromeDriver((ChromeOptions)options);
                    return(driver);
                };
                break;

            case BrowserType.Firefox:
                options = new FirefoxOptions {
                    AcceptInsecureCertificates = true
                };
                options.SetLoggingPreference(LogType.Browser, LogLevel.All);
                webDriverFunc = () => new FirefoxDriver((FirefoxOptions)options);
                break;

            default:
                throw new Exception($"Browser {Config.Browser} is not supported");
            }


            if (Config.Selenoid)
            {
                options.AddAdditionalOption("selenoid:options", new Dictionary <string, object>
                {
                    ["enableLog"]   = true,
                    ["enableVnc"]   = false,
                    ["enableVideo"] = false,
                });
                options.AddAdditionalOption("env", new Dictionary <string, object>
                {
                    ["VERBOSE"] = true,
                });
                webDriverFunc = () => new RemoteWebDriverWithLogs(new Uri(Config.SelenoidHubUrl), options);
            }

            var webDriver = webDriverFunc.Invoke();

            webDriver.Manage().Window.Size = new Size(1600, 800);

            return((withEvents) ? GetEventFiringWebDriver(webDriver) : webDriver);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var driverOptions = new FirefoxOptions();

            driverOptions.AddAdditionalOption("se:recordVideo", true);
            driverOptions.AddAdditionalOption("se:timeZone", "US/Pacific");
            driverOptions.AddAdditionalOption("se:screenResolution", "1920x1080");

            var driver = new RemoteWebDriver(new Uri("http://localhost:4444"), driverOptions);

            driver.Navigate().GoToUrl("http://www.google.com");
            Thread.Sleep(5000);
            driver.Quit();
        }
Exemplo n.º 3
0
        public void FirefoxW3C()
        {
            var browserOptions = new FirefoxOptions
            {
                BrowserVersion = "latest",
                PlatformName   = "Windows 10"
            };

            sauceOptions.Add("name", MethodBase.GetCurrentMethod().Name);
            browserOptions.AddAdditionalOption("sauce:options", sauceOptions);

            _driver = new RemoteWebDriver(new Uri("https://ondemand.saucelabs.com/wd/hub"),
                                          browserOptions.ToCapabilities(), TimeSpan.FromSeconds(30));
            _driver.Navigate().GoToUrl("https://www.saucedemo.com");
            GoToThenAssert();
        }
Exemplo n.º 4
0
 private void CreateWebDriverWithProfiling()
 {
     if (TestUtilities.IsFirefox(driver))
     {
         FirefoxOptions options = new FirefoxOptions();
         options.AddAdditionalOption(CapabilityType.EnableProfiling, true);
         localDriver = new FirefoxDriver(options);
     }
     else if (TestUtilities.IsChrome(driver))
     {
         ChromeOptions options = new ChromeOptions();
         options.AddAdditionalOption(CapabilityType.EnableProfiling, true);
         localDriver = new ChromeDriver(options);
         ICapabilities c = ((IHasCapabilities)localDriver).Capabilities;
     }
 }