プログラミングを完全に理解したエンジニアのメモ

チラ裏レベルのことしか書いてないインターネットの藻屑

Selenimuのsession not created error と TCP connection error

問題

ひさしぶりにSeleniumを使うと下記のエラー

session not created: This version of ChromeDriver only supports Chrome version 103 (Selenium::WebDriver::Error::SessionNotCreatedError)
Current browser version is 110.0.5481.177 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

原因

ChromeDriverとMacchromeブラウザのバージョン違い

解決方法

$ brew upgrade chromedriver

下記から手動で落としているサイトもあるが、自分はbrewで管理しているので上記コマンドでOK

chromedriver.chromium.org

upgrade後実行しても、

Failed to open TCP connection to 127.0.0.1:9515 (Connection refused - connect(2) for "127.0.0.1" port 9515) (Errno::ECONNREFUSED)

というエラーが出るので、 Macの「システム環境設定」→「セキュリティとプライバシー」→「一般」タブ ダウンロードしたアプリケーションの実行許可を「このまま許可」