読者です 読者をやめる 読者になる 読者になる

dehio3’s diary

仕事、生活、趣味のメモ

CUI実行環境構築

CUIでの実行環境構築

以下の手順を参考に環境を作成

tech-sketch.jp

テストコードを実行したところ以下のエラーが発生

# ruby /tmp/selenium_test.rb
/var/lib/gems/2.3.0/gems/selenium-webdriver-3.2.2/lib/selenium/webdriver/common/service.rb:59:in `binary_path':  Unable to find Mozilla geckodriver. Please download the server from https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH. More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver. (Selenium::WebDriver::Error::WebDriverError)
    from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.2.2/lib/selenium/webdriver/common/service.rb:49:in `initialize'
    from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.2.2/lib/selenium/webdriver/firefox/w3c_bridge.rb:33:in `new'
    from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.2.2/lib/selenium/webdriver/firefox/w3c_bridge.rb:33:in `initialize'
    from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.2.2/lib/selenium/webdriver/common/driver.rb:52:in `new'
    from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.2.2/lib/selenium/webdriver/common/driver.rb:52:in `for'
    from /var/lib/gems/2.3.0/gems/selenium-webdriver-3.2.2/lib/selenium/webdriver.rb:87:in `for'
    from /tmp/selenium_test.rb:3:in `<main>'

Mozilla geckodriver をダウンロードしろとのこと

# cd /usr/loca/src
# wget https://github.com/mozilla/geckodriver/releases/download/v0.14.0/geckodriver-v0.14.0-linux64.tar.gz

# tar -zxvf geckodriver-v0.14.0-linux64.tar.gz
geckodriver

# ls -l
total 7256
-rwxrwxr-x 1 ubuntu ubuntu 5593244 Jan 31 17:14 geckodriver
-rw-r--r-- 1 root   root   1832331 Jan 31 17:15 geckodriver-v0.14.0-linux64.tar.gz

# mv geckodriver /usr/local/bin/
# ls -l /usr/local/bin/geckodriver
-rwxrwxr-x 1 ubuntu ubuntu 5593244 Jan 31 17:14 /usr/local/bin/geckodriver

テスト再実行…OK

# ruby /tmp/selenium_test.rb
Google