require '../lib/grid' require 'watir-webdriver-performance' # only if using webdriver_performance ## # Set some parameters before we begin params={} params[:controller_uri] = "druby://ec2-50-16-63-81.compute-1.amazonaws.com:11235" params[:browser] = "chrome" params[:quantity] = 5 ## # Let's instantiate a grid object grid = Grid.new(params) ## # 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(params) 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