0
fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList", 2);
fp.set_preference("browser.download.manager.showWhenStarting", False);
fp.set_preference("browser.download.dir", self.download_dir);
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv");
self.browser = webdriver.Remote("http://192.168.1.242:4444/wd/hub", 
                                     desired_capabilities=webdriver.DesiredCapabilities.FIREFOX,
                                    browser_profile=fp
                                    )

the above code does not respect the profile specified.

BUT the code below works as expected:

fp = webdriver.FirefoxProfile()
    fp.set_preference("browser.download.folderList", 2);
    fp.set_preference("browser.download.manager.showWhenStarting", False);
    fp.set_preference("browser.download.dir", self.download_dir);
    fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv");
    self.browser = webdriver.Firefox(fp)

In the seleniums documentation page http://seleniumhq.org/docs/04_webdriver_advanced.html#remotewebdriver has the following example:

from selenium import webdriver
fp = webdriver.FirefoxProfile()
# set something on the profile...
driver = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.FIREFOX,    browser_profile=fp)

which is the same as the code in my example. Also when i start the selenium server with -firefoxProfileTemplate it seems to ignore the profile's settings

java -jar ./selenium-server-standalone-2.25.0.jar -firefoxProfileTemplate  /home/xubuntu/.mozilla/firefox/fdui6lsj.crawler/

EDIT:

I also want to mention that if I load the profile from the file:

fp = webdriver.FirefoxProfile('/home/xubuntu/.mozilla/firefox/fdui6lsj.crawler/')

self.browser = webdriver.Remote("http://192.168.1.242:4444/wd/hub", 
                                 desired_capabilities=webdriver.DesiredCapabilities.FIREFOX,
                                browser_profile=fp
                                )

the profile is loaded but it takes a lot of time.

Can someone tell me what is wrong?

Giorgos Komnino
  • 433
  • 1
  • 7
  • 20
  • please see the question and help. [Question in stackoverflow][1] [1]: https://stackoverflow.com/questions/27058053/selenium-python-webdriver-path-error-system-cant-find-the-path-specified – Yevgeniy Semashko Nov 21 '14 at 09:49

1 Answers1

2

Try calling update_preferences() at the end. That should force the writing of the config file:

fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv");
fp.update_preferences()
Max Leske
  • 5,007
  • 6
  • 42
  • 54