Thursday, May 30, 2013

Setting Firefox Profile To Download File without Asking



 Setting Firefox Profile  To Download File without Asking

Often when downloading files via web automation you encounter a scenario where you want the browser to silently accept the file that is response to an a request.  By setting these preferences in the browser setup, your file is downloaded to the specified path.  Same holds true by changing your settings via about:config.

download_path = '/tmp/download'

profile.set_preference('browser.download.dir', download_path)

profile.set_preference('browser.download.lastDir', download_path)

profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'application/pdf, application/vnd.fdf, application/x-msdos-program, application/x-unknown-application-octet-stream, application/vnd.ms-powerpoint, application/excel, application/vnd.ms-publisher, application/x-unknown-message-rfc822, application/vnd.ms-excel, application/msword, application/x-mspublisher, application/x-tar, application/zip, application/x-gzip,application/x-stuffit,application/vnd.ms-works, application/powerpoint, application/rtf, application/postscript, application/x-gtar, video/quicktime, video/x-msvideo, video/mpeg, audio/x-wav, audio/x-midi, audio/x-aiff,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
     

profile.set_preference('browser.download.folderList',2)
    
 profile.set_preference('browser.helperApps.alwaysAsk.force',False)

No comments:

Post a Comment