user1593800 user1593800 - 7 months ago 16
Python Question

Selenium Firefox webdriver does not adopt profile

I have created a FF profile:

fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.dir", CLIENT_SAVING_DIR)
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")


Then pass this profile to remote mode webdriver:

remoteHost="192.168.x.y:4444/wd/hub"
driver = webdriver.Remote(remoteHost,
desired_capabilities=DesiredCapabilities.FIREFOX,
browser_profile=pf)


I've downgraded my Firefox to version 35.0 and using Selenium
selenium-server-standalone-2.44.0.jar
.

The driver works just fine but it seems the profile I had set is not used. The browser still appears the download prompt dialog.

I have tried for many times and consult everything I could find. Even tried playing with
about:config
in FireFox but useless.
Could anyone please help?

Answer

I have found the answer. (It took me for a day at work)

fp = webdriver.FirefoxProfile()
... set your profile attributes
fp.update_preference() #the answer

I think it's important to paste this line at the end of profile definition. Selenium API should put this line into their documentation.