Watir on WebDriver
Update!
Instructions on this page are obsolete. Please find up to date detailed instructions for Windows, Mac and Linux in my watir book.
Jari Bakken just released Watir on WebDriver.
Windows
One-Click Installer (old)
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).
RubyInstaller
Install RubyInstaller, DevKit and all required gems and it just works!
gem install watir-webdriver
Mac
My Mac came with Ruby and RubyGems installed, so it was just:
sudo gem install watir-webdriver
Linux
Ubuntu
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
Fedora
Please see Installing Watir-Web Driver on Fedora Linux

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
[...] Jari Bakken just released pre-release of Watir-Webdriver (install instructions at Watir on WebDriver) [...]
#32 Brent Strange | Watir Podcast
6 Sep 10 at 5:26 pm
[...] to support this newer approach. For installation instructions of Watir on top of WebDriver there is a good post on the topic by Željko Filipin. There’s also some musings on the ‘why’ of [...]
Watirgrid Support for Watir-Webdriver « Altentee » Performance & Test Automation Experts
11 Oct 10 at 1:11 am
To install the webdriver on Ubuntu 10.10 64bit I did the following,
sudo apt-get install ruby-full
sudo apt-get install rubygems
sudo gem1.8 install watir-webdriver
Alastair
27 Oct 10 at 12:18 pm
Alastair,
Thanks for letting me know. I have just started to update the post with the information you have provided, and I see that I already have `sudo apt-get install ruby-full`.
Željko Filipin
27 Oct 10 at 12:24 pm
As of selenium-webdriver 0.0.29, win32-process is no longer needed on Windows.
Jari
24 Nov 10 at 12:55 am
Jari, thanks for letting me know, I have removed win32-process.
Željko Filipin
24 Nov 10 at 1:26 pm
[...] that option again-. So we’ll uninstall firewatir and then install watir-webbriver (detailed install instructions) using the command shell: $ sudo gem uninstall firewatir $ sudo apt-get install [...]
Web Page Testing with Firefox 4.0 (and HTML 5 Dojo Toolkit Data Tags) | Interesting IT Tip's
25 Apr 11 at 8:20 pm
Hi,
I am using watir with firefox on windows 7. And I would like to start using watir webdriver.
What is not clear for me: do i have to unistall JSSH firtst.
I have installed the watir webdriver; and i have that sample that I would like to make t running in IE
require ‘watir’
require “rubygems”
require “watir-webdriver”
#Watir::Browser.default = “firefox”
#browser = Watir::Browser.new(:firefox)
browser = Watir::Browser.new(:internet_explorer)
# browser = Watir::Browser.new(:chrome)
browser.goto(“http://www.google.com/ncr”)
browser.text_field(:name, “q”).set(“pickaxe”)
browser.button(:value, “Google Search”).click
browser.close
But I am receiving:
”
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:274:in `activate’: can’t activate ffi (>= 1.0.7, runtime) for ["selenium-webdriver-0.2.0", "watir-webdriver-0.2.2"], already activated ffi-0.6.3-x86-mingw32 for ["childprocess-0.1.7", "selenium-webdriver-0.2.0", "watir-webdriver-0.2.2"] (Gem::LoadError)”
There is any conflick with selenium-webdriver is installed?
Thanks,
Cristina
Cristina
9 May 11 at 9:55 pm
Please see this page on how to get Watir support: http://watir.com/support/
Željko Filipin
9 May 11 at 9:59 pm
Hi,
I tried to install chrome WATIR in Windows XP, so I have first installed web driver gems and tried to run the following script,
require ‘watir-webdriver’
$browser = Watir::Browser.new(:chrome)
$browser.goto(“www.google.co.in”)
$browser.text_field(:name, “q”).set(“Test”)
$browser.button(:name, “btnG”).click
but I am getting a error msg says “Unable to find the chromedriver executable”.
anyone can help me this regard?
Srinivas
19 Jul 11 at 7:06 am
I do not provide Watir support here. Please see this page on how to get Watir support: http://watir.com/support/
Željko Filipin
20 Jul 11 at 10:49 am