场景如下:
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
最佳答案
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}"
关于performance - 我想用 Watir 或 Selenium 计算页面加载时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4177070/