0
我试图设置所有可能的首选项,以避免打开并保存文件对话框,同时使用硒下载文件。首选项设置为避免在Firefox下载对话框不工作PDF
它正在为文本文件,但不适用于PDF文件
下面是喜好设置:
String downloadPath = <some random path>;
String mimetypes = "application/vnd.pdf,application/vnd.adobe.xfdf,text/csv,application/x-msexcel,application/excel,application/pdf,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml";
String url = "http://only-testing-blog.blogspot.in/2014/05/login.html";
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.panel.shown", false);
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", mimetypes);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", mimetypes);
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);
FirefoxDriver driver = new FirefoxDriver(profile);
driver.get(url);
driver.findElement(By.xpath("//a[contains(.,'Download PDF File')]")).click();
正在使用火狐与2.53.0硒版本
请帮助我使它适用于PDF,Excel和Word文件
谢谢!
PDF文件正在发生什么? –
打开或保存文件对话框正在显示PDF,Excel和工作文件 –
您可以缩小您的问题到PDF,Excel和Word中的任何一种文件类型吗? – DebanjanB