Sha256: f5fba98457fc415e2df566bdf923a89abd628714e1343e8187a19b4ba258358a

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "WatirWebdriverPerformance" do

  let!(:b) { @b }

  before(:all) do
    @b ||= Watir::Browser.new :chrome
  end

  after(:all) do
    @b.close
  end

  it "should open get performance metrics from the browser" do
    b.goto "google.com"
    b.performance.should be_an_instance_of(OpenStruct)
  end

  it "should get summary data from the performance metrics" do
    # Summary metrics based on Processing Model of NavigationTiming
    # http://w3c-test.org/webperf/specs/NavigationTiming/#processing-model
    b.performance.summary.should include(:app_cache)
    b.performance.summary.should include(:dns)
    b.performance.summary.should include(:tcp_connection)
    b.performance.summary.should include(:request)
    b.performance.summary.should include(:response)
    b.performance.summary.should include(:dom_processing)
  end

   it "should get summary data from the performance metrics for redirects" do
    b.goto "http://watirgrid.com"
    b.performance.summary.should include(:redirect)
  end

   it "should get summary data from the performance metrics for secure connections" do
    b.performance.summary.should include(:tcp_connection_secure)
  end

  it "should get the summary metrics such as Response Time, TTLB and TTFB" do
    b.performance.summary.should include(:time_to_first_byte) # aka "server time"
    b.performance.summary.should include(:time_to_last_byte) # aka "network + server time"
    b.performance.summary.should include(:response_time)
    puts "Page took #{b.performance.summary[:response_time]/1000} seconds to load"
  end

  it "should return true for chrome supported" do
    b.goto "google.com"
    b.should be_performance_supported
  end

  it "should support performance as block" do
    b.goto "google.com"
    b.with_performance {|performance| performance.should_not be_nil }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-webdriver-performance-0.1.3 spec/watir-webdriver-performance_spec.rb