対応方法: エラーが発生し、Selenium 経由で Chrome が使用できない場合の対処法
When using Selenium on a Mac, if you encounter errors like the following and cannot use Chrome via Selenium:
This version of ChromeDriver only supports Chrome version 114
Current browser version is 116.0.5845.96 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Or if you still get the following error even after installing the latest ChromeDriver:
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Check the ChromeDriver download page:
https://chromedriver.chromium.org/downloads
You will see:
If you are using Chrome version 115 or newer, please consult the Chrome for Testing availability dashboard. This page provides convenient JSON endpoints for specific ChromeDriver version downloading.
So, let's check the JSON endpoint:
https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
The release information is in JSON format. Ideally, you should create a script to automate the process, but for this urgent case, I will handle it manually.
curl 'https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json' | jq | less
Inspect the JSON content and search for version 116, then look for mac-arm64 around that section:
{
"platform": "mac-arm64",
"url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5791.0/mac-arm64/chrome-mac-arm64.zip"
},
{
"platform": "mac-arm64",
"url": "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5791.0/mac-arm64/chromedriver-mac-arm64.zip"
}
You will find these two lines.
Download the ChromeDriver and the automated testing version of Chrome (Google Chrome for Testing) from each URL.
Place the ChromeDriver in a directory included in your PATH.
If you have used ChromeDriver in the past, you can locate it with which chromedriver
. In my case, it was installed via Homebrew and located at /opt/homebrew/bin/chromedriver
, so I overwrote it.
Place Google Chrome for Testing in the Applications directory on your Mac.
This should make Selenium's ChromeDriver usable.
Update:
I have created a script to automate the updates.
https://www.ytyng.com/blog/download-chromedriver-and-deploy-to-path/
Comments