Chromium/Chrome headless - file download not working?

后端 未结 7 1095
遥遥无期
遥遥无期 2020-12-03 05:21

I downloaded the latest version of chromium, to test out the headless feature.

When I run (as root, because I\'m still testing things):

./chrome --no         


        
相关标签:
7条回答
  • 2020-12-03 06:08

    The following code works in C# using ChromeDriver 2.46

        private ChromeDriver GetDriver()
        {
            var options = new ChromeOptions();
    
            options.AddArguments("headless");
            options.AddUserProfilePreference("download.prompt_for_download", "false");
            options.AddUserProfilePreference("download.directory_upgrade", "true");
            options.AddUserProfilePreference("download.prompt_for_download", "false");
            options.AddUserProfilePreference("safebrowsing.enabled", "false");
            options.AddUserProfilePreference("safebrowsing.disable_download_protection", "true");
    
            options.AddArguments("--disable-web-security");
    
            var curr = Directory.GetCurrentDirectory();
            options.AddUserProfilePreference("download.default_directory", curr);
    
            var driver = new ChromeDriver(options);
            Log.Info($"Started Chrome Driver with options: {options.ToJsonNoTypes()}");
    
            var param = new Dictionary<string, object>();
            param.Add("behavior", "allow");
            param.Add("downloadPath", curr);
            driver.ExecuteChromeCommand("Page.setDownloadBehavior", param);
    
            return driver;
        }
    
    0 讨论(0)
提交回复
热议问题