[英]Selenium Firefox webdriver does not adopt profile
I have created a FF profile: 我创建了一个FF配置文件:
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: 然后将此配置文件传递给远程模式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
. 我已经将Firefox降级到35.0版,并使用了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. 甚至尝试在FireFox中使用
about:config
玩,但没用。 Could anyone please help? 谁能帮忙吗?
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.
Selenium API应该将此行放入其文档中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.