LoginSignup
12
10

More than 5 years have passed since last update.

gem selenium-webdriverでRspecがコケた時の対処法

Last updated at Posted at 2015-06-13

経緯

everydayrails(RSPECによるRailsテスト入門)の
「8.フィーチャスペック」内
「javascriptを利用するやりとりも含める」で以下の問題が発生したので解決策を以下に記載します。

問題

Gemfileにselenium-webdriverを追加しspecを走らせたところ、以下のエラーが発生。

Failure/Error: visit root_path
     Selenium::WebDriver::Error::WebDriverError:
       unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)

理由

selenium-webdriverのgemのバージョンが古かったから

解決策その1(推奨)

※6/14修正(@jnchitoさんありがとうございます)
1,gemfileを以下に変更します。

gem 'selenium-webdriver'

2,ターミナルで以下のコマンドを打つと最新のgemを取得出来ます。
bundle update selenium-webdriver

firefoxのバージョンが上がって動かない時には、上記の方法で解決出来るようです。

解決策その2

gemfileを以下に変更

gem 'selenium-webdriver', "~> 2.46.2"

※2015年6月時点のバージョンなので、firefoxのバージョンが上がると動かなくなる可能性があります。

教訓

gemのバージョンを確認する。
バージョンを固定しないほうが良い場合もある。

12
10
5

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