【发布时间】:2017-05-31 06:45:57
【问题描述】:
对于一个测试套件,我正在运行一个使用 selenium webdriver 控制 Firefox 实例的 python 脚本。我想将 about:config 中的设置 dom.disable_open_during_load 更改为 true。尽管这是我的默认 Firefox 配置文件中的默认设置,但 selenium 在我启动 webdriver 实例时将其更改为 false(用户定义)。它似乎使用了一个匿名的、稍微改变了的个人资料?!然后我可以手动将其改回来,但我很难用代码来做到这一点:使用新配置文件或使用 Firefox 配置文件管理器配置的预设配置文件都不能解决问题。
from selenium import webdriver
FFprofile = webdriver.FirefoxProfile()
FFprofile.set_preference('dom.disable_open_during_load', 'true') # I also tried True, 1 - with and without quotes
# FFprofile = webdriver.FirefoxProfile('C:/Users/ExampleUser/AppData/Local/Mozilla/Firefox/Profiles/owieroiuysd.testprofile')
FFdriver = webdriver.Firefox(firefox_profile=FFprofile)
FFdriver.get('http://www.google.com')
我可以通过这种方式更改各种设置,但这不适用于此设置。更改后的值false“用户定义”从何而来?它是某处硒的自动设置吗?我正在使用:
- geckodriver 0.16.1
- 硒 3.4.2.
- Firefox 53.0.3(64 位)
- python 3.4.4
编辑:我刚刚在 SO 上找到 this question,在 java 中处理同样的问题。
如果事实证明这是不可能的,那么可能有一个很好的解决方法吗?有什么想法吗?
【问题讨论】:
标签: python selenium selenium-webdriver