“Watir” (pronounced water) stands for “Web Application Testing in Ruby”. Watir is an automated test tool which uses the Ruby scripting language to drive the Internet Explorer web browser. Watir is a toolkit for automated tests to be developed and run against a web browser.

What Does Watir Work With?

Watir will drive web applications that are served up as HTML pages in a web browser. Watir will not work with ActiveX plugin components, Java Applets, Macromedia Flash, or other plugin applications. To determine whether Watir can be used to automate a part of a web application, right click on the object and see if the View Source menu option is available. If you can view the HTML source, that object can be automated using Watir.

Installation Softwares :

1. Ruby 1.8.4 (available free download)

2. Watir (After installation of Ruby got command prompt c:\gem install watir)

Developing Test Cases

The goal of this user guide is to help you get started writing test cases quickly. Each section below describes the methods for driving a web application. Select the ones you need for each page of your web application based on the content of each page in the application.

Plan what you need to get Watir to do before you begin scripting. Open your web browser with the application under test in front of you, and pay close attention to the objects on that page. What text fields require entries? What buttons need to be pushed? What links need to be clicked on? It sometimes helps to write out the steps it will take to exercise a test first, and then filling in the Watir scripting code to satisfy each of those steps.

It is a good idea to view the source of the page (in Internet Explorer, right click and select View Source) and get an idea of what the attributes of the objects you need to interact with are. For example, on the Google home page, if you search the source for “Google Search”, you will find the tag with the following attributes: <input type=submit value=”Google Search” name=btnG> The “type” attribute “submit” tells us that it is a button, the caption or value that you see on the button is “Google Search”, and the name of the button is “btnG”. Watir can use different attributes of a tag to manipulate that object, so it is important to know what they are. In some cases the attributes are not explicit in the tag such as the “text” attributes.

To start developing a test:

  1. Open your text editor.
  2. Name your test file with a .rb (Ruby) extension.
  3. Provide your new test file with access to the Watir tool by entering this statement at the beginning of your test script: require ‘watir’
  4. Open Internet Explorer and navigate to the application you wish to test
  5. Interact with it to design your test case
  6. Using the Watir methods below, type the corresponding Watir methods into your test script
  7. Verify the results

Watir syntax:

#Enable Instant Forward to Voice Mail
require ‘watir’
include Watir

ie = IE.new
ie.goto( ‘http://www.vonage.com/&#8217; )

ie.text_field( :name, ‘username’ ).set( ‘username’ )
ie.text_field( :name, ‘password’ ).set( ‘password’ )
ie.button( :name, ‘submit’ ).click


ie.button( :name, ‘callForwardingButton’ ).click

ie.select_list( :name, ‘callForwardingSeconds’ ).select( ‘Instantly’ )
ie.text_field( :name, ‘singleAddress’ ).set( ‘15035551234’ )


ie.link(:text,”Log Out”).click


Do U have any queries about this blog then send ur feed back to this mail id : jazzezravi@gmail.com


One thought on “Watir

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s