如何将 Mozilla Firefox 设置为不打开带有 .iso 文件的管理器下载?

How to set Mozilla Firefox to doesn't open manager download with .iso file?

我在使用框架 Vaadin 测试平台和 Selenium 库时遇到问题。 对于我的测试,当我尝试下载 .iso 文件时,我需要告诉 Mozilla Firefox 浏览器 31.0 版本不要打开下载管理器对话框。 我希望下载在我设置的路径中自行开始。 我的 JAVA 代码示例,我在 apache tomcat 1.8 上使用 jdk 1.8,我的 OS 是 Windows 8:

public static RemoteWebDriver getFirefoxDriver(String pathDownloadFile) {
        final FirefoxProfile firefoxProfile = new FirefoxProfile();
        final DesiredCapabilities capability = new DesiredCapabilities();
        firefoxProfile.setPreference("browser.download.dir", pathDownloadFile);
        firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
        firefoxProfile.setPreference("browser.download.folderList", 2);
        firefoxProfile.setPreference("browser.download.defaultFolder", pathDownloadFile);
        firefoxProfile.setPreference("pdfjs.disabled", true);
        firefoxProfile.setPreference("plugin.scan.plid.all", false);
        firefoxProfile.setPreference("plugin.scan.Acrobat", "99.0");
        firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
                "application/pdf,application/octet-stream,application/xml,text/csv,application/zip,application/vnd.pdf,"
                        + "application/x-pdf,application/pkcs7-mime,application/x-pkcs7-mime,application/pkcs7-signature,text/plain,"
                        + "application/iso-image");
        firefoxProfile.setPreference("browser.helperApps.alwaysAsk.force", false);
        firefoxProfile.setEnableNativeEvents(false);
        capability.setBrowserName("firefox");
        capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
       WebDriver driver = new RemoteWebDriver(testingbotdotcom, capability);
return driver;

    }

这是 firefox 配置文件的设置。我认为问题出在 mime 类型上,但在每个论坛上我都读到 .iso 文件的 mime 类型是 application/iso-image 或 application/octet-stream 但它不起作用。

感谢大家的回答。

您可以在 linux

上使用以下 curl 命令确定 mimetype
curl -I "http://ftp.uni-erlangen.de/mirrors/ubuntu-releases/16.04/ubuntu-16.04.1-desktop-amd64.iso" | grep "Content-Type"

哪个returns

Content-Type: application/x-iso9660-image