【问题标题】:Watir unable to find Mozilla geckodriverWatir 找不到 Mozilla geckodriver
【发布时间】:2017-04-01 21:12:48
【问题描述】:

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

Unable to find Mozilla geckodriver. Please download the server from https://github.com/mozilla/geckodriver/releases and place it

我已经完成了以下步骤。

下载最新的firefox(50.0版)

我从https://github.com/mozilla/geckodriver/releases下载最新版的geckodriver,放到~/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

宝石文件

source "https://rubygems.org"
gem  'nokogiri'
gem  'watir-webdriver'
gem  'open_uri_redirections'
gem  'selenium-webdriver'
gem  "watir", ">= 6.0.0.beta2"

环境:OSX 10.10

【问题讨论】:

  • Sierra 10.12.1FF 50.1.0GeckoDriver 0.13.0 上,您的步骤实际上对我有用

标签: ruby selenium firefox


【解决方案1】:

我在 Linux Mint 17.2 上遇到了同样的问题。我通过将提取的 tar to usr/bin 中的geckodriver 文件移动 解决了这个问题(您必须拥有root 权限才能这样做)。

由于某种原因,如果我在 path 变量中定义它,zsh 将找不到它。也许其他人有更好的解决方案,但现在可行。

【讨论】:

  • @CodaChang 在你的 shell 中试试这个:set -U fish_user_paths /path/to/your/gecko/driver $fish_user_paths 它应该永久改变你的路径。
【解决方案2】:

如果 geckodriver 在 ~/ 中,只需将 ~/ 添加到您的路径中。只有目录应该在您的路径中。大概是在~/geckodriver/geckodriver找geckodriver

另外,如果你使用的是最新版本的 Watir (6),你只需要require "watir" 而不是require "watir-webdriver"

【讨论】:

    猜你喜欢
    • 2018-09-06
    • 1970-01-01
    • 2017-05-09
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 2018-10-16
    • 1970-01-01
    • 2011-09-27
    相关资源
    最近更新 更多