How can Geckodriver/Firefox work without Marionette? (running python selenium 3 against FF 53)

前端 未结 1 875
南方客
南方客 2020-12-04 02:34

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 of

相关标签:
1条回答
  • 2020-12-04 03:09

    You have take care of a couple of things as follows:

    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.

    0 讨论(0)
提交回复
热议问题