Chase Raab Chase Raab - 10 months ago 52
Python Question

Set Firefox Preferences with Splinter

I am trying to automate a download using splinter that prompts a dialog box when initiated. To get around this, I want to set Firefox preferences to not open the box when downloading a pdf. I followed this github guide: which appeared to address my concern. My issue now is I can't get it to work. I'm not sure where the issue is as the the script runs, but it doesn't seem to take the preferences into account.

Here is my code:

from splinter import Browser
prof = {}
prof[''] = 'false'
prof['browser.helperApps.alwaysAsk.force'] = 'false'
prof[''] = 'C:\Users\craab\Desktop\Notes\Confluence_Backup'
prof[''] = 2
prof['browser.helperApps.neverAsk.saveToDisk'] = 'application/pdf'
prof[''] = 'false'
prof['browser.helperApps.useWindow'] = 'false'
prof['browser.helperApps.showAlertonComplete'] = 'false'
prof['browser.helperApps.alertOnEXEOpen'] = 'false'
prof['']= 'false'
browser = Browser('firefox',profile_preferences=prof)
browser.fill('os_username', 'user')
browser.fill('os_password', 'pass')

Answer Source

I was able to achieve the same goal through saving all the preferences within the Firefox browser, then calling my Firefox profile

browser = Browser('firefox', profile=r'C:\Users\me\AppData\Roaming\Mozilla\Firefox\Profiles\0lot9hun.default')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download