Passing a firefox profile to remote webdriver fire

2019-06-20 10:01发布

问题:

I'm trying to start up a remote webdriver instance of Firefox and pass in a profile.

profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList","2")
self.webdriver = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.FIREFOX,browser_profile=profile)

this is not working. If I pass it into the Firefox webdriver instance it works fine

profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList","2")
self.webdriver = webdriver.Firefox(firefox_profile=profile)

Is there a bug? I'm using Firefox 9 and Selenium 2.16

回答1:

So this was either a bug with Selenium or Firefox that has been fixed. Problem is that browser.download.folderList is an integer, so I changed it 2 to int and it works



回答2:

My call with Selenium 2.39.0 looks a little different than what's above. Note "browser_profile" as the key for the .Remote call, instead of "firefox_profile" used above.

    profile = webdriver.FirefoxProfile()
    profile.accept_untrusted_certs = True

    executor = "https://" + \
        self.env.getSeleniumHub()['ip'] + \
        ":4444/wd/hub"

    capabilities = self.env.getSeleniumCapabilities("firefox")

    self.driver = webdriver.Remote(
        browser_profile=profile,
        desired_capabilities=capabilities,
        command_executor=executor)
    self.driver.implicitly_wait(10)