On and off I've been messing around trying to get Watir to work on my machine. The gem installed properly based on the instructions given to simple go to the command line and use the following:

gem install watir

But when I tried to execute a simple test I got the following:

uninitialized constant Watir
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
./watir.rb:6: uninitialized constant Watir (NameError)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'
from C:/CODE06/RubyStart/WatirTest.rb:7

It seemed like an environment variable was not properly referencing the library but when I hunted for it I saw no environment variables. I ran the unit tests for Watir and it seemed to have installed correctly but I noticed the following at the beginning of each:

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__

Smells like a path the the library so I investigated with:


which shows me the following:


In order to get the script working I just hacked the $LOAD_PATH to include a hardcoded reference to my Watir libraries:

$LOAD_PATH.unshift 'c:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1'

From there I was set with the following simple script:

require 'watir'

include Watir

ie = Watir::IE.new

I'll dig into this - I haven't had the patience to sit down with a Ruby book just yet (anyone have ideas?) but if anyone has a similar problem running Watir, here is a hack to get you started if this is a hit on your Google search.



Thank you, I've alredy spent a lot of time looking for the solution.
Thanks a lot for this hack. I spent a good 2 hours wondering what the heck I was doing wrong.

Much appreciated.