Disable chrome download multiple files confirmation

pedroaxl picture pedroaxl · Apr 4, 2013 · Viewed 15.4k times · Source

I developed a crawler with ruby watir-webdriver that downloads some files from a page. My problem is that when I click to download the second file, Chrome opens a bar in the top asking for confirmation that I am downloading multiple files from this website.

Once this is used by webdriver, I cannot confirm the download. Is there anyway to avoid this confirmation? I am thinking if is there any configuration to avoid it or if is there an extension to do this or even if I can click on the confirmation with webdriver.

thanks

Answer

dev-random picture dev-random · Apr 24, 2016

I'm using Chrome 49 and none of the other solutions worked for me. After some research I found a working solution:

ChromeDriver createChromeDriverWithDownloadFolder(String folder) {
    Map<String, Object> chromePrefs = new HashMap<String, Object>();
    chromePrefs.put("profile.default_content_settings.popups", 0);
    chromePrefs.put("download.default_directory", folder);
    chromePrefs.put("profile.content_settings.exceptions.automatic_downloads.*.setting", 1 );
    chromePrefs.put("download.prompt_for_download", false);

    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("prefs", chromePrefs);
    DesiredCapabilities cap = DesiredCapabilities.chrome();
    cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    cap.setCapability(ChromeOptions.CAPABILITY, options);
    return new ChromeDriver(cap);
}

It seems as if these settings are constantly changing. Therefore, here's how I found the right solution for my setup:

  1. Open Chrome and go to chrome://version/ to find the path of your profile
  2. In Default/Preferences is a json file called Preferences. Open it and search for automatic_downloads. In my case the interesting part of the file looked like this:

    ..."profile": { "avatar_bubble_tutorial_shown": 1, "avatar_index": 0, "content_settings": { "clear_on_exit_migrated": true, "exceptions": { "app_banner": {}, "auto_select_certificate": {}, "automatic_downloads": { "[.]localhost:63342,": { "setting": 1 },...

  3. From that I could derive that the right setting would be chromePrefs.put("profile.content_settings.exceptions.automatic_downloads.*.setting", 1 );