Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download multiple files - Selenium/Chrome

What is the correct way of preventing current version of Chrome, running via Selenium, from showing the following dialog:

localhost:8444 wants to download multiple files. Block / Allow.

when the website under test triggers two file downloads? Both files are generated in the browser using URL.createObjectURL(), Blob and dynamically appended anchor.

I did try several profile settings described in other answers, but they seem to no longer work with the most recent Chrome 62:

"download.directory_upgrade" "true"
"safebrowsing.enabled" "true"
"profile.content_settings.exceptions.automatic_downloads.https://localhost:8444,*.setting" 1
"profile.content_settings.exceptions.automatic_downloads.https://localhost:8444,*.last_modified" 0
"profile.content_settings.exceptions.automatic_downloads.*.last_modified" 0
"profile.content_settings.exceptions.automatic_downloads.*.setting" 1
"profile.default_content_setting_values.automatic_downloads" 1
"profile.default_content_setting_values.automatic_downloads" 2

I tried all of the above, individually and in certain permutations.

  • Chrome 62
  • Chromedriver 2.32
  • Selenium 3.6
like image 966
kamituel Avatar asked Apr 30 '26 19:04

kamituel


1 Answers

I was also facing the same problem. After updating as mentioned by @FlorentB. its working fine for chrome 66 chrome driver 2.36 webdriver 3.8

 DesiredCapabilities capabilities = DesiredCapabilities.chrome();
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.content_settings.exceptions.automatic_downloads.*.setting", 1);
capabilities.setCapability("chrome.prefs", chromePrefs); 
like image 58
jchaturvedi Avatar answered May 02 '26 23:05

jchaturvedi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!