1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

selenium 利用時に ChromeDriver の version 違いで起こるエラー対処法

Posted at

#背景
自分用のメモ

状況

  • Selenium で動かしているプログラムが、以下エラーで動かなくなった
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version ○○
  • エラー内容としてChromeDriver versionが原因
  • chromedriver の version が一致していないので合わせる

(毎回調べるのが面倒なのでメモ。)

環境

・Mac Mojave 10.46.6
・homebrew-cask で ChromeDriver を事前に入れている

対処法

ChromeDriverとChromeバージョン違いで起こるエラーで紹介されているように downgrade すれば問題なく動く。

upgrade して修正したい場合は、chromedriver を brew cask upgradeすればOK。
前は Homebrewでcask upgradeが実装されていたで紹介されているように、方法がなかったらしいが、brew cask upgradeを使うことで、homecask 経由で落としたアプリを一括アップデートできるよう実装されている。(有志の皆様、ありがとうございます!)

upgrade は 例えば以下の流れ。

XXX-XXX% brew cask list
chromedriver                                     coolterm                                         google-chrome-canary

XXX-XXX% brew cask upgrade 
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/cask-versions, homebrew/core and homebrew/cask).
==> New Formulae
crc                  docker-slim          gnirehtet            libtorch             powerline-go         skymaker             tio
...(省略)
==> Updated Formulae
abcl                                 flow                                 libtorrent-rasterbar                 pyinvoke
abcmidi                              fmt                                  libtrace                             pylint
...(省略)
==> Deleted Formulae
aap                  bubbros              curlish              docker-cloud         ino                  nicotine-plus        sshconfigfs
archivemail          bzr-fastimport       cvs2svn              euca2ools            
...(省略)
==> Casks with `auto_updates` or `version :latest` will not be upgraded
==> Upgrading 1 outdated package:
chromedriver 77.0.3865.40 -> 79.0.3945.36
==> Upgrading chromedriver
==> Downloading https://chromedriver.storage.googleapis.com/79.0.3945.36/chromedriver_mac64.zip
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'chromedriver'.
==> Unlinking Binary '/usr/local/bin/chromedriver'.
unzip -o /Users/username/Library/Caches/Homebrew/downloads/2712e559b7e0712e196b123a7581adecc2cfdc8d8d728b01fd875b3d371e5d29--chromedriver_mac64.zip -d /var/folders/v_/d8m3hn9n4nj62mx2c7lzkx200000gn/T/d20191217-6720-1bmlok7
chmod +rw /var/folders/v_/d8m3hn9n4nj62mx2c7lzkx200000gn/T/d20191217-6720-1bmlok7/chromedriver
cp -p /var/folders/v_/d8m3hn9n4nj62mx2c7lzkx200000gn/T/d20191217-6720-1bmlok7/chromedriver /usr/local/Caskroom/chromedriver/79.0.3945.36/chromedriver
==> Linking Binary 'chromedriver' to '/usr/local/bin/chromedriver'.
==> Purging files for version 77.0.3865.40 of Cask chromedriver
🍺  chromedriver was successfully upgraded!

これで動かすと、問題なくプログラムが動作した。
とう言うわけで、上記エラーが出た場合は、downgrade or upgrade で対応すればよいっぽいです。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?