Exemple #1
0
        /// <summary>
        /// Launch browser with parameter of visible.
        /// </summary>
        public static IWebDriver Launch(bool visible)
        {
            /* Hide CMD */
            var chromeDriverService = ChromeDriverService.CreateDefaultService();

            chromeDriverService.HideCommandPromptWindow = true;
            /* Hide Browser */
            ChromeOptions option = new ChromeOptions();

            option.AddArgument("--headless");
            /* Start browser with 10 timeout */
            IWebDriver Chrome;

            if (visible)
            {
                Chrome = new ChromeDriver();
            }
            else
            {
                Chrome = new ChromeDriver(chromeDriverService, option);
            }
            Chrome.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10);
            return(Chrome);
        }