5

I have the following code

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

And get the following error :

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File ~\untitled2.py:11 in <module>
    driver = webdriver.Chrome(ChromeDriverManager().install())

  File ~\anaconda3\envs\TFE\lib\site-packages\selenium\webdriver\chrome\webdriver.py:45 in __init__
    super().__init__(

  File ~\anaconda3\envs\TFE\lib\site-packages\selenium\webdriver\chromium\webdriver.py:51 in __init__
    self.service.path = DriverFinder.get_path(self.service, options)

  File ~\anaconda3\envs\TFE\lib\site-packages\selenium\webdriver\common\driver_finder.py:40 in get_path
    msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."

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

Does anyone know where it could be from?

Thanks

0

2 Answers 2

6

I was getting same error as yours. I tried following code and it works.

import selenium
from selenium import webdriver

chrome_options = webdriver.ChromeOptions()

# Set the executable path for the Chrome WebDriver
chrome_options.add_argument("webdriver.chrome.driver=[your chrome driver path sould be here]")

driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.google.ca")
print(driver.title)
driver.close()

I hope it helps.

0

My selenium has no ChromeDriverManager function or class, it can be the version problem.

it is a string returned by ChromeDriverManager().install()

class WebDriver(ChromiumDriver):
    """Controls the ChromeDriver and allows you to drive the browser."""
    def __init__(
        self,
        options: Options = None,
        service: Service = None,
        keep_alive: bool = True,
    ) -> None:
        self.service = service if service else Service()
        self.options = options if options else Options()
        self.keep_alive = keep_alive

        self.service.path = DriverFinder.get_path(self.service, self.options)

Your Answer

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

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