阻止通过 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/