Unable to find the chromedriver executable 対応

capybara を使った自動テストを実行しようとした時に下記のエラーが発生してこけました.

/Users/${YOUR_NAME}/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/selenium-webdriver-2.43.0/lib/selenium/webdriver/chrome/service.rb:20:in `executable_path': Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at http://code.google.com/p/selenium/wiki/ChromeDriver. (Selenium::WebDriver::Error::WebDriverError)

メッセージに書いてあるとおり, chromedriver のページにいってドライバーをダウンロード&解凍し, 任意のパスに配備. そしてそこにPATHを通すことで解消しました.

手順

 

1. chromedriver をダウンロード, 解凍

Macなので mac32 を選択

(64bit環境なのですが32bitでも問題なかったです.)

http://chromedriver.storage.googleapis.com/2.9/chromedriver_mac32.zip

 

2. ${HOME}/bin/chromedriver など任意のパスに配備

 

3. bashrc に export PATH="$HOME/bin:$PATH" などとしてパスを通す.

 

参考