Watir on WebDriver
Jari Bakken just released Watir on WebDriver.
On Windows, install it with
gem install watir-webdriver
and use it with
require "rubygems" # optional require "watir-webdriver" browser = Watir::Browser.new(:firefox)
Supported browsers are Internet Explorer (:ie, :internet_explorer), Firefox (:ff, :firefox), Chrome (:chrome) and RemoteWebDriver Server (:remote).
Update 1: as Steve suggested, I have tried it on RubyInstaller.
Install RubyInstaller, DevKit and all required gems and it just works!
gem install watir-webdriver gem install win32-process
Update 2: It works on Mac.
My Mac came with Ruby and RubyGems installed, so it was just:
sudo gem install watir-webdriver
Update 3: It works on Ubuntu Linux.
My Ubuntu did not have Ruby and RubyGems installed.
Install Ruby with:
sudo apt-get install ruby-full
You can install RubyGems with:
sudo apt-get install rubygems
but Jari said it would be better to install it from source. Downland the latest RubyGems tgz or zip file (rubygems-1.3.5.tgz and rubygems-1.3.5.zip at the moment), extract it, open Terminal in extracted folder and run:
sudo ruby setup.rb
Install watir-webdriver:
sudo gem1.8 install watir-webdriver
Update 4: watir-webdriver is no longer prerelase gem, so installation is simpler.

If you really want to live on the edge, how about trying it with RubyInstaller 1.8.6 [mingw32]?
skim
13 Jan 10 at 7:58 pm
Steve, you are always full of good ideas.
Will try tomorrow.
Željko Filipin
13 Jan 10 at 11:26 pm
What does your gem list look like for 1.8.6 [i386-mingw32]? I tried running a simple script, but it’s failing on loading watir-webdriver (it can’t find it).
I installed the three gems you mentioned for RubyInstaller.
skim
14 Jan 10 at 9:16 pm
Željko Filipin
15 Jan 10 at 2:29 pm
Steve, maybe you need to require rubygems.
Željko Filipin
15 Jan 10 at 6:55 pm
Hmmm weird. It worked, but why? I thought I read something against requiring rubygems.
skim
15 Jan 10 at 11:09 pm
Really? As far as I know requiring rubygems can not do any harm. In some implementations rubygems is already required, so you do not have to do it yourself.
Željko Filipin
15 Jan 10 at 11:18 pm
Here’s the response article that points to the original for requiring rubygems: http://blog.mmediasys.com/2009/12/30/to-require-or-not-require-rubygems-in-your-applications-or-libraries/
skim
16 Jan 10 at 11:12 pm
I have read the article and posts linked from it, and if you do not want to require rubygems, fell free to use solutions provided there.
Željko Filipin
18 Jan 10 at 2:34 pm
Yeah, I just need to figure out what it’s complaining about
skim
19 Jan 10 at 10:13 pm
I got super excited about this, but realized that Watir::Browser.attach was not working. Too bad, because I need attach support in the web apps I work on.
I found this selenium issue that appears to describe the problem – I guess this means it’s a WebDriver issue rather than a watir-webdriver issue? Hopefully it will get fixed eventually…
http://code.google.com/p/selenium/issues/detail?id=18
Anonymous
22 Jan 10 at 6:54 pm
Yes, as far as I remember, Jari said attach is not working because WebDriver does not support it yet.
Željko Filipin
22 Jan 10 at 7:06 pm
[...] January 28, 2010, Alan Baird (<alan_baird>) and Jari Bakken (<jarib>) had a chat about watir-webdriver on #watir IRC channel at freenode.net. Published with permission. [14:29] <alan_baird> [...]
Alan Baird and Jari Bakken on watir-webdriver at Željko Filipin's Blog on Software and Testing
3 Feb 10 at 12:25 pm
[...] http://zeljkofilipin.com/2010/01/12/watir-on-webdriver/ [...]
My first test using webdriver (aka Selenium 2.0)! « XPlayer
19 Feb 10 at 1:24 am
What do you need to do to get the remote web driver server working?
Alister Scott
8 Apr 10 at 11:07 am
Alister, I did not play with remote server. It would be the best to ask at Webdriver or Selenium lists.
Željko Filipin
8 Apr 10 at 11:03 pm
Hi Željko Filipin,
Thanks for your help.
Could work in chrome with the help of Webdriver:).
Godwin
21 Apr 10 at 7:54 am
Godwin, I am glad I could help.
Željko Filipin
21 Apr 10 at 10:12 am
I have followed the install instructions as above and verified that I have the gems for watir-webdriver & selenium-webdriver in my ruby folder.
I am using
require ‘rubygems’
require ‘watir-webdriver’
browser = Watir::Browser.new(:chrome)
and I get the error message:
C:/Ruby/lib/ruby/gems/1.8/gems/watir-webdriver-0.0.1.dev5/lib/watir-webdriver/exception.rb:8: superclass mismatch for class UnknownObjectException (TypeError)
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require’
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in’
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require’
from C:/Ruby/lib/ruby/gems/1.8/gems/watir-webdriver-0.0.1.dev5/lib/watir-webdriver.rb:6
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require’
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require’
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require’
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in’
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require’
from test.rb:8
any ideas?
Stuart Alexander
5 May 10 at 5:47 pm
Stuart,
This is not the best place for your question. Please take a look at these:
http://watir.com/support/
http://github.com/jarib/watir-webdriver/issues
Željko Filipin
6 May 10 at 1:53 pm
If you have somewhere else in your code:
require ‘watir’
you will get a superclass mismatch.
Try opening a new irb session and:
require ‘watir-webdriver’
That should work, if not you have a different problem
Steve
15 Jun 10 at 10:35 pm
Thanks Steve, I have forwarded your comment to Stuart.
Željko Filipin
16 Jun 10 at 9:35 am
[...] 7:15 – Zeljko’s blog post on Webdriver installation [...]
#35 Željko Filipin on Watir Stack Exchange Site | Watir Podcast
10 Jul 10 at 1:25 pm
[...] Explorer to work, I came across watir-webdriver. There’s a great guide for setting it up here. I managed to get it to run a google search in Chrome, however when it came to a Zoombu search it [...]
My experience with Watir | WillSteward.com
15 Jul 10 at 11:17 pm
Hi,
I installed watir-webdriver gem.
When i ran the script, i am getting an “Extension error” pop up and chrome browser opens indicating chromeDriver server started..
But it is not navigating to the desired web page.
Env:
Windows xp
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
Sample script which i ran:
#require “rubygems”
require “watir-webdriver”
browser = Watir::Browser.new(:chrome)
browser.goto “http://google.com”
browser.text_field(:name, ‘q’).set “watir-webdriver”
browser.button(:name, ‘btnG’).click
Abhishek
19 Jul 10 at 8:55 pm
Hi Abhishek, I have no idea why your script does not work. If you want an answer you should post your question at webdriver, watir-webdriver or watir support forums. Let me know if you can not find them.
Željko Filipin
23 Jul 10 at 11:08 pm
Hello,
Could you tell me what code did you use to test the webdriver on safari on Mac.
Thanks.
JD
2 Aug 10 at 9:44 pm
JD, as far as I know Safari on Mac is not supported. You should ask here: http://seleniumhq.org/support/
Željko Filipin
3 Aug 10 at 9:54 am