public static IWebDriver CreateDriver()
        {
            switch (LocalBrowser.ToLower())
            {
            case "chrome":
                WebDriver = new ChromeDriver(DriverPath);
                break;

            case "firefox":
                WebDriver = new FirefoxDriver();
                break;

            case "ie":
                var options = new InternetExplorerOptions();
                options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                WebDriver = new InternetExplorerDriver(DriverPath, options);
                // WebDriver = new InternetExplorerDriver(DriverPath);
                break;

            default:
                WebDriver = new ChromeDriver(DriverPath);
                break;
            }
            WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            WebDriver.Manage().Window.Maximize();


            return(WebDriver);
        }
예제 #2
0
        public static IWebDriver CreateDriver()
        {
            // IWebDriver webDriver;
            if (IsSauceLabsTest)
            {
                var capabilities = BuildDesiredCapabilities();
                WebDriver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"), capabilities,
                                                TimeSpan.FromSeconds(180));
            }
            else if (IsSeleniumGrid)
            {
                //DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
                //ChromeOptions options = new ChromeOptions();
                //options.BinaryLocation = "c:\\chromedriver.exe";
                //capabilities.SetCapability(ChromeOptions.Capability, options);


                DesiredCapabilities capabilities = DesiredCapabilities.Chrome();

                //  dc.SetCapability(CapabilityType.Platform, "WINDOWS");
                WebDriver = new RemoteWebDriver(new Uri(SeleniumGridURL), capabilities,
                                                TimeSpan.FromSeconds(60));
            }
            else
            {
                switch (LocalBrowser.ToLower())
                {
                case "chrome":
                    WebDriver = new ChromeDriver();
                    break;

                case "firefox":
                    WebDriver = new FirefoxDriver();
                    break;

                case "ie":
                    WebDriver = new InternetExplorerDriver();
                    break;

                default:
                    // if no options set correctly in config then use the default
                    WebDriver = new FirefoxDriver();
                    break;
                }

                // adding in 50 second implicit wait due to selenium grid needing at least 45s for nodes since thats the socket connection time
                WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            }
            WebDriver.Manage().Window.Maximize();


            return(WebDriver);
        }