【问题标题】:Download multiple files - Selenium/Chrome下载多个文件 - Selenium/Chrome
【发布时间】:2017-11-14 15:27:29
【问题描述】:

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

localhost:8444 想要下载多个文件。阻止/允许。

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

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

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

  • 铬 62
  • Chromedriver 2.32
  • 硒 3.6

【问题讨论】:

  • 它适用于 "profile.content_settings.exceptions.automatic_downloads.*.setting": 1 与 Chrome 62 和 chromedriver 2.33。更新您的驱动程序并确保您正确设置了首选项。
  • @FlorentB.Wow,你是对的。在本地运行 Selenium 时,我确实错误地设置了 Chrome 配置文件。有趣的是,我以前从未注意到这一点。如果您想发表评论作为答案,我会很乐意接受。谢谢!

标签: google-chrome selenium selenium-chromedriver


【解决方案1】:

我也遇到了同样的问题。在@FlorentB 提到的更新之后。它的工作正常 铬 66 铬驱动程序 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); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    • 2023-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-10
    • 1970-01-01
    相关资源
    最近更新 更多