Help us understand the problem. What is going on with this article?

Mac で Ruby で Firefox の selenium でちょっとつまづいた

Firefox でウェブのフォームにちょっと値を入れた状態にする,ということを Mac 上の Ruby で自動化したかった。

selenium-webdriver という gem を使えば簡単(Rails のデフォルトの Gemfile にもこの gem は書かれている)。

ところが久々に動かそうとしたらつまづいた。

コード

こんな感じで,とりあえずページを開こうとした

Gemfile
# 該当部分
gem "selenium-webdriver"
# 該当部分
driver = Selenium::WebDriver.for(:firefox)
driver.navigate.to("http://localhost:3000/")

エラー

Selenium::WebDriver::Error::UnknownError: newSession

と怒られた。

解決

もともと brew install geckodriver で geckodriver は入ってたんだけど,以下の手順で入れ直したら解決した。

rm '/usr/local/bin/geckodriver'
brew install geckodriver
brew link geckodriver

環境

macOS 10.13.6(High Sierra)
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin15]
geckodriver 0.23.0
Firefox 64

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away