【发布时间】:2022-01-10 09:35:47
【问题描述】:
无法绕过“这种类型的文件会损害您的计算机”。
使用 Java 和 Chrome 驱动程序 97+。
试过了:
Map<String, Object> prefs = new HashMap<>();
prefs.put("download.default_directory", "C:\\Users\\Fedor\\Downloads");
prefs.put("download.prompt_for_download", false);
prefs.put("profile.default_content_settings.popups", 0);
prefs.put("safebrowsing.enabled", true);
prefs.put("download.extensions_to_open", "text/x-python");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments("start-maximized");
options.addArguments("--safebrowsing-disable-download-protection");
options.addArguments("--safebrowsing-disable-extension-blacklist");
driver = new ChromeDriver(options);
对于那些认为它是重复的人,以下链接对于当前驱动程序版本无用:
- How to hide the warning "This type of file can harm your computer" while downloading .xml file using Chrome Chromedriver 79 with Selenium Java
- How to disable 'This type of file can harm your computer' pop up
- Unable to download file using ChromeDriver
- ChromeOption '--safebrowsing-disable-download-protection' doesn't disables the download warning in Chrome version 67.x
- How to disable 'This type of file can harm your computer' pop up
- XML file download blocked in selenium chromedriver
- Download .xml file with selenium chrome driver
- How to use chrome webdriver in selenium to download files in python?
【问题讨论】:
标签: java selenium google-chrome selenium-webdriver selenium-chromedriver