2

I updated from selenium 3.141.0 to 4.0.0b4. The code below worked fine before (it opened up google)

import selenium
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)

driver.get("https://google.com.au")

But once I updated, selenium has begun to give me this error message:

Unrecognised option moz:debuggerAddress

I've tried to dig around on the internet for a while and I can't find any resolution. The closest thing I found was another package that had the same issue, but I'm not sure how the fix applies here. I wanted to try and "disable" the moz debuggeraddress option but I don't know how. I never had the option to add it - it seems like something else is mysteriously adding this option for me. How can I make the above code work in 4.0.0.b4 ?

John Hon
  • 153
  • 1
  • 9

1 Answers1

0

I had the same issue after I updated to Selenium 4.0.0. The error ceased to occur after I updated my geckodriver to 0.30.0 and addressed some of the deprecated objects from previous selenium versions, but in the process I may have mistakenly imported the wrong Service and/or Options from Selenium. I think that may be what is going on in your case as well.

I could not replicate the error directly from your code. I used the code below to demonstrate the potential error and the solution.

Service object stack post: DeprecationWarning: executable_path has been deprecated selenium python

Latest geckodriver: https://github.com/mozilla/geckodriver/releases/tag/v0.30.0

I replicated your error by running this in Windows Subsystem for Linux (WSL2) with Ubuntu 20.04 with Selenium 4.0.0 or Selenium 4.0.0b4 (I tested both with the same outcome) with geckodriver v0.28.0.

import pathlib
from selenium import webdriver
from selenium.webdriver.firefox.options import Options

# note the purposeful error in the service import #
from selenium.webdriver.chrome.service import Service

options = Options()

options.headless = True

# I keep my driver in my local folder with my script #
path = f"{pathlib.Path(__file__).parent.absolute()}/geckodriver" 

driver = webdriver.Firefox(service=Service(path), options=options)

print(driver.capabilities['moz:geckodriverVersion'])

driver.get("https://google.com.au")

print(driver.page_source[0:97:1])

driver.quit()

This code returns:

selenium.common.exceptions.InvalidArgumentException: Message: Unrecognised option moz:debuggerAddress

This suggests to me that when running the old gecko driver selenium can't overcome the misused chrome Service. If you switch the purposefully mistaken Service import to firefox as:

from selenium.webdriver.firefox.service import Service

The code will then return:

PermissionError: [Errno 13] Permission denied: '/home/***/geckodriver'

During handling of the above exception, another exception occurred:

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable may have wrong permissions.

Finally, if you update to geckodriver v0.30.0 both of the scripts above will return:

0.30.0 #indicating gecko version #
<html itemscope="" itemtype="http://schema.org/WebPage" lang="en-CA"><head><meta charset="UTF-8"> #a subset of the HTML returned from a page source #

Taken together, I would suggest updating your geckodriver and taking a look at your imports. This is somewhat of an applied solution, if someone has a better understanding of the inner workings of the Service and Options objects they may be able to provide a more detailed answer.

  • moz:debugerAddress is not an Option, it's under capabilities. I've not been able to solve the problem, but poped out such option from my capabilities dict. Case you don't manually use capabilities, just do it with `capabilities = DesiredCapabilities.FIREFOX.copy()` then `capabilities.pop("moz:debuggerAddress")`. Start the driver the same as now, but passing also the capabilities like `driver = webdriver.Firefox(service=Service(path), options=options, capabilities=capabilities)`, so, when you refer to driver.capabilities that option is not even present. That solved the problem for me. – m3nda Nov 27 '21 at 15:50