0

**Solution: Selenium's new tool known as SeleniumManager will do what ChromeDriverManager used to do. No need to use webdriver_manager **


options = Options()
options.add_argument('--no-sandbox')  # Run Chrome without the sandbox
options.add_argument('--headless')  # Run Chrome in headless mode (no GUI)

driver = webdriver.Chrome(options=options)

I'm trying to run the code below, but getting the following error:

WebDriverException: Message: Can not connect to the Service /Users/abc/.wdm/drivers/chromedriver/mac64/115.0.5790.114/chromedriver-mac-arm64/chromedriver

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.chrome.options import Options


options = Options()
options.add_argument('--no-sandbox')  # Run Chrome without the sandbox
options.add_argument('--headless')  # Run Chrome in headless mode (no GUI)
options.binary_location="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"

driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options = options)

I've done the following:

  1. Ensuring ChromeDriver binary has executable permission for the non-root user.
  2. Ensure that /etc/hosts file contains 127.0.0.1 localhost
  3. ChromeDriver executable file is the correct version for the installed version of Chrome (see image below)
  4. Verify that the path to the ChromeDriver executable is correct: /Users/abc/.wdm/drivers/chromedriver/mac64/115.0.5790.114/chromedriver-mac-arm64/chromedriver
  5. I've added /Users/abc/.wdm/drivers/chromedriver/ as a path environment variable.

enter image description here

Any ideas?

mikelowry
  • 1,307
  • 4
  • 21
  • 43

2 Answers2

2

Root cause of this issue: Chromium team have done some modifications to their drivers, the last stable driver version is v114. If your system is on browser version v115, then WebDriverManager is not finding and downloading the v115 driver from Chromium website. This is the cause of the issue.

enter image description here

Reference Link: https://chromedriver.chromium.org/downloads

SOLUTION: You can try one of the below:

Option 1. Force WDM to use driver v114, see code below

driver = webdriver.Chrome(service=Service(ChromeDriverManager(version="114.0.5735.90").install()),options=options)

Option 2. If you are using Selenium v4.6.0 or higher, you can just get rid of WebDriverManager, as Selenium's new tool SeleniumManager does what WDM used to do. So WDM is not needed anymore to handle browser drivers. Refer the answer below

https://stackoverflow.com/a/76752843/7598774

https://stackoverflow.com/a/76728148/7598774

UPDATE:

YOU CAN USE THE "NEW CHROME FOR TESTING" BROWSER AND v115 CHROMEDRIVER FROM FOLLOWING LINK CHROME FOR TESTING

Option 3.: Use below code to launch new "Chrome For Testing" browser:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

service = Service('C:\User\drivers\chromedriver-win32\chromedriver.exe') # v115 chromedriver.exe path
options = Options()
options.binary_location= 'C:\\User\\browsers\\chrome-win64\\chrome.exe' # v115 new ChromeFortesting browser path
options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=service,options=options)

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

Result: enter image description here

New "Chrome For testing" browser logo is slightly different(See below): Left side is regular Chrome browser and right side is new Chrome For Testing browser.

enter image description here

Shawn
  • 4,064
  • 2
  • 11
  • 23
  • Still had some persisting issues after applying the solutions provided here, what fixed it was running the following: ```brew install chromedriver```. – mikelowry Aug 20 '23 at 16:53
0

Selenium just added support for chromedriver 115 in the latest versions (4.11.2):

(Technically 4.11.0, but due to a bug, get 4.11.2 or newer for Python.)


If you're wondering why you're now seeing this error for ChromeDriverManager, it's because https://chromedriver.chromium.org/downloads only goes up to version 114 due to driver restructuring by the Chromium Team for the new Chrome-for-Testing.


Selenium Manager is now fully included with selenium 4.11.2, so you no longer need to use webdriver-manager/ChromeDriverManager. This is all you need now:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service()
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
# ...
driver.quit()

Add additional options as needed, such as:

options.add_argument("--no-sandbox")
options.add_argument("--headless=new")

If the driver isn't found on your system PATH, Selenium Manager will automatically download it.

Michael Mintz
  • 9,007
  • 6
  • 31
  • 48