Rub*_*tos 5 python firefox selenium webdriver geckodriver
geckodriver版本
0.16.1
Firefox版本
53.0.2(32位)
怎么了:
当我尝试在不安全的页面上自动登录时,firefox会打开一个新选项卡" https://support.mozilla.org/1/firefox/53.0.2/WINNT/pt-PT/insecure-password ".
我怎么能禁用它?我认为属性"security.insecure_field_warning.contextual.enabled"与此行为有关,但我不知道如何通过python代码禁用它.
我尝试以下代码但没有成功:
[...]
firefox_driver = path_drivers + "geckodriver.exe"
profile = webdriver.FirefoxProfile()
profile.set_preference("security.insecure_field_warning.contextual.enabled", False)
return webdriver.Firefox(executable_path=firefox_driver, firefox_profile=profile)
Run Code Online (Sandbox Code Playgroud)
首选项不会更改,在about:config上保留True值.
任何的想法?
最好的祝福,
鲁本桑托斯
我找到了解决方案。
从 geckodriver 0.11 版本开始,可以通过 moz:firefoxOptions 功能更改 Firefox 首选项,而不是更改配置文件设置。
{
"capabilities": {
"alwaysMatch": {
"moz:firefoxOptions": {
"binary": "/usr/local/firefox/bin/firefox",
"args": ["--no-remote"],
"prefs": {
"dom.ipc.processCount": 8
},
"log": {
"level": "trace"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我能够使用此解决方案更改“security.insecure_field_warning.contextual.enabled”:
[...]
firefox_driver = path_drivers + "geckodriver.exe"
firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
#To disable insecure-password tab by support firefox
firefox_options = { "moz:firefoxOptions" : { "prefs" : { "security.insecure_field_warning.contextual.enabled" : False } } }
firefox_capabilities["alwaysMatch"] = firefox_options
return webdriver.Firefox(executable_path=firefox_driver, capabilities=firefox_capabilities)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
779 次 |
| 最近记录: |