browser.helperApps.neverAsk.saveToDisk preference

2019-06-05 23:32发布

问题:

I am using firefox-profile with below settings -

var q = require('q');
var FirefoxProfile = require('firefox-profile');

var firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.download.folderList", 2);
firefoxProfile.setPreference("browser.download.dir", process.cwd() +'/e2e/downloads/');
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-executable");

MIME-type of file is "application/x-executable". After adding all above details, it shows download pop up on firefox.

Environment:-

Ubuntu 14.04
Firefox 44
Protractor 3.2.2
Selenium-webdriver 2.53

回答1:

I am pretty sure it is just about specifying the correct mime-type. Apparently, just setting the application/x-executable not enough in this case.

The most reliable way to do that is to actually open firefox manually, download the file asking firefox to save the file automatically. Then, open Help - Troubleshooting Information, open Profile Folder, open mimeTypes.rdf file and locate the mime-types of the automatically downloaded files. You will have there something like:

<RDF:Description RDF:about="urn:mimetype:handler:x-executable"
               NC:alwaysAsk="false"
               NC:useSystemDefault="true">
   <NC:externalApplication RDF:resource="urn:mimetype:externalApplication:x-executable"/>
</RDF:Description> 

FYI, you can specify multiple mime-types in comma-separated string for the browser.helperApps.neverAsk.saveToDisk preference.