0
votes

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?

1
Are you sure that watir-webdriver is installed? Do you see it when you run gem list?orde

1 Answers

3
votes

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')