Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to utilize BrowserStack's automated testing using ruby with Selenium WebDriver with Eclipse.

Here is the code i'm trying to run:

require 'rubygems'
require 'selenium-webdriver'

# Input capabilities
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browser"] = "IE"
caps["browser_version"] = "7.0"
caps["os"] = "Windows"
caps["os_version"] = "XP"
caps["browserstack.debug"] = "true"
caps[:name] = "Testing Selenium 2 with Ruby on BrowserStack"

driver = Selenium::WebDriver.for(:remote,
  :url => "http://xxxxxxxxxxxxx:[email protected]/wd/hub",
  :desired_capabilities => caps)
driver.navigate.to "http://www.google.com/ncr"
element = driver.find_element(:name, 'q')
element.send_keys "BrowserStack"
element.submit
puts driver.title

driver.quit

And here is the error i'm running into:

/Users/user/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- selenium-webdriver (LoadError)
from /Users/user/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/user/Documents/workspace/Lowfares/ie/wintest.rb:2:in `<main>'
like image 749
Dimi Avatar asked Dec 26 '22 10:12

Dimi


1 Answers

In my case it helped to add the following to my Gemfile

# in test group
gem 'selenium-webdriver'

Then run bundle install

like image 86
houbena Avatar answered May 11 '23 05:05

houbena