【发布时间】:2016-09-16 02:35:12
【问题描述】:
我正在使用带有 selenium 的 chromedriver 从应用程序下载文件。但是在点击应用程序中的下载按钮时,它给出的错误是“Failed-Download error.”
Chrome 驱动程序版本:2.21 硒版本:2.53.0
初始化chrome驱动和更改下载位置的代码:
String newPath = "D:\\Backup" + File.separator + "Database ";
new File(newPath).mkdir();
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", newPath);
chromePrefs.put("safebrowsing.enabled", "true");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
options.addArguments("--test-type");
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability("disable-popup-blocking", true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
System.setProperty("webdriver.chrome.driver", CHROME_DRIVER_PATH);
driver = new ChromeDriver(cap);
// Maximize the driver window
driver.manage().window().maximize();
错误是:
有人可以帮我解决这个问题吗? 我可以手动从 Chrome 下载文件。
【问题讨论】:
标签: java selenium selenium-chromedriver