Search code examples
rubyseleniumrubygemscapybaraosx-elcapitan

unable load selenium-webdriver on mac os el capitan


I upgraded to El Capitan then problem started. When I run cucumber features it gives following error:

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'

when I run bundle install then selenium-webdriver is installed:

~/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

But when I check the which selenium-webdriver, it returns nothing:

~/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 ⚡=) 

My ruby version is:

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

I guess the problem is related to path and configuration because I can require selenium-webdriver irb, but I couldnt solve it. Any gurus please help me on the problem?


Solution

  • May someone need this solution.

    After many trials, eventually I found something solves the problem. First the version of rbenv and ruby were different so install the same version of ruby with rbenv as ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]. After that install the bundle again and finally bundle install installed the webkit and other gems successfully.

    ~/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