WatirGrid

WatirGrid allows for distributed testing across a grid network using Watir.

Getting Started

To install WatirGrid:

gem install watirgrid

The Basics

WatirGrid allows a local client to control remote Watir objects in parallel, hosted by providers on a grid network, via a central controller.

Key Terminology

The controller implements a repository of tuples (tuple space) that can be accessed concurrently. The controller also hosts a ring server which advertises these tuples across a grid network making it loosely coupled.

Typically you will host one controller on a central machine. You will normally connect to this controller via a contoller_uri. You can also find this controller by its ring server, using a UDP broadcast for the ring server port.

The providers make remote Watir objects available to the tuple space hosted by the controller. Typically you will host one or many providers on your grid network, for example, each PC may become a single provider of a Watir tuple in the form of an Internet Explorer, Firefox, Safari or WebDriver browser object.

WatirGrid IS

  • A lightweight, pure Ruby implementation of distributed computing using DRb and Rinda.

  • A simple way to control remote Watir objects in parallel.

  • Cross platform friendly and works on Windows, OSX or Linux.

  • Open source, you’re already looking in the right place if you want the source code.

  • WebDriver friendly, thanks to the wire protocol, WatirGrid happily runs with WebDriver implementations such as watir-webdriver and selenium-webdriver.

WatirGrid IS NOT

  • A “grid management” system. If you’re looking to control individual resources, such as starting and stopping workstations or VMs you should look at the commercial implementation at Gridinit.com

  • Selenium Grid. If you’re looking for a full blown implementation of distributed computing you should take a look at Selenium Grid

Simple Example

Pick a server to host the controller for the ring server and execute the following:

$ controller

This should find your external facing IP and start the controller:

I, [2011-04-09 18:06:19 #1971]  INFO -- : Controller started on : druby://127.0.0.1:11235

On each remote machine, host the provider for the distributed (DRb) Watir object:

$  provider -d watir -c druby://127.0.0.1:11235

This should find the recently started controller and register the provider:

I, [2011-04-09 18:06:26 #1972]  INFO -- : Provider started on   : druby://127.0.0.1:11236
I, [2011-04-09 18:06:26 #1972]  INFO -- : Controller found on   : druby://127.0.0.1:11235
I, [2011-04-09 18:06:26 #1972]  INFO -- : Provider registered   : druby://127.0.0.1:11235

You will now be able to execute commands across remote browsers on your grid network.

e.g.

require 'watirgrid'
Watir::Grid.control(:controller_uri => 'druby://127.0.0.1:11235') do |browser, id|
  puts "My remote browser id is #{id}"
  browser.goto("http://www.google.com")
  browser.text_field(:name, 'q').set("watirgrid")
  browser.button(:name, "btnI").click
end

You may wish to host the controller and providers on different machines in a real scenario. You can specify things like server hostnames, ports and access control lists for each of the different types of servers. For more help see:

$  controller --help
Usage: controller [options]
Advanced Options:
    -h, --drb HOST                   Specify the DRb host for this controller to bind to.
    -p, --drb-port PORT              Specify the DRb port for this controller to listen on.
    -H, --ring-server HOST           Specify the ring server host for this controller to bind to.
    -P, --ring-server-port PORT      Specify the ring server port for this controller to listen on.
    -a, --access-control-list ACL    Specify a comma separated Access Control List
    -l, --log LEVEL                  Specify the logging level:
                                       - DEBUG
                                       - INFO
                                       - ERROR
        --help                       Show this message
$  provider --help
Usage: provider -d DRIVER [options]
Basic Options:
    -d, --driver TYPE                Specify driver type to use on this provider:
                                       - watir
                                       - webdriver
                                       - selenium
                                       - firewatir
                                       - safariwatir
    -c, --controller URI             Specify the controller URI to register this provider on e.g.:
                                       - druby://127.0.0.1:11235
    -b, --browser TYPE               Specify the browser type to start when using webdriver or selenium:
                                       - firefox
                                       - chrome
                                       - ie
Advanced Options:
    -h, --drb HOST                   Specify the DRb host for this provider to bind to.
    -p, --drb-port PORT              Specify the DRb port for this provider to listen on.
    -H, --ring-server HOST           Optionally specify the ring server host if not using controller URI.
    -P, --ring-server-port PORT      Optionally specify the ring server port if not using controller URI.
    -a, --access-control-list ACL    Specify a comma separated Access Control List
    -l, --log LEVEL                  Specify the logging level:
                                       - DEBUG
                                       - INFO
                                       - ERROR
        --help                       Show this message

Copyright © 2009-2011 Tim Koopmans. See LICENSE for details.