【发布时间】: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