pythonpython-3.xgoogle-chromeselenium-webdriverselenium-chromedriver

Attribute Error : 'str' object has no attribute '_ignore_local_proxy' with ChromeDriverManager


I've just started with Selenium and I'm already stuck at the first step: setting up the driver.
I keep getting this error:

'str' object has no attribute '_ignore_local_proxy'.

Here's the code :

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import requests

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

And the whole traceback :

AttributeError                            Traceback (most recent call last)
Cell In[21], line 1
----> 1 driver = webdriver.Chrome(ChromeDriverManager().install())

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\chrome\webdriver.py:49, in WebDriver.__init__(self, options, service, keep_alive)
     45 self.keep_alive = keep_alive
     47 self.service.path = DriverFinder.get_path(self.service, self.options)
---> 49 super().__init__(
     50     DesiredCapabilities.CHROME["browserName"],
     51     "goog",
     52     self.options,
     53     self.service,
     54     self.keep_alive,
     55 )

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\chromium\webdriver.py:60, in ChromiumDriver.__init__(self, browser_name, vendor_prefix, options, service, keep_alive)
     51 self.service.start()
     53 try:
     54     super().__init__(
     55         command_executor=ChromiumRemoteConnection(
     56             remote_server_addr=self.service.service_url,
     57             browser_name=browser_name,
     58             vendor_prefix=vendor_prefix,
     59             keep_alive=keep_alive,
...
     63     )
     64 except Exception:
     65     self.quit()

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

I'm using VS Code with Python 3.11, if that can somehow help.


Solution

  • This is due to changes in selenium 4.10.0: https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e

    Changes_in_selenium_4_10_0

    Note that the first argument is no longer executable_path, but options. (ChromeDriverManager().install() returns the path to the install location.) Since selenium manager is now included with selenium 4.10.0, you should no longer use ChromeDriverManager at all.

    from selenium import webdriver
    
    driver = webdriver.Chrome()
    # ...
    driver.quit()
    

    However, if you still want to pass in the executable_path to an existing driver, you must use the service arg now:

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    
    service = Service(executable_path="PATH_TO_DRIVER")
    options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(service=service, options=options)
    # ...
    driver.quit()