How can Geckodriver/Firefox work without Marionette? (running python selenium 3 against FF 53)
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.
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.