1

如何使用 watir-webdriver-performance 获取 Ajax 性能数据?

当我使用下面的脚本时,我在触发 Ajax 请求后得到了相同的结果。

require 'rubygems'
gem "selenium-webdriver"
require 'watir-webdriver'
require 'watir-webdriver-performance'

Selenium::WebDriver::Chrome.path = chromePath
b = Watir::Browser.new :chrome

b.goto 'Ajax Website'
p b.performance.summary

# click some ajax button to trigger server request 
p b.performance.summary

# click some ajax button to trigger server request 
p b.performance.summary

b.close

输出

{:time_to_first_byte=>396, :request=>395, :tcp_connection=>0, :app_cache=>0, :time_to_last_byte=>405, :redirect=>679, :response=>9, :dns=>0, :response_time=>6134, :dom_processing=>4041}

{:time_to_first_byte=>449, :request=>446, :tcp_connection=>0, :app_cache=>0, :time_to_last_byte=>458, :redirect=>2320, :response=>9, :dns=>0, :response_time=>3751, :dom_processing=>946}

{:time_to_first_byte=>449, :request=>446, :tcp_connection=>0, :app_cache=>0, :time_to_last_byte=>458, :redirect=>2320, :response=>9, :dns=>0, :response_time=>3751, :dom_processing=>946}
4

0 回答 0