问题描述
我只在 selenium 控制的 firefox 弹出窗口中看到一个奇怪的不受信任的证书"错误.很具体.为了解决这个问题,各种谷歌搜索结果建议关闭牵线木偶,如下所示:
from selenium.webdriver.common.desired_capabilities import DesiredCapabilitiesfirefox_capabilities = DesiredCapabilities.FIREFOXfirefox_capabilities['牵线木偶'] = False驱动程序 = webdriver.Firefox()
这有效,但如何?Geckodriver 在 Marionette 关闭的情况下如何工作?
来自
- 现在根据 Selenium 3.4.x 规范,我进行了一些修改.将 "marionette" 设为 true 并在初始化驱动程序时添加
executable_path
.
需要注意的是,当前的 Selenium-Python 绑定对于 geckodriver 是不稳定的,并且看起来是特定于架构的.您可以找到 github
I'm seeing a bizarre "untrusted cert" error only on selenium-controlled firefox pop-ups. Very specific. To solve this problem, various google results suggested turning off marionette, like so:
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = False
driver = webdriver.Firefox()
And this works, but how?? How is geckodriver working at all with Marionette off?
From this other Stack Overflow answer:
The answer goes on to explicitly say it should fail:
So, how the heck is this working?
You have take care of a couple of things as follows:
"untrusted cert" error only on selenium-controlled firefox pop-ups
: This is a common issue and we can avoid that through configuring theWebDriver
instance throughDesiredCapabilities
class.turning off marionette
: Turning offmarionette
is no more a solution while we work with Selenium 3.x and recent Mozilla Firefox Browser releases. By forcefully setting "marionette" to false through DesiredCapabilities class you won't be able to open Mozilla Firefox Browser above version 48.x.- About your code, I don't see any significant errors in your code. You have set "marionette" to false through
DesiredCapabilities
class but still works and open a Mozilla Firefox Browser session of legacy releases which is also installed on your machine which is below version 48.x - To do a quick test, I simply copied your code and opened the url
https://www.whatismybrowser.com/
.
Code:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = False
driver = webdriver.Firefox()
driver.get('https://www.whatismybrowser.com/')
Result: Mozilla Firefox version 47 is opened.
- Now as per Selenium 3.4.x specifications, I made a couple of modifications. Turned "marionette" to true and added
executable_path
while initializing the driver.
Code:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
driver = webdriver.Firefox(firefox_binary=binary,executable_path='C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get('https://www.whatismybrowser.com/')
Result: Mozilla Firefox version 53 is opened.
这篇关于Geckodriver/Firefox 如何在没有 Marionette 的情况下工作?(针对 FF 53 运行 python selenium 3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!