Everytime I run this code on any device (I tried on my Mac and Windows)
from selenium import webdriver
PATH="/Users/priyanshulal/Library/Mobile Documents/com~apple~CloudDocs/chromedriver-mac-arm64"
driver = webdriver.Chrome(PATH)
driver.get("https://www.chess.com/")
driver.close()
it gives me the same error:
Traceback (most recent call last):
File "/Users/priyanshulal/Library/Mobile Documents/com~apple~CloudDocs/PersonalProject/selen/selen.py", line 4, in <module>
driver = webdriver.Chrome(PATH)
^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 50, in __init__
if finder.get_browser_path():
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/common/driver_finder.py", line 47, in get_browser_path
return self._binary_paths()["browser_path"]
^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/common/driver_finder.py", line 56, in _binary_paths
browser = self._options.capabilities["browserName"]
^^^^^^^^^^^^^^^^^^^^^^^^^^
I am new to coding, so I'm not exactly sure what went wrong.
I expected a window for Chess.com with Google Chrome to pop up then close, but I got an error instead.
The easiest and simplest way to avoid this issue is to use the webdriver_manager library.
You can understand the purpose and benefits and how to use this in the reference below.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
driver.get("https://www.chess.com/")
driver.close()