LoginSignup
27
20

More than 5 years have passed since last update.

[Ruby] ChromeをSeleniumで動かす方法

Posted at

以下のRubyコードを実行しても

require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

以下の様なエラーが出る場合

Selenium::WebDriver::Error::WebDriverError: 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 https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.
from /Users/Jimmy/.rvm/gems/ruby-2.2.1/gems/selenium-webdriver-2.47.1/lib/selenium/webdriver/chrome/service.rb:37:in `executable_path'

1. 以下のリンクで環境にあったchromedriverをダウンロードする

2. 解凍したchromedriverをwhich rubyした時のパスと同じ階層にいれる

以下の場合は

$ which ruby
/Users/nwtgck/.rvm/rubies/ruby-2.2.1/bin/ruby

以下のコマンドでOK

$ mv chromedriver /Users/nwtgck/.rvm/rubies/ruby-2.2.1/bin

起動

require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

スクリーンショット 2015-08-25 午後4.44.21.png

27
20
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
27
20