LoginSignup
19
12

More than 3 years have passed since last update.

CircleCIのChromeとchromedriver-helperのchromedriverのバージョンを揃える

Last updated at Posted at 2019-03-14

現象

CircleCIで自動テストを動かしていたところ、以下のようなエラーでfeature specが通らなくなった

     Selenium::WebDriver::Error::SessionNotCreatedError:
       session not created: This version of ChromeDriver only supports Chrome version 74
         (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Linux 4.4.0-141-generic x86_64)

これはCircleCIが用意しているコンテナ内にあるChromeとchromedriver-helperでインストールされるchromedriverのバージョンが違うために起こっているようだった
SSHログインを試して確認した

circleci@hogehoge:~$ google-chrome --version
Google Chrome 72.0.3626.121
circleci@9hogehoge:~$ ls .chromedriver-helper/
74.0.3729.6

解決策

以下の2つの方法があると思う

  1. Chromeのバージョンを上げる
  2. chromedriverのバージョンをchromeに合わせる

今回は2の方法を採用した

chromedriverのバージョンをChromeに合わせる

やっていることは
- Chromeのバージョンを取得
- 対応するchromedriverのバージョンを問い合わせる
- chromedriver-helper経由でchromedriverのバージョンを変える

      # Align chrome-driver's version installed by chromedriver-helper
      - run:
          name: Update ChromeDriver Version
          command: |
            CHROME_VERSION=$(google-chrome --version | sed -r 's/[^0-9]+([0-9]+\.[0-9]+\.[0-9]+).*/\1/g')
            CHROMEDRIVER_VERSION=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION)
            bundle exec chromedriver-update $CHROMEDRIVER_VERSION

webdrierを使用する(※追記)

chromedriver-helperがdeprecatedになったのでwebdriversを使わなければいけない
その場合は以下のように書き換えれば良い

bundle exec rake webdrivers:chromedriver:update

参考:
Version selection with LATEST_RELEASE is deprecated #79

chromeのバージョンを上げる

下記URLが参考になると思う。
Circle CIでHeadless Chrome 解決編
CircleCIのChromeを最新版に

19
12
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
19
12