0

When trying to get Chromium going with selenium I constantly get the following error

chromedriver
Traceback (most recent call last):
  File "/home/admin/.local/lib/python3.9/site-packages/selenium/webdriver/common/driver_finder.py", line 38, in get_path
    path = SeleniumManager().driver_location(options) if path is None else path
  File "/home/admin/.local/lib/python3.9/site-packages/selenium/webdriver/common/selenium_manager.py", line 76, in driver_location
    browser = options.capabilities["browserName"]
AttributeError: 'str' object has no attribute 'capabilities'

How I have tried getting it

print(webdriver.Chrome())
print(webdriver.Chrome("/usr/bin/chromedriver"))
print(webdriver.Chrome('/usr/lib/chromium-browser/chromedriver'))

Browser version

chromium-browser --version
Chromium 113.0.5672.95 Built on Raspbian , running on Raspbian 11

Webdriver version

sudo apt install chromium-chromedriver
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
chromium-chromedriver is already the newest version (113.0.5672.95-rpt1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Chromedriver

chromedriver --version
ChromeDriver <Some IP> (917deeefba48411c7b40ba19aef7b229bf48acd7-refs/branch-heads/5672_63@{#13})
which chromedriver
/usr/bin/chromedriver

Where is the driver

dpkg -L chromium-chromedriver
/.
/usr
/usr/bin
/usr/bin/chromedriver
/usr/lib
/usr/lib/chromium-browser
/usr/share
/usr/share/doc
/usr/share/doc/chromium-chromedriver
/usr/share/doc/chromium-chromedriver/changelog.Debian.gz
/usr/share/doc/chromium-chromedriver/copyright
/usr/lib/chromium-browser/chromedriver

Selenium

Type "help", "copyright", "credits" or "license" for more information.
>>> import selenium
>>> selenium.__version__
'4.12.0'

Yet as you can see I have the chromium browser, I have the chromium driver, their versions match. Why isn't this working well? What does this error mean?

I have tried reading other posts to figure this one out but most of them seemed to have the issue that the driver version did not match. This is not the case here. Furthermore in the documentation for selenium it says that in version 4.6 or higher it should automatically download drivers.

What might be going on here?

1 Answer 1

0

Alright! I figured it out with help of a GitHub ticket on the very responsive Selenium project https://github.com/SeleniumHQ/selenium/issues/12746

They changed things up in a recent release so many of the examples out there are outdated. The proper way to do this now is

service = webdriver.ChromeService(executable_path = '/usr/bin/chromedriver')
driver = webdriver.Chrome(service=service)

See this documentation where they talk about the services

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.