Ruby selenium cannot load such file — selenium-webdriver (LoadError)

In my case it helped to add the following to my gem file

gem 'selenium-webdriver

then run "bundle install"

Dimi

What I realized is when you install selenium you need to run sudo gem install selenium-webdriver for applications to access it.

This is because, the libraries are not installed globally

sudo gem install --no-user-install selenium-webdriver

the above command install the libs inside [email protected]

Image

I faced the same error when I used Sublime Text 2 and tried to run using the 'build' button. But the script ran fine when i ran it from the command prompt.

It has more to do with the path assigned to the editor more than anything else. ALthough do a quick a check on your gem list to see if the selenium - webdriver exists there or not.

I had the same issue when changing laptop.

For me this was the path. In eclipse: Select 'Window' then 'Preferences' then select 'Ruby' and 'Interpreters' Ensure the interpreter selected points to your installation .exe of ruby

You could do a search or just browse to the path if you know it.

Once I fixed this I was up and running :-)

In my case i was facing multiple such errors including cannot load such file — selenium-webdriver (LoadError). After installing Ruby dev kit with MSYS2 development tool chain the issue was resolved. Following were the steps followed:

  1. Installed Ruby with MSYS2 development tool chain option checked. Be default it is not checked.

enter image description here

  1. Ran all three MSYS2 installations one by one in order

    1 - MSYS2 base installation

    2 - MSYS2 system update (optional)

    3 - MSYS2 and MINGW development toolchain

Which components shall be installed? If unsure press ENTER [1,2,3]

  1. Checked Ruby SDK is selected. On Ruby-mine it is at Run->Edit Configuration

  2. Installed the gem using: gem install selenium-webdriver

In my case, I was using Bundler, so simply adding require bundler/setup to the top fixed the problem for me. Hope that helps someone else.