0

I am trying to set the preferences on my Firefox browser to never ask to save to disk when downloading a .eml file.

   def setUp(self):
    profile = webdriver.FirefoxProfile()
    profile.set_preference('browser.download.folderList', 2)
    profile.set_preference('browser.download.manager.showWhenStarting', False)
    profile.set_preference('browser.download.dir', os.path.join(os.path.expanduser("~"), "Downloads\\"))
    profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv,message/rfc822')
    self.driver = webdriver.Firefox(profile)
    self.base_url = baseurl
    self.verificationErrors = []
    self.accept_next_alert = True
    self.driver.implicitly_wait(3)   

With this code I am able to download a .csv without having the saveToDisk pop-up appear in Firefox, however this will not work with .eml despite having the 'message/rfc822' MIME-type set.

Can any help explain if I am using an incorrect MIME-type to set preferences for .emls as well? Or is there something else I need to do in order to download .eml's without having any pop-ups be displayed?

Golshy
  • 63
  • 2
  • 13

1 Answers1

0

Seems that you have right content type. Still you can verify the content type and then lets see from there

from mimetypes import MimeTypes
import urllib 
mime = MimeTypes()
url = urllib.pathname2url('path\to\filesample.eml')
mime_type = mime.guess_type(url)
print mime_type
Shijo
  • 9,313
  • 3
  • 19
  • 31
  • Hi, Thanks for the response. After running your above code in console with the .eml the return I get is: ('message/rfc822', None) Seems to be the same Mime-type I am using. – Golshy Jan 24 '17 at 16:57
  • that's interesting ... i too dont see a problem .. may be do you want to find the content type from server itself.. that could be different – Shijo Jan 24 '17 at 17:00