以下是该方案:
1. Login to a web application with username and password and hit Enter (Start timer) 2. Load the login page (lap timer split, to mark the time for page load ) 3. Click on a another page (split the lap timer) 4. Stop the stop watch
答案 0 :(得分:3)
Watir中的任何方法调用都会返回所需的时间,因此这是一项简单的任务。
例如,
b.text_field(:id, 'uid').set username
b.text_field(:id, 'pwd').set password
time1 = b.button(:id, 'logon').click
time2 = b.button(:id, 'movepage').click
puts "Time One: #{time1} Time Two: #{time2} Total Time: #{time1+time2}"
答案 1 :(得分:1)
所有现代浏览器都引入了新规范。目前谷歌Chrome,IE9已内置,Mozilla正在等待应用已提供的补丁。
这个新规范称为WebTimings,我写了一个blog post,展示了如何使用C#访问它。访问它的方法是通过javascript,因此可以与所有语言绑定一起使用。
所需的JavaScript是
var performance = window.performance || window.webkitPerformance || window.mozPerformance window.msPerformance || {};
var timings = performance.timing || {};
return timings;
这会返回一个像这样的字典
/* The dictionary returned will contain something like the following.
* The values are in milliseconds since 1/1/1970
*
* connectEnd: 1280867925716
* connectStart: 1280867925687
* domainLookupEnd: 1280867925687
* domainLookupStart: 1280867925687
* fetchStart: 1280867925685
* legacyNavigationStart: 1280867926028
* loadEventEnd: 1280867926262
* loadEventStart: 1280867926155
* navigationStart: 1280867925685
* redirectEnd: 0
* redirectStart: 0
* requestEnd: 1280867925716
* requestStart: 1280867925716
* responseEnd: 1280867925940
* responseStart: 1280867925919
* unloadEventEnd: 1280867925940
*/