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:
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 check boxes.
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:
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
gem install watir --no-ri
gem install watir-webdriver
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
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!
Open a new cmd window and type the following:
b = Watir::Browser.new :ff
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 ;-)
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:
b = Watir::Browser.new :chrome
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:
[5788:17528:1010/103252:ERROR:platform_thread_win.cc(127)] NOT IMPLEMENTED
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:
b = Watir::Browser.new :ie
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.
When you're ready to carry on you'll probably want to grab yourself an IDE, I go through a few options here: