jufisch
jufisch

Reputation: 1

Load Error persists with 'require watir-webdriver'

I'm trying to use the Watir gem in a short ruby script. When I run the script:

require 'rubygems'
require 'watir-webdriver'

browser = Watir::Browser.new

browser.goto 'http://wers.tunegenie.com/'

puts browser.div(class: 'song')

I get a load error:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- watir-webdriver (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require'

I've followed troubleshooting questions in other posts (need to install web-driver gem, need to require rubygems) but no luck. Any thoughts?

Upvotes: 0

Views: 453

Answers (1)

Sebastián Palma
Sebastián Palma

Reputation: 33471

Try to isolate your script/project into its own folder, create your Gemfile and replace the require to watir as the doc. says

In your folder, run bundle init to create your Gemfile. Add the watir gem (gem 'watir'), and replace your script to:

require 'watir'

browser = Watir::Browser.new
browser.goto 'http://wers.tunegenie.com/'

puts browser.div(class: 'song')

Upvotes: 3

Related Questions