尽管将 safebrowsing.enabled 设置为 true/false,但警告 ...这种类型的文件可能会损害您的计算机... 仍在浏览器中显示.如何隐藏这些信息?
启用使用 Chrome 下载文件/
Despite setting safebrowsing.enabled to true / false, the warning ...This type of file can harm your computer... is still being displayed in browser. How to hide this information?
To enable downloading of file using Chrome/ChromeDriver hiding the warning This type of file can harm your computer you need to:
download.default_directorydownload.prompt_for_downloaddownload.extensions_to_opensafebrowsing.enabled--safebrowsing-disable-download-protectionsafebrowsing-disable-extension-blacklistTo demonstrate downloading using selenium-chromedriver, and google-chrome through java I have clicked on the first Download link in the webpage http://www.landxmlproject.org/file-cabinet and your effective solution will be:
Code Block:
System.setProperty("webdriver.chrome.driver", "C:\Utility\BrowserDrivers\chromedriver.exe");
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("download.default_directory", "C:/Utility/Downloads/");
prefs.put("download.prompt_for_download", false);
prefs.put("download.extensions_to_open", "application/xml");
prefs.put("safebrowsing.enabled", true);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments("start-maximized");
options.addArguments("--safebrowsing-disable-download-protection");
options.addArguments("safebrowsing-disable-extension-blacklist");
WebDriver driver = new ChromeDriver(options);
driver.get("http://www.landxmlproject.org/file-cabinet");
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='MntnRoad.xml']//following::span[1]//a[text()='Download']"))).click();
Browser Snapshot:
这篇关于如何隐藏警告“此类文件可能会损害您的计算机"使用带有 Selenium Java 的 Chrome Chromedriver 79 下载 .xml 文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何检测 32 位 int 上的整数溢出?How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
return 语句之前的局部变量,这有关系吗?Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
如何将整数转换为整数?How to convert Integer to int?(如何将整数转换为整数?)
如何在给定范围内创建一个随机打乱数字的 intHow do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
java的行为不一致==Inconsistent behavior on java#39;s ==(java的行为不一致==)
为什么 Java 能够将 0xff000000 存储为 int?Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)