AutomationDrivers.SeleniumDriver.SeleniumDriver.GenerateBrowserSpecificDriver C# (CSharp) Method

GenerateBrowserSpecificDriver() private static method

private static GenerateBrowserSpecificDriver ( Browser browser, System.TimeSpan commandTimeout ) : Func
browser Browser
commandTimeout System.TimeSpan
return Func
        private static Func<IWebDriver> GenerateBrowserSpecificDriver(Browser browser, TimeSpan commandTimeout)
        {
            string driverPath = string.Empty;
            switch (browser)
            {
                case Browser.InternetExplorer:
                    driverPath = EmbeddedResources.UnpackFromAssembly("IEDriverServer32.exe", "IEDriverServer.exe", Assembly.GetAssembly(typeof(SeleniumDriver)));
                    return new Func<IWebDriver>(() => new Wrappers.IEDriverWrapper(Path.GetDirectoryName(driverPath), commandTimeout));
                case Browser.InternetExplorer64:
                    driverPath = EmbeddedResources.UnpackFromAssembly("IEDriverServer64.exe", "IEDriverServer.exe", Assembly.GetAssembly(typeof(SeleniumDriver)));
                    return new Func<IWebDriver>(() => new Wrappers.IEDriverWrapper(Path.GetDirectoryName(driverPath), commandTimeout));
                case Browser.Firefox:
                    return new Func<IWebDriver>(() =>
                    {
                        var firefoxBinary = new OpenQA.Selenium.Firefox.FirefoxBinary();
                        return new OpenQA.Selenium.Firefox.FirefoxDriver(firefoxBinary, new OpenQA.Selenium.Firefox.FirefoxProfile
                        {
                            EnableNativeEvents = false,
                            AcceptUntrustedCertificates = true,
                            AlwaysLoadNoFocusLibrary = true
                        }, commandTimeout);
                    });
                case Browser.Chrome:
                    driverPath = EmbeddedResources.UnpackFromAssembly("chromedriver.exe", Assembly.GetAssembly(typeof(SeleniumDriver)));

                    var chromeService = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverPath));
                    chromeService.SuppressInitialDiagnosticInformation = true;

                    var chromeOptions = new ChromeOptions();
                    chromeOptions.AddArgument("--log-level=3");

                    return new Func<IWebDriver>(() => new OpenQA.Selenium.Chrome.ChromeDriver(chromeService, chromeOptions, commandTimeout));
                case Browser.PhantomJs:
                    driverPath = EmbeddedResources.UnpackFromAssembly("phantomjs.exe", Assembly.GetAssembly(typeof(SeleniumDriver)));

                    var phantomOptions = new OpenQA.Selenium.PhantomJS.PhantomJSOptions();
                    return new Func<IWebDriver>(() => new OpenQA.Selenium.PhantomJS.PhantomJSDriver(Path.GetDirectoryName(driverPath), phantomOptions, commandTimeout));
            }

            throw new NotImplementedException("Selected browser " + browser.ToString() + " is not supported yet.");
        }

Same methods

SeleniumDriver::GenerateBrowserSpecificDriver ( Browser browser ) : Func