【发布时间】:2013-01-17 12:19:51
【问题描述】:
enter code here我试图在保存任何类型的文件时隐藏询问文件对话框。
我们知道我们需要在“browser.helperApps.neverAsk.saveToDisk”中设置我们需要的所有文件的mime类型。
所以就我而言,它看起来像:
FirefoxProfile.SetPreference("browser.download.folderList", 2);
FirefoxProfile.SetPreference("browser.download.dir", "d:\\test");
FirefoxProfile.SetPreference("browser.helperApps.alwaysAsk.force", false); FirefoxProfile.SetPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
FirefoxProfile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/excel");
我正在使用http://filext.com/file-extension/XLS 的 mime 类型,并在“zip”、“jpg”、“docx”、“xlsx”方面取得了成功,但它不适用于“xls”、“csv”。当我尝试下载“xls”或“csv”Firefox 时询问保存位置。
有什么帮助吗?
【问题讨论】:
-
您是否尝试过将 mime 类型(应用程序/excel)视为已接受的答案(或其他任何内容),如这篇文章中:stackoverflow.com/questions/974079/…
-
我确实做到了。此外,我查看了注册表 HKCR/.xls 和 HKCR/.csv - application/vnd.ms-excel。所以我使用了这种 mime 类型。而且它不起作用。
-
我通过 fiddler 查看了它并得到了“Content-Type: application/download”。这种 mime 类型也不起作用。
-
对不起,这里不能再帮忙了。我用我知道的每一种 mime 类型都试过了,甚至查找了 M$ 类型(filext.com/faq/office_mime_types.php),但没有运气。我试图直接在Firefox的about:config页面中设置该值,但似乎没有考虑到它。您可以尝试的是:创建一个新的 Firefox 配置文件,进行必要的更改,找到配置文件,然后直接加载此配置文件进行测试。这应该可以解决问题。
标签: c# firefox selenium webdriver selenium-webdriver