public void RemoteWebDriverFactoryWorks(
     PlatformType platformType,
     Browser browser,
     BrowserVisibility browserVisibility = BrowserVisibility.OnScreen)
 {
     Driver = RemoteWebDriverFactory
              .GetWebDriver(browser, platformType, WindowSize.Fhd, browserVisibility == BrowserVisibility.Headless);
     Assertions.AssertThatPageCanBeLoaded(Driver);
     Driver.IsRunningHeadless().Should()
     .Be(browserVisibility == BrowserVisibility.Headless,
         $"{browserVisibility.ToString()} was requested");
 }
        /// <summary>
        /// Return a WebDriver instance of the given configuration.
        /// </summary>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public IWebDriver GetWebDriver(IWebDriverConfiguration configuration)
        {
            Logger.Info($"WebDriver requested using {configuration}");
            IWebDriver driver = configuration.IsLocal ?
                                LocalWebDriverFactory.GetWebDriver(configuration) :
                                RemoteWebDriverFactory.GetWebDriver(configuration);

            if (IsDebugEnabled)
            {
                IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                Logger.Debug($"{driver} successfully launched. Agent String: {js.ExecuteScript("return navigator.userAgent;")}");
            }

            return(driver);
        }
        /// <summary>
        /// Return a WebDriver instance of the given configuration.
        /// </summary>
        /// <param name="browser"></param>
        /// <param name="windowSize"></param>
        /// <param name="isLocal"></param>
        /// <param name="platformType"></param>
        /// <param name="headless"></param>
        /// <param name="windowCustomSize"></param>
        /// <returns></returns>
        public IWebDriver GetWebDriver(Browser browser, WindowSize windowSize = WindowSize.Hd, bool isLocal = true,
                                       PlatformType platformType = PlatformType.Any, bool headless          = false, Size windowCustomSize = new Size())
        {
            string configurationDescription = new StringBuilder()
                                              .Append($"Browser: {browser.ToString()}")
                                              .Append(headless ? "headless" : "on screen")
                                              .Append($"WindowSize enum: {windowSize.ToString()}, ")
                                              .Append($"{((windowSize == WindowSize.Custom || windowSize == WindowSize.Defined) ? $"Size: {windowCustomSize.Width} x {windowCustomSize.Height}, " : string.Empty)}")
                                              .Append(isLocal ? "running locally)" : $"running remotely on {RemoteWebDriverFactory.GridUri} on platform: {platformType}.)")
                                              .ToString();

            Logger.Info($"WebDriver requested using parameters: {configurationDescription}");
            IWebDriver driver = isLocal ?
                                LocalWebDriverFactory.GetWebDriver(browser, windowSize, headless, windowCustomSize) :
                                RemoteWebDriverFactory.GetWebDriver(browser, platformType, windowSize, headless, windowCustomSize);

            if (IsDebugEnabled)
            {
                IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                Logger.Debug($"{driver} successfully launched. Agent String: {js.ExecuteScript("return navigator.userAgent;")}");
            }

            return(driver);
        }