Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable chrome download multiple files confirmation

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

like image 208
pedroaxl Avatar asked Apr 04 '13 17:04

pedroaxl


People also ask

How do I change download settings multiple files?

Open Google Chrome and click Customize / Control Google Chrome > Settings. Click on + Show advanced settings. Go to Privacy > Content Settings. In the Automatic Downloads section, select Allow all sites to download multiple files automatically.

How do I keep Chrome from downloading unconfirmed?

Press Ctrl + J or click the Options dropdown menu and select Downloads to open the download manager. In the list of downloads, find the failed item and click Resume. If everything goes to plan, your download will resume from where it got interrupted.


1 Answers

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 );

like image 150
dev-random Avatar answered Oct 09 '22 09:10

dev-random