Tuesday, September 11, 2012

Grid Continued...


WatirGrid is Distributed

Built with standard DRb packages. Completely written in Ruby using core libraries.Lets you control Watir objects remotely with transmission passed by reference.

The standard Ruby library ships with a package known as DRb, it means Distributed Ruby. DRb is an incredibly easy package to learn and use. It has the benefits of being written completely in Ruby and using core libraries. It also offers advantages such as automatic selection of object transmission (either pass by value or pass by reference), reasonable speed, and the ability to run on any operating system that runs Ruby. 

WatirGrid is Parallel

WatirGrid uses Threads to execute Watir test cases in parallel (sort of). Threads execute on remote Watir objects, offloading any processing overheads

threads = []
  grid.browsers.each_with_index do |browser, index|
    threads << Thread.new do
      ...
    end
  end
threads.each {|thread| thread.join}


Key Terminology

Controllers implements a repository of tuples (tuple space) that can be accessed concurrently. The controller hosts the ring server which advertises these tuples across a grid network. Typically you will host one controller on a central machine.

Providers make remote Watir objects available to the tuple space hosted by the ring server. 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 or Safari browser object.

Example:

require 'watirgrid'
require 'pp'
# Start a Controller

controller = Controller.new
controller.start
# Start a Provider
provider = Provider.new(:browser_type => 'safari')
provider.start
grid = Watir::Grid.new
grid.start(:take_all => true)
pp grid.browsers.first
# Take the first browser on the grid and execute some Watir
browser = grid.browsers.first[:object].new_browser
browser.goto "http://google.com"
browser.close


No comments:

Post a Comment