Sha256: 088636bbcf67287b19a923d6d029b6f4498c0d1ca31cea99e0c8e43d62ef7980

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

require 'grid'
require 'watir-webdriver-performance' # only if using webdriver_performance

##
# Set some parameters before we begin
options={}
options[:controller_uri] = "druby://ec2-50-16-63-81.compute-1.amazonaws.com:11235"
options[:browser] = "chrome"
options[:quantity] = 5

##
# Let's instantiate a grid object
grid = Grid.new(options)

##
# How big is my grid?
puts grid.size

##
# The setup method will prepare the browsers on the grid
grid.setup

##
# Info about providers on the grid
p grid.providers.first[:hostname]
p grid.providers.first[:architecture]

##
# The iterate method can be passed a block of watir code,
# and is yielded a browser object in return
grid.iterate do |browser|
  2.times do # because we want to iterate more than once for each browser
    browser.goto "altentee.com"
    puts browser.title
    # if using webdriver_performance we can get performance metrics
    puts browser.performance.summary[:response_time]
  end
end

##
# The teardown method will close browsers and release nodes back to the grid
grid.teardown

##
# There's also a iterate_with_index method if you want to keep track
# of individual browsers for further reporting and analysis
grid = Grid.new(options)
grid.setup

grid.iterate_with_index do |browser, index|
  puts "I am browser index #{index}"
  browser.goto "watirgrid.com"
  puts browser.performance.summary[:dom_processing]
end

grid.teardown

##
# Finally, here's a shorthand control method to do the setup, iteration and teardown
# in one foul swoop!

params[:rampup] = 10 #seconds, optional rampup period for all the browsers
Grid.control(params) do |browser, index|
  puts "I am browser index #{index}"
  browser.goto "gridinit.com"
  puts browser.performance.summary[:time_to_first_byte]
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grid-0.4.3 examples/basic/basic.rb
grid-0.4.2 examples/basic/basic.rb