2
我想用这个selenium.For处理文件下载Firefox配置文件下载一个文件,我用下面的代码来设置Firefox的配置:无法通过设定使用硒的webdriver
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.dir", downloadPath);
profile.setPreference("browser.helperApps.neverAsk.openFile",
"text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
"text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml");
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
profile.setPreference("browser.download.manager.focusWhenStarting", false);
profile.setPreference("browser.download.manager.useWindow", false);
profile.setPreference("browser.download.manager.showAlertOnComplete", false);
profile.setPreference("browser.download.manager.closeWhenDone", false);
通过我的UI,我正在下载2个文件。 第一个文件,我能够成功下载其弹出来是这样的:
我不确定为什么我的Firefox配置文件设置无法处理第二个文件的下载。
请提出建议。任何帮助将不胜感激!
似乎第一个文件是格式微软office的Excel 97-2003工作表和第二个是微软办公ExcelWorksheet (较新的版本),所以它无法找到开放的应用程序。试图通过点击保存然后尝试打开来保存它。 – Naruto
@Naruto我相信这真的不容易做(甚至不可能)(点击保存) - 只使用硒。 – drets
是否需要使用硒?或者我可以建议另一种方式? –