0

フレームワーク Vaadin テスト ベンチと Selenium ライブラリの使用中に問題が発生しました。私のテストでは、Mozilla Firefox ブラウザー 31.0 バージョンに、.iso ファイルをダウンロードしようとしたときにダウンロード マネージャー ダイアログを開かないように指示する必要があります。設定したパスでダウンロードが自動的に開始されるようにします。私の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-type にあると思いましたが、すべてのフォーラムで、.iso ファイルの mime-type が application/iso-image または application/octet-stream であると読みましたが、機能しません。

答えてくれてありがとう。

4

1 に答える 1

0

Linux で次の curl コマンドを使用して、MIME タイプを特定できます。

curl -I "http://ftp.uni-erlangen.de/mirrors/ubuntu-releases/16.04/ubuntu-16.04.1-desktop-amd64.iso" | grep "Content-Type"

返す

Content-Type: application/x-iso9660-image
于 2016-08-30T15:14:10.577 に答える