I am trying to automate the download of eml files when exporting protonmail mails using Selenium C# implementation. According to MimeMapping.GetMimeMapping the MIME type is message/rfc822. However, despite setting the following preference, the popup to download the file keeps appearing. Any idea on how to avoid the popup in this particular case?
opcion.SetPreference("browser.helperApps.neverAsk.saveToDisk", "message/rfc822");
FirefoxOptions opcion = new FirefoxOptions();
opcion.SetPreference("browser.download.folderList", 2);
opcion.SetPreference("browser.download.manager.showWhenStarting", false);
opcion.SetPreference("browser.download.dir", ruta);
opcion.SetPreference("browser.download.useDownloadDir", true);
opcion.SetPreference("browser.download.viewableInternally.enabledTypes", "");
opcion.SetPreference("browser.helperApps.alwaysAsk.force", false);
opcion.SetPreference("browser.helperApps.neverAsk.saveToDisk", "Unknown/Extension missing, text/javascript, application/x-javascript,application/javascript, multipart/x-gzip, application/x-gzip, application/x-gzip, text/css, text/plain, application/x-binary, message/partial, multipart/form-data, multipart/byteranges,RFC-822 data,text/plain,application/pdf,application/eml,gzip,application/javascript,gzip,image/gif,application/msword, application/csv, application/ris, text/csv, image/png, application/pdf, text/html, text/plain, application/Zip, application/x-Zip, application/x-Zip-compressed, application/download, application/octet-stream,application/protonmail.ch, application/protonmail.com,image/pjpeg,application/vnd.semf,application/vnd.semd,application/vnd.sema,message/rfc822,multipart/x-gzip,multipart/eml,application/x-gzip,application/octet-stream,Thunderbird Document,wget url\\sample.eml,application/xml,text/plain,text/xml,image/jpeg,text/eml,test/sample/message.eml,application/blob,text/plain,multipart/mixed,application/pdf,text/plain,application/text,text/xml,application/xml,application/json,application/eml,blob://");
CodePudding user response:
Finally the way to go in this case was setting opcion.SetPreference("browser.download.improvements_to_download_panel", true);
The final code was:
FirefoxOptions opcion = new FirefoxOptions();
opcion.SetPreference("browser.download.folderList", 2);
opcion.SetPreference("browser.download.manager.showWhenStarting", false);
opcion.SetPreference("browser.download.dir", ruta);
opcion.SetPreference("browser.download.improvements_to_download_panel", true);
opcion.SetPreference("browser.download.manager.showWhenStarting", false);
opcion.SetPreference("browser.download.useDownloadDir", true);
opcion.SetPreference("browser.download.viewableInternally.enabledTypes", "");
opcion.SetPreference("browser.helperApps.alwaysAsk.force", false);
opcion.SetPreference("browser.helperApps.neverAsk.saveToDisk", "Thunderbird Document, blob: ,application/vnd.protonmail.v1 json, application/json, json, media-src,blob,message, message/rfc6532,message/partial, message/external-body, message/rfc822, application/octet-stream, text/plain, application/download, application/octet-stream, binary/octet-stream, application/binary, application/x-unknown, texto/html");
opcion.SetPreference("pdfjs.disabled", true);
return opcion;