Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
/ watirgrid Public archive

WatirGrid: Web Application Testing in Ruby across a grid network.

License

Notifications You must be signed in to change notification settings

timkoopmans/watirgrid

Repository files navigation

Please Note

This project is no longer actively maintained. Recommend you look at Selenium Grid as an alternative.

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 take a look at Selenium Grid.

ATTENTION Ruby 1.9.x users

Strings are no longer enumerable in Ruby 1.9.2 so you may see errors like this:

NoMethodError: undefined method each' for "192.168.0.134":String
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/rinda/ring.rb:180:inlookup_ring

The Ruby core library for Rinda is broken as it incorrectly uses the each method on a string. Without resorting to monkey patches, you can avoid this error in watirgrid by not using the DRb broadcast methods used in a lookup. This happens when you do not specify a controller URI. To avoid this:

Specify the controller URI if starting a provider from the command line

provider -c druby://203.51.48.187:11235 -d webdriver -b chrome
I, [2011-11-01 20:25:25 #49264]  INFO -- : Provider started on   : druby://203.51.48.187:54289
I, [2011-11-01 20:25:25 #49264]  INFO -- : Controller found on   : druby://203.51.48.187:11235
I, [2011-11-01 20:25:25 #49264]  INFO -- : Provider registered   : druby://203.51.48.187:11235

Specify the controller URI if staring a provider programatically

provider = Provider.new(:driver => 'webdriver', :controller_uri => 'druby://203.51.48.187:11235')

And always specify the controller URI when instantiating your grid!

Watir::Grid.control(:browser_type => 'firefox', :controller_uri => 'druby://127.0.0.1:1234') do |browser, index|
  browser.goto "http://google.com"
  browser.close
end

Starting without a controller URI will probably be deprecated in the next release anyway.

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.

About

WatirGrid: Web Application Testing in Ruby across a grid network.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages