Here is my code I tried different path versions but I am not able to run this code.
from selenium import webdriver
# Specify the path to the Chrome WebDriver executable
PATH = "C:\Users\CHEEMN2\Downloads\chromedriver-win64\chromedriver-win64/to/chromedriver.exe" # Replace with the actual path on your system
# Create a Chrome WebDriver instance
driver = webdriver.Chrome(executable_path=PATH)
# Open a URL
driver.get("https://www.google.com/")
# Close the WebDriver when done
driver.quit()
This is the error i keep on getting
[Running] python -u "c:\Users\CHEEMN2\OneDrive - CPGGPC\Python\import os.py"
Traceback (most recent call last):
File "C:\Users\CHEEMN2\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 38, in get_path
path = SeleniumManager().driver_location(options) if path is None else path
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\CHEEMN2\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 71, in driver_location
browser = options.capabilities["browserName"]
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'capabilities'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\CHEEMN2\OneDrive - CPGGPC\Python\import os.py", line 6, in <module>
driver = webdriver.Chrome(driver_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\CHEEMN2\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
super().__init__(
File "C:\Users\CHEEMN2\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 51, in __init__
self.service.path = DriverFinder.get_path(self.service, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\CHEEMN2\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 40, in get_path
msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'capabilities'
[Done] exited with code=1 in 0.683 seconds
I am using VS code for web scraping.
I have tried to to check all the versions for Python 3.11.4
I downloaded this version for Chrome chrome version 116.0.5845.97 (Official Build) (64-bit) (cohort: Bypass) chromedriver win64 https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/win64/chromedriver-win64.zip
the selenium version is python -c "import selenium; print(selenium.version)" 4.11.2