google-chrome - 下载多个文件 - Selenium/Chrome

标签 google-chrome selenium selenium-chromedriver

阻止通过 Selenium 运行的当前版本的 Chrome 显示以下对话框的正确方法是什么:

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

被测网站什么时候触发两个文件下载?这两个文件都是使用 URL.createObjectURL()Blob 和动态附加的 anchor 在浏览器中生成的。

我确实尝试了其他答案中描述的几种配置文件设置,但它们似乎不再适用于最新的 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

我尝试了以上所有方法,分别进行了某些排列。

  • Chrome 62
  • Chrome 驱动程序 2.32
  • Selenium 3.6

最佳答案

我也遇到了同样的问题。如@FlorentB 所述更新后。它工作正常 Chrome 66 Chrome 驱动程序 2.36 网络驱动程序 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); 

关于google-chrome - 下载多个文件 - Selenium/Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47289486/

相关文章:

javascript - 在 'background.js' 到 'contentScript.js' 之间传递的简单消息

javascript - Chrome Profiler Javascript 内存泄漏

selenium - 指定了主机 header 或原始 header ,但对于 selenium 网格来说不是 localhost

javascript - 如何在 Selenium C# 中切换 Chrome 上的标签页?

Selenium docker : Firefox crashes when trying to open fancybox popup

android - 使用机器人框架脚本和 chromedriver 在 Android 设备中打开 Chrome 浏览器?

google-chrome - listbox.js 或 pickers.js 未从 sv-se 加载,错误 404

google-chrome - ChromeDriver 在 Jenkins Selenium 作业上不断崩溃 : "WebDriverError: Chrome failed to start: crashed"

python - 开始玩 selenium,通过 css 方法获取问题

php - 如何增加 facebook php web-driver 中的 curl 超时