Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Selenium with python script

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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'

>Solution :

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:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading