public static IWebDriver GetRemoteWebDriver(BrowserTypes browser, Uri gridUrl, PlatformType platformType = PlatformType.Any) { switch (browser) { case BrowserTypes.Firefox: return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetFirefoxOptions(platformType), gridUrl)); case BrowserTypes.Chrome: return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetChromeOptions(platformType), gridUrl)); case BrowserTypes.InternetExplorer: return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetInternetExplorerOptions(platformType), gridUrl)); case BrowserTypes.Edge: return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetEdgeOptions(platformType), gridUrl)); case BrowserTypes.Safari: return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetSafariOptions(platformType), gridUrl)); default: throw new PlatformNotSupportedException($"{browser} is not currently supported."); } }
public static IWebDriver GetLocalWebDriver(BrowserTypes browser, bool headless = false) { if (headless && !(browser == BrowserTypes.Chrome || browser == BrowserTypes.Firefox)) { throw new ArgumentException($"Headless mode is not currently supported for {browser}."); } switch (browser) { case BrowserTypes.Firefox: return(GetLocalWebDriver <FirefoxDriver, FirefoxOptions>(StaticDriverOptionsFactory.GetFirefoxOptions(headless))); case BrowserTypes.Chrome: return(GetLocalWebDriver <ChromeDriver, ChromeOptions>(StaticDriverOptionsFactory.GetChromeOptions(headless))); case BrowserTypes.InternetExplorer: return(GetLocalWebDriver <InternetExplorerDriver, InternetExplorerOptions>(StaticDriverOptionsFactory.GetInternetExplorerOptions())); case BrowserTypes.Edge: return(GetLocalWebDriver <EdgeDriver, EdgeOptions>(StaticDriverOptionsFactory.GetEdgeOptions())); case BrowserTypes.Safari: return(GetLocalWebDriver <SafariDriver, SafariOptions>(StaticDriverOptionsFactory.GetSafariOptions())); default: throw new PlatformNotSupportedException($"{browser} is not currently supported."); } }