Ruby Watir Tutorial Site

WATIR is the most remarkable web testing tool out there at the moment. It is used in writing automated test in Test Unit, Cucumber, Rspec…. and the list is growing.

• Its free and open source.
• Its easy to use
• It has a large community so help is easy to find
• Regular updates
• Can be customized to suit your needs

The aim of this site is to give QA analysts information on how to use Watir, create a test framework and make a GUI for their framework. The test framework will be used to run all your watir test cases using Test Unit. Users will be given the basic information required to start automation using Ruby (Watir).

This website is mainly for QA analysts trying to learn Watir and not for developers. As a QA analyst, you do not need to learn the entire ruby language and libraries, just enough to use Watir. As the analyst improves, he/she can then add to their ruby knowledge and start writing more complex codes. Please bookmark us and check back for our regular updates

All Posts:

Ruby connect to SQL database

After searching for hours on how to connect to an SQL database and retrieve information, I decided to put together some useful functions to remind myself in the future. Most tutorials or examples on the web show you how to connect to Mysql databases but not SQL. The important thing to note is that, you … Continue reading Ruby connect to SQL database

Adding and subtracting time

This might be useful to someone. I had a situation where i wanted to calculate the date for exactly 5 months ago from the current time. Here is the code: five_months_time = << 5 five_months_ago  = five_months_time.strftime("%d/%b/%Y")   So using the above code, if the current date and time = 29/09/2011 The code will … Continue reading Adding and subtracting time

Watir wait until

When using watir, sometimes there are pages that dont completely load because ajax or javascript is used to load content on the page. This causes watir not to find content that is on the page because watir checks for the content before javascript has finished loading it. To solve this problem, use the wait_until method: … Continue reading Watir wait until

Watir test unit script template

require 'rubygems' require 'watir' require 'test/unit' class Test_brands < Test::Unit::TestCase     def test_0()          # write your tests here         pageUrl = "http://girfsystest/"         $browser =         $browser.goto(pageUrl)                       end     end Share this:EmailStumbleUponRedditDiggPrint

How to return the location of a text from a table

This is a simple method that returns the table index, the row index and column index where a text is found If you have some tables on a webpage and your script needs to refer to the table, table row or table cell where a certain text occurs, you can use this function. It is … Continue reading How to return the location of a text from a table

Set browser speed in WATIR

This only works with IE The default browser speed for WATIR in IE is fast. You can change this speed to: Slow : This is the slowest speed and you can watch the tests run at a reasonable speed Fast: This is the default speed Zippy: Extra fast, when Watir is typing texts into fields … Continue reading Set browser speed in WATIR

Watir GUI

Here is a video of my Watir GUI which runs off my framework. It requires the framework to output the test results as they pass or fail and also when they are started. There are 2 several parts to it, when you launch the program, it goes to the default test script folder and gets … Continue reading Watir GUI

Watir console color

If you want to print colourful text to the command line with Watir or Ruby, you can do the following: First, you have to install the win32console gem Then you have to require 'Win32/Console/ANSI' in your script Then copy the following methods to your function script or main script def print_red(text) # this prints out … Continue reading Watir console color

Firewatir attach browser

If you want to attach firewatir to an open instance of firefox:         browser = FireWatir::Firefox.attach(:url, pageUrl) Dont forget to require firewatir, and follow the firewatir installation instructions here: Also, you can use a rescue statement like i do in my framework just incase firewatir cannot find an open firefox browser with that … Continue reading Firewatir attach browser

Designing A Watir Framework

The first thing to do when designing a framework is to sort out your folder structure. Have the main script which will call everything else, sit at the top then have folders for: • Test scripts • Function files • Result files • Input files (like test data in xml format) The Functions files will … Continue reading Designing A Watir Framework

My Watir Framework

The belowis a diagramatical illustration of my Watir framework. I will discuss each part individually. The main script is called via the command line and arguments are passed to it when called. These arguments tell the main script: What environment i want to run the scripts on If it should run all the scripts or … Continue reading My Watir Framework

Leave a Reply

Test Automation Tutorials with Ruby and Cucumber by Michael Martins