Ejemplo n.º 1
0
        private static ChromeDriver BuildChromeDriver()
        {
            var options = new ChromeOptionsWithPrefs();

            options.AddArguments("--start-maximized");
            options.AddArgument("--enable-automation");
            options.AddArgument("--no-sandbox");
            options.AddArgument("--disable-infobars");
            options.AddArgument("--disable-dev-shm-usage");
            options.AddArgument("--disable-browser-side-navigation");
            options.AddArgument("--disable-gpu");

            if (Constants.Headless)
            {
                options.AddArguments("--headless");
            }

            options.prefs = new Dictionary <string, object>
            {
                { "profile.default_content_settings.popups", 0 },
                { "download.prompt_for_download", "false" }
            };

            return(new ChromeDriver(ChromeDriverService.CreateDefaultService(), options, TimeSpan.FromSeconds(Constants.NavigationTimeout)));
        }
        public void demo1()
        {
            var options = new ChromeOptionsWithPrefs();

            options.prefs = new Dictionary <string, object>
            {
                { "download.default_directory", @"c:\download temp\" }
            };
            RemoteWebDriver driver = new ChromeDriver(@"d:\selenium dlls\", options);
        }