Geckodriver / Firefox如何在没有Marionette的情况下工作? (在FF 53上运行python selenium 3) [英] How can Geckodriver/Firefox work without Marionette? (running python selenium 3 against FF 53)

查看:297
本文介绍了Geckodriver / Firefox如何在没有Marionette的情况下工作? (在FF 53上运行python selenium 3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只有硒控制的Firefox弹出窗口,我看到一个奇怪的不可信的证书错误。非常具体。为了解决这个问题,各种谷歌搜索结果提示关闭木偶,如下所示:

  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities 

firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities ['marionette'] = False
driver = webdriver.Firefox()

这个工作,但怎么样? Geckodriver如何与Marionette合作?

来自


  1. 现在按照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:

Marionette is an automation driver for Mozilla's Gecko engine.

The answer goes on to explicitly say it should fail:

"In case of using the Firefox 53.x browsers if you forcefully set "marionette" to false through DesiredCapabilities class you will observe a UnreachableBrowserException."

So, how the heck is this working?

解决方案

Here are the Answers to all of your Questions:

  1. "untrusted cert" error only on selenium-controlled firefox pop-ups : This is a common issue and we can avoid that through configuring the WebDriver instance through DesiredCapabilities class.
  2. turning off marionette : Turning off marionette 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.
  3. 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
  4. 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.

  1. 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.

It is to be noted that the current Selenium-Python binding is unstable with geckodriver and looks to be Architecture specific. You can find the github discussion and merge here. So you may additionally need to pass the absolute path of the firefox binary as firefox_binary argument while initializing the webdriver

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.

Let me know if this Answers your Question.

这篇关于Geckodriver / Firefox如何在没有Marionette的情况下工作? (在FF 53上运行python selenium 3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆