Watir无法找到Mozilla geckodriver

Cod*_*ang 10 ruby firefox selenium

我正在使用Watir抓取一些东西,但它会抛出

Unable to find Mozilla geckodriver. Please download the server from https://github.com/mozilla/geckodriver/releases and place it
Run Code Online (Sandbox Code Playgroud)

我已经完成了以下步骤.

下载最新的firefox(版本50.0)

geckodriverhttps://github.com/mozilla/geckodriver/releases下载最新版本,并将其放入~/geckodriver

然后加入export PATH=$PATH:~/geckodriver~/.bash_profile和源它.

这是我执行的代码

require 'watir-webdriver'
browser = Watir::Browser.new :firefox # should open a new Firefox window
browser.goto 'http://nitrowriters.com/form/form.html' # or type the local path to your downloaded copy
Run Code Online (Sandbox Code Playgroud)

的Gemfile

source "https://rubygems.org"
gem  'nokogiri'
gem  'watir-webdriver'
gem  'open_uri_redirections'
gem  'selenium-webdriver'
gem  "watir", ">= 6.0.0.beta2"
Run Code Online (Sandbox Code Playgroud)

环境:OSX 10.10

小智 6

我在Linux Mint 17.2上遇到了同样的问题.我要解决它移动geckodriver文件从提取焦油 usr/bin(你拥有root权限才能做到这一点).

出于某种原因,如果我在path变量中定义它,zsh就找不到它.也许其他人有更好的解决方案,但现在这个有效.