Getting Started with Watir In One Minute Guide

Watir (Web Application Testing in Ruby) is a great functional testing framework for web applications. However, newcomers often have difficulties. If you do, you may find this useful.

Use TestWise RubyShell

TestWise Rubyshell is a pre-packaged Watir software on Windows platform.

  1. Install TextWise RubyShell

    Download latest RubyShell installer, double click rubyshell-1.x.x-setup.exe to install, accept all default options.
    (Default to c:\rubyshell)

  2. Try out: Watir

    You are ready to run Watir scripts. Start a Window command window,

    cd C:\rubyshell\samples\watir
    ruby google_watir.rb
    
  3. Try out: Watir with RSpec + Reports

    Double click C:\rubyshell\samples\watir_rspec\demo.bat

Use RubyInstaller and install Watir manually

  1. Install Ruby

    Install Ruby (recommending v1.8.7) using the one-click installer for Windows.

  2. Install Watir

    Start a Windows command window (if you are unfamiliar with this, you'd better try TestWise IDE)

    gem install watir
    

    If you behind a firewall and need proxy to access Internet,

    gem install -p http://proxy_server:proxy_port watir
    

  3. Create a sample Watir script file

    Open notepad, paste into the text below,

    require 'watir'
    
    browser = Watir::IE.start("http://google.com")
    browser.text_field(:name, "q").set "Watir IDE"
    browser.button(:name, "btnG").click
    
    then save as c:\google_watir.rb
  4. Run Watir script

    Start a Windows command window,

    cd C:\
    ruby c:\google_watir.rb
    
    to run the watir test script you just created, which will start an Internet Explorer window: doing a google search.

Use TestWise IDE

Create, edit, manage and run Watir/RWebSpec test scripts in single tool.

  1. Install TestWise IDE

    Download free TestWise Community Edition installer, double click TestWise-1.x.x-setup.exe to install, accept all default options.

  2. Startup TestWise IDE

    You may launch TestWise after the installation (default)

    Or start up normally

  3. Try it out

    TestWise will load the sample project if it is first time.
    If not, close current project, click menu File -> Open Project, then choose c:\Program File\TestWise\samples\demo-watir\demo-watir.tpr project file.

    Select the file hello_world_watir.rb on the left, the test script will be opened in the editor.

    Right mouse click in the editor, select 'Run Ruby script'

    An Internet Explorer will be started to run the Watir script.