【发布时间】:2015-10-22 15:25:02
【问题描述】:
我尝试使用 Java 中的 Selenium WebDriver 从 Firefox 自动下载。 不幸的是,我找到了很多答案,但这在我的代码中很奇怪。
我试过了
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.dir", "D:\\");
profile.setPreference("browser.helperApps.neverAsk.openFile","application/msword, application/csv, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword, application/csv, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream");
但不可能工作! 我尝试下载的文件类型是 CSV Excel 文件。
在 Mozilla>Options>Application 中,任何自动化都是可见的,尽管我添加了 setPreference。
就在那之前,我刚刚添加了
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "XXX.XXX.XXX.XXX");
profile.setPreference("network.proxy.http_port", XXXX);
因为我的公司有代理,但这次在 Mozilla>选项>Internet 设置中,我添加的代理规则是可见的。
【问题讨论】:
标签: java firefox selenium selenium-webdriver download