【问题标题】:unable load selenium-webdriver on mac os el capitan无法在 mac os el capitan 上加载 selenium-webdriver
【发布时间】:2016-03-06 15:32:12
【问题描述】:

我升级到 El Capitan 然后问题开始了。当我运行cucumber features 时,会出现以下错误:

Background: Member should open homepage # features/m001_top_header.feature:6
Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler. (LoadError)
./features/support/env.rb:47:in `new'
./features/support/env.rb:47:in `block in <top (required)>'
./features/support/app_life_cycle_hooks.rb:22:in `Before'
Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler. (LoadError)
./features/support/env.rb:47:in `new'
./features/support/env.rb:47:in `block in <top (required)>'
./features/support/app_life_cycle_hooks.rb:22:in `Before'

当我运行 bundle install 然后 selenium-webdriver 安装:

~/P/m/web-automation (responsive ⚡=) bundle install
...
Using websocket 1.2.2
Using selenium-webdriver 2.48.1
Using spec 5.3.4
...
Bundle complete! 13 Gemfile dependencies, 61 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
~/P/m/web-automation (responsive ⚡=) bundle show selenium-webdriver
/usr/local/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.48.1

但是当我检查which selenium-webdriver 时,它什么也没返回:

~/P/m/web-automation (responsive ⚡=) which selenium-webdriver
~/P/m/web-automation (responsive ⚡=) which rspec
/usr/local/bin/rspec
~/P/m/web-automation (responsive ⚡=) which ruby
/usr/local/bin/ruby
~/P/m/web-automation (responsive ⚡=) which selenium-webdriver
~/P/m/web-automation (responsive ⚡=) 

我的红宝石版本是:

~/P/m/web-automation (responsive ⚡=) ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]

我猜这个问题与路径和配置有关,因为我可以要求selenium-webdriver irb,但我无法解决。哪位大神帮我解决一下这个问题?

【问题讨论】:

    标签: ruby selenium gem capybara osx-elcapitan


    【解决方案1】:

    尝试运行

    bundle exec cucumber
    

    【讨论】:

    • 我需要使用 cucumber,因为 CI 脚本依赖它。
    • 嗯? bundle exec cucumber 只是设置环境,以便使用 Gemfile 中指定版本的 gems,然后在该环境中执行 cucumber。
    • 我知道它运行黄瓜,但我需要运行cucumber ...
    • 好吧,除非您正在运行的 cucumber 可执行文件设置为 binstub(基本上是 bundle exec cucumber ...),否则您将绕过 Gemfile 中设置的环境,您将拥有各种问题,因为您永远无法保证您正在运行的已安装 gem 的版本
    【解决方案2】:

    可能有人需要这个解决方案。

    经过多次尝试,最终我找到了解决问题的方法。首先rbenvruby 的版本不同,所以安装与ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15] 相同的ruby 版本和rbenv。之后再次安装bundle,最后bundle install成功安装了webkit和其他gem。

    ~/P/m/web-automation (responsive ⚡=) rbenv version
    2.0.0-p645 (set by /Users/mesutgunes/.rbenv/version)
    ~/P/m/web-automation (responsive ⚡=) ruby -v
    ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
    ~/P/m/web-automation (responsive ⚡=) bundle install
    Failed to execute process '/usr/local/bin/bundle'. Reason:
    The file '/usr/local/bin/bundle' specified the interpreter '/usr/local/opt/ruby/bin/ruby', which is not an executable command.
    ~/P/m/web-automation (responsive ⚡=)
    ~/P/m/web-automation (responsive ⚡=)
    ~/P/m/web-automation (responsive ⚡=) gem install bundler
    Successfully installed bundler-1.10.6
    Parsing documentation for bundler-1.10.6
    1 gem installed
    ~/P/m/web-automation (responsive ⚡=) bundle install
    

    【讨论】:

      猜你喜欢
      • 2016-09-19
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-15
      • 2016-06-11
      • 2016-10-23
      • 2017-02-27
      相关资源
      最近更新 更多