The Watir-WebDriver-Performance gem aims to provide a set of navigation timing metrics for Watir-WebDriver actions using a W3C page performance standard. This is a perfect solution to capture response time metrics, and it’s very straightforward to do but currently only works in Chrome and IE9l, so there’s no Firefox support.
require 'watir-webdriver'
require 'watir-webdriver-performance'
b = Watir::Browser.new :chrome
10.times do
b.goto 'http://watir.com'
load_secs = b.performance.summary[:response_time]/1000
puts "Load Time: #{load_secs} seconds."
end
This produces something like:
Load Time: 3.701 seconds. Load Time: 0.694 seconds. Load Time: 1.874 seconds. Load Time: 1.721 seconds. Load Time: 2.096 seconds. Load Time: 0.823 seconds. Load Time: 2.362 seconds. Load Time: 1.008 seconds. Load Time: 1.761 seconds. Load Time: 2.066 seconds.
List of available metric groupings
- :summary
- :navigation
- :memory
- :timing