Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'str' object has no attribute 'capabilities' in selenium

Code screenshot1 Code screenshot2

Getting error when using selenium in colab

I am trying to use selenium in colab but they show attribute error

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/common/driver_finder.py in get_path(service, options)
     38             path = SeleniumManager().driver_location(options) if path is None else path
     39         except Exception as err:
---> 40             msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."
     41             raise NoSuchDriverException(msg) from err
     42 

AttributeError: 'str' object has no attribute 'capabilities'
like image 937
Fatahullah Khan Avatar asked Sep 13 '25 11:09

Fatahullah Khan


1 Answers

For the current version of selenium, you can't pass executable_path to Chrome() directly. If you want to reference a specific downloaded version of ChromeDriver try this:

from selenium import webdriver

cService = webdriver.ChromeService(executable_path='/Users/[...]binaries(117)/chromedriver')
driver = webdriver.Chrome(service = cService)

For windows reference the .exe itself.

like image 71
sd989 Avatar answered Sep 16 '25 01:09

sd989