Thursday, April 16, 2009

Watir - Wave 1



Starting up:

The first thing we obviously need to do is to install watir. So lets get into that:

Download and install ruby:

Go to ruby-lang and from there to the download page.
I really recommend you to use the 1.8.6 one click installer  because this include some dependencies that otherwise you will need to handle manually latter on. So to save time and avoid some minor complications latter on let's use that one.

There is really not much to say about the ruby install, just launch the installer, fallow the instructions and you should be ready to go in a few minutes.

If you keep all the defaults in the ruby install you have gems ready to use. I will not get into to much detail about gems, just google it and you will find a lot of information about it. For now just thing of it as a way to install "libraries" to your ruby install.

Launch a command prompt window and type: 
gem update --system
Note that if you are using Windows you might or not get an error at the end of the update this is just because Windows is missing some build tools, don't worry about it.

After that and without closing the command prompt type:
gem install watir
Wait a couple of minutes and you should be good to go.

Now lets make sure that everything is correctly installed.
In the same command prompt just type:
irb
This will launch the ruby interactive console we will be using this a lot, but for now just notice that you prompt changes to a ruby prompt. There type:
require 'watir'
If  you get a "true" response means you are ready to start having fun, anything else ... you are ready to have even more fun!!!



You will need to check your installs again and look for any specific error you migth be getting.

Optionally you should install the Windows Internet Explorer Developer Toolbar

This doesn't really have to do anything with Watir but you will see is a very useful tool for the scripting tasks. we will be getting into that latter.

After you have installed you should be able to find it in the ">>" Icon next to to "Tools"




We will use this tool to get the attributes and properties of the different elements on the web pages to use it you just need to activate the inspector by clicking the "Select Element By Click" icon in the tool bar and then click on any part of the page.

You should see how as you move through the page the different elements are being highlighted by a blue box. If you click any the properties are listed in the Attributes part of the toolbar.





Notice that while the inspector is activated you can't work with the element on the page, click on a button will display its properties not active the action, you can't type in to text box, etc, to do that you need to deactivate the inspector.

And so that's it for this post.
We are good to start writting test and that's what we will be doing in the next wave.

Watir - Wave 0

Hi in this series I'll be talking a little bit about Web Application Testing in Ruby "Watir"
As many of you might or might not know this is a Automating Framework that has been around form a a while now.
The are many reason why you should give it a really take it in to consideration if you are in need of included some automated testing. The most important (at least to me) are:
  • Is Free 
  • Is based on ruby. Which is a extremely powerful and flexible language that allows you to do almost anything you want in very short time
  • Supports multiple browsers
  • Being based on ruby is multi-platform
  • Takes short time to master
In the fallowing post I'll be posting some tutorials that hopefully will help you to create some anything from a simple validations script to a high customized testing framework. 

Stay tuned.