Example #1
0
        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.");
            }
        }
Example #2
0
        public void Uhd4KBrowserIsOfRequestedSize()
        {
            Driver = StaticWebDriverFactory.GetLocalWebDriver(StaticDriverOptionsFactory.GetFirefoxOptions(true), WindowSize.UHD4K);
            Size size = Driver.Manage().Window.Size;

            size.ShouldSatisfyAllConditions
            (
                () => size.Height.ShouldBe(2160),
                () => size.Width.ShouldBe(3840)
            );
        }
Example #3
0
        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.");
            }
        }
Example #4
0
        //public static IWebDriver GetLocalWebDriver(ChromeOptions options, WindowSize windowSize = WindowSize.HD)
        //{
        //    IWebDriver driver = new ChromeDriver(DriverPath, options);
        //    return SetWindowSize(driver, windowSize);
        //}

        public static IWebDriver GetLocalWebDriver(FirefoxOptions options, WindowSize windowSize = WindowSize.HD)
        {
            //IWebDriver driver = new FirefoxDriver(DriverPath, options);
            //return SetWindowSize(driver, windowSize);
            return(GetLocalWebDriver <FirefoxDriver, FirefoxOptions>(StaticDriverOptionsFactory.GetFirefoxOptions(false)));
        }
Example #5
0
        public void HdBrowserIsOfRequestedSize()
        {
            //Driver = StaticWebDriverFactory.GetLocalWebDriver(StaticDriverOptionsFactory.GetFirefoxOptions(true), WindowSize.HD);
            Driver = StaticWebDriverFactory.GetLocalWebDriver <FirefoxDriver, FirefoxOptions>(StaticDriverOptionsFactory.GetFirefoxOptions(true));

            Size size = Driver.Manage().Window.Size;

            size.ShouldSatisfyAllConditions
            (
                () => size.Width.ShouldBe(1366),
                () => size.Height.ShouldBe(768)
            );
        }