-2

I'm new to selenium and I keep running into the same error. I'm working on a windows os and have selenium version is v4.6.0.

from selenium import webdriver

driver = webdriver.Chrome('chromedriver.exe')
driver.get('https://www.selenium.dev/')
print(driver.title)
driver.quit()

But I keep running into this error and the path for the driver is correct.

Error

Traceback (most recent call last):
  File "c:\Users\chris\development\automation\selenium\index.py", line 5, in <module>
    driver = webdriver.Chrome('chromedriver.exe')
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\chris\development\automation\selenium\.venv\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 49, in __init__
    super().__init__(
  File "C:\Users\chris\development\automation\selenium\.venv\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 60, in __init__
    ignore_proxy=self.options._ignore_local_proxy,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute '_ignore_local_proxy'
  • 1
    https://stackoverflow.com/a/49795348/8669719 the webdriver.Chrome(absolute_path_to_chromedriver.exe) needs the absolute path to the chromedriver. See answer for detailed information. – Knight Jun 29 '23 at 08:31

3 Answers3

1

You need an absolute path to chrome driver for selenium to work. Your question is answered here.

Martin
  • 158
  • 1
  • 3
  • 13
0

The issue is in the below line:

driver = webdriver.Chrome('chromedriver.exe')

If your selenium version is v4.6.0 or above, then you don't need to set the path for chromedriver.exe, so your code can be simplified as below:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get('https://www.selenium.dev/')
print(driver.title)
driver.quit()

References:

Shawn
  • 4,064
  • 2
  • 11
  • 23
0

Note: Remove executable_url from the argument, because you have installed the latest version of Selenium if you have selenium above the 4.6.0 you don't need to add executable_url and in the latest version of Selenium you don't need to download webdriver.

just copy the below code and run the your python file simple

from selenium import webdriver

driver=webdriver.Chrome()

driver.get("https://www.facebook.com/")