Friday, April 9, 2010

Watir: Introduction: What is Watir

Introduction

"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.

Prerequisites

To use the tool, you should have a basic understanding of:
  • HTML: This is a basic HTML tutorial.
  • Programming: You should understand programming basics, including variables and simple control structures like "for" loops and "if" statements.
  • Ruby: You do not need to know how to program in Ruby to get started with Watir, but you should learn some Ruby if you really want to get the most out of Watir
  • Check out the Ruby Cheat Sheet for basic Ruby information.
  • Microsoft has a toolbar for Internet Explorer which can be useful in navigating the DOM for pages that you're looking to automate.

Watir: Install Ruby: How to Installed Ruby ?

  • Log in as administrator.
  • Download the One-Click Ruby Installer for Windows (v.1.8.6-26) from the Ruby One Click Installer Page .
    We recommend using the latest version of Ruby 1.8.6 with Watir 1.6.
    Watir's modal dialog support in Watir 1.5 required Ruby 1.8.2. This is no longer true and this feature now requires Ruby 1.8.6.
  • Run it (leave all choices at the default).
  • You have installed Ruby.
  • Installing Ruby 1.9.1


    Install the lastest 1.9.1 RubyInstaller and development kit from here: http://rubyforge.org/frs/?group_id=167
    (at the time of writing it is this: rubyinstaller-1.9.1-p243-rc1.exe)
    Note: The Ruby path is not set by default but there is an option to set it in the installer
    Type ruby -v in the command line which should return
    ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
    You can have >1 versions of Ruby installed, but the first that is found in the path is used.
    Download 7-zip www.7-zip.org and unzip the devkit to here C:\ruby19