예제 #1
0
        public static IWebDriver GetLocalWebDriver(Browser browser, bool headless = false)
        {
            if (headless && !(browser == Browser.Chrome || browser == Browser.Firefox))
            {
                throw new ArgumentException($"Headless mode is not currently supported for {browser}.");
            }
            switch (browser)
            {
            case Browser.Firefox:
                return(GetLocalWebDriver(StaticDriverOptionsFactory.GetFirefoxOptions(headless)));

            case Browser.Chrome:
                return(GetLocalWebDriver(StaticDriverOptionsFactory.GetChromeOptions(headless)));

            case Browser.IE:
                return(GetLocalWebDriver(StaticDriverOptionsFactory.GetInternetExplorerOptions()));

            case Browser.Edge:
                return(GetLocalWebDriver(StaticDriverOptionsFactory.GetEdgeOptions()));

            case Browser.Safari:
                return(GetLocalWebDriver(StaticDriverOptionsFactory.GetSafariOptions()));

            default:
                throw new PlatformNotSupportedException($"{browser} is not currently supported.");
            }
        }
예제 #2
0
        public static IWebDriver GetRemoteWebDriver(
            Browser browser,
            Uri gridUrl,
            PlatformType platformType = PlatformType.Any,
            string proxy = null)
        {
            switch (browser)
            {
            case Browser.Firefox:
                return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetFirefoxOptions(platformType, proxy), gridUrl));

            case Browser.Chrome:
                return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetChromeOptions(platformType, proxy), gridUrl));

            case Browser.IE:
                return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetInternetExplorerOptions(platformType), gridUrl));

            case Browser.Edge:
                return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetEdgeOptions(platformType), gridUrl));

            case Browser.Safari:
                return(GetRemoteWebDriver(StaticDriverOptionsFactory.GetSafariOptions(platformType), gridUrl));

            default:
                throw new PlatformNotSupportedException($"{browser} is not currently supported.");
            }
        }