I’m trying to mess with Selenium for the first time, upon installing chromedriver (125.0.6422.78 (r1287751)) and Google Chrome(Version 125.0.6422.113 (Official Build) (arm64)) – having to reinstall it through terminal.
I am currently using MacOS Sonoma 14.4.1.
When I run the program, it opens the Chrome For Testing app but then doesn’t not open the link provided in driver.get(“url”) – also does not quit afterwards with driver.quit().
Then about 30 seconds without any message, the error appears.
It is the only Chrome instance open (including both Chrome for Testing and normal ChromeBrowser).
Im quite new to all of this, so I have no clue what even could be causing this.
My code is the following:
import selenium
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
cservice = Service(executable_path="path/to/chromedriver")
driver = webdriver.Chrome(service= cservice)
driver.get("https://www.facebook.com")
time.sleep(5)
driver.quit()
After 30sec of not showing any error or appearing anything in Chrome for Testing this error appears:
Error:
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 55, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/selenium/webdriver/common/service.py", line 109, in start
raise WebDriverException(f"Can not connect to the Service {self._path}")
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /path/to/chromedriver
Replaced the actual path with “/path/to/chromedriver” – the path I’m using is not usr/local/bin but:
/chrome/mac_arm-125.0.6422.78/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing
Because it was the only way it even opened the Chrome For Testing – before it would give:
selenium.common.exceptions.WebDriverException: Message: Service (path) Status Code: -6
I have restarted my computer, did a clean chrome driver re-install, did a clean selenium re-install.
I have also tried to fix the error when using the /usr/local/bin directory but couldn’t find a solution.
Any idea?
edgarisnew is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.