作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带有链接的网络应用程序。单击此链接时,它会打开弹出窗口,要求使用特定应用程序打开文件。
我编写了以下用于创建 firefox 配置文件的代码,它适用于其他文件扩展名,但不适用于 .xlsx 文件。
profile.setEnableNativeEvents(true);
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.dir", System.getProperty("user.dir")+"\\src\\com\\Download");
profile.setPreference("browser.download.downloadDir", System.getProperty("user.dir")+"\\src\\com\\Download");
profile.setPreference("browser.download.defaultFolder", System.getProperty("user.dir")+"\\src\\com\\Download");
profile.setPreference("browser.download.manager.closeWhenDone", true);
profile.setPreference("pdfjs.disabled", true);
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/xls, application/zip,text/csv,application/msword,application/excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/pdf," +
"application/vnd.ms-excel,application/msword,application/unknown,application/vnd.openxmlformats-officedocument.wordprocessingml.document");
最佳答案
这个偏好对我有用。
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
下表记录了处理 Office 2007 文档时可用的 HTTP MIME 类型:
外部 MIME 类型
关于java - 如何使用 webdriver 在 firefox 中处理下载 .xlsx 文件,其中弹出窗口默认为 'Open with' 单选按钮而不是 'Save file',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34271396/
我是一名优秀的程序员,十分优秀!