Installing Watir & Ruby

Please Note: The following tutorial is applicable for Windows 7, XP and Vista. 

Step 1 – Install Ruby (Version 1.9.3-p448)

First things first, let’s download and install Ruby, the king of programming languages!

You can download it here, make sure you get version 1.9.3-p448:
http://rubyinstaller.org/download 

During the installation make sure you add the Ruby executables to your path and associate .rb and .rbw files with your installation by checking the appropriate checkboxes. 

Once you’ve installed Ruby open up a cmd window and run the following command to ensure everything is up to date:
gem update –system

Step 2 – Install Devkit

Download DevKit from here:
http://rubyinstaller.org/downloads

I’d reccommend this version: DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe


Once you’ve got that, extract it to c:\devkit


Then open a cmd window, goto the devkit directory and type the following commands:

ruby dk.rb init

ruby dk.rb install


Step 3 – Install Watir & Web Drivers

It’s now time to install Watir. This is actually pretty easy all you have to do is open up a cmd window and run the following commands to install the necessary gems.

gem install nokogiri

gem install mini_magick -v 3.5

gem install watir --no-ri --no-rdoc

gem install watir-webdriver --no-ri --no-rdoc

Now let’s install a couple of additional web drivers for IE and Chrome. Firefox will work without an additional driver so you won’t need to worry about that. Simply download them using the links below and then extract them to the bin folder located within your Ruby installation E.g. c:\ruby193\bin 

Chrome
http://chromedriver.storage.googleapis.com/index.html

IE
https://code.google.com/p/selenium/wiki/InternetExplorerDriver

Step 4 – Testing Our Installation

Okay we’re all installed now hopefully so let’s run a quick test to see if it works and we can actually take control of some web browsers!

FireFox
Open a new cmd window and type the following:

irb

require "watir-webdriver"

b = Watir::Browser.new :ff

b.goto "http://www.thebritishibm.com"

Hopefully that should have opened a new instance of FireFox and then navigated to my band’s website! Why not treat yourself to a CD or a T-Shirt while you’re there 😉

Chrome
This is my favourite browser and has proved to be the most reliable to use when automating with Watir (in my own personal opinion). Anyway, once again open up a new cmd window and then type in the following:

irb

require "watir-webdriver"

b = Watir::Browser.new :chrome

b.goto "http://www.gimpysoftware.com"

That should have opened a new instance of Chrome and then navigated to another one of my sites featuring a Panda bear with jetpack.

NOTE. There appears to be an issue with the latest Chrome Driver, you may see an error message like this but as long as an instance of Chrome is opened then you should be fine:

IE
Lastly, let’s give old IE a whirl, this used to be my default browser in the old days, can’t say I’m much of a fan now but anyway open up a new cmd window and then type in the following:

irb

require "watir-webdriver"

b = Watir::Browser.new :ie

b.goto "http://www.aidy.com"

That should have opened a new instance of IE and then navigated to yet another one of my sites, all the music on here is free to download by the way so fill your boots son! You’ve earned it after all that installation mayhem, chuck on a bit of ‘Not Your Day’ and relax with a beer.

Leave a Reply

Your email address will not be published. Required fields are marked *