browser.helperApps.neverAsk.saveToDisk preference isn't working with protractor for firefox

帅比萌擦擦* 提交于 2019-12-23 04:19:12

问题


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.



来源:https://stackoverflow.com/questions/38247075/browser-helperapps-neverask-savetodisk-preference-isnt-working-with-protractor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!