简体   繁体   English

Selenium Firefox Webdriver不采用配置文件

[英]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.

相关问题 Python中的Selenium:将Firefox配置文件设置为webdriver似乎不起作用 - Selenium in Python: Setting Firefox profile to webdriver does not seem to work 在python中使用默认的firefox配置文件和selenium webdriver - Using the default firefox profile with selenium webdriver in python Selenium Python Firefox webdriver:无法修改配置文件 - Selenium Python Firefox webdriver : can't modify profile Selenium webdriver在firefox profile.setpreference中禁用WebRTC检测 - Selenium webdriver Disable WebRTC detection in firefox profile.setpreference Python Selenium-FireFox Webdriver配置文件首选项中可能有哪些键 - Python Selenium - What are possible keys in FireFox webdriver profile preferences 如何在 python 中为 selenium webdriver 导入和导出 FireFox 配置文件 - How to import and export FireFox profile for selenium webdriver in python 在任何PC上使用默认的Firefox配置文件进行Selenium(python)Webdriver授权 - Selenium(python) webdriver authorization using default firefox profile on any PC 创建Webdriver后Selenium Firefox配置文件更新下载目录 - Selenium firefox profile update download directory after creating webdriver 将Firefox与Selenium Webdriver一起使用不会记录历史记录 - Using Firefox with Selenium webdriver does not record history Selenium WebDriver:Firefox 启动,但不打开 URL - Selenium WebDriver: Firefox starts, but does not open the URL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM