From: Gordon Thiesfeld Date: 2010-12-23T15:54:44+09:00 Subject: Re: how to know a search result is successfully displayed through its source codes On Thu, Dec 23, 2010 at 12:11 AM, Fan Jin wrote: > Gordon Thiesfeld wrote in post #970057: >> On Tue, Dec 21, 2010 at 8:02 PM, Fan Jin wrote: >>> Jeremy Bopp wrote in post #969808: >>> >>> Yes, the library I am using here is watir, but the two times which I >>> caught from click and result return are properly not right, they are >>> identical even the interface's response time is longer than 2s. >>> The method I used here was ping the HTTP server, once the result was >>> returned, the happened time was caught. >>> Need your more help, thanks :> >>> >> >> If you post some code, folks might be better able to help you. > > The codes I wrote was following: >  #set a key word in search field, then click the search button. >  browser.text_field(:id, 'simpleSearchInput').set('test') >  browser.link(:id,'simpleSearchSubmit').click >  t1 = Time.now # get the time when button is clicked. >  Watir::Wait.until{browser.div(:id, 'srpWrapper').exists?}#wait until > the search result list is loaded, here I used div(:id) to ensure that > result is finish loading. >  t2 = Time.now # give the time t2. >  t = t2 - t1 # This is the system responding time. >  puts "the system response time is: " + t.to_s > > Although the codes run well, the time it returns is almost > the same. I think there is a method in watir which can get the time of > response directly after a new webpage was loaded. Need folks help.Thanks > > Jin Fan > > -- > Posted via http://www.ruby-forum.com/. > > Some resources for you: http://stackoverflow.com/questions/4177070/i-want-to-calculate-the-page-load-time-in-watir-or-selenium http://wiki.openqa.org/display/WTR/How+to+wait+with+Watir The click method waits for the page to load. That's why you're not seeing any time difference between t1 and t2. The page is already loaded, so Watcher::Wait.until returns immediately. Also, the click method returns the load time, so you could write it like this: browser.text_field(:id, 'simpleSearchInput').set('test') t = browser.link(:id,'simpleSearchSubmit').click puts "the system response time is: #{t.to_s}"