Thanks Dylan, I have tried the same and it works. /Soori
On Jul 13, 9:53 pm, Dylan <mej...@gmail.com> wrote: > If I'm understanding you right, you want your test to never take more > than 20 seconds, and if the page isn't loaded by then put that in the > log? > > If so, you would need something like "click_no_wait" for "goto" (or > you can justwrite a tiny html file that just has a link to the page > and call click_no_wait on that). I'm not sure how hard that would be > to extend watir to do. Then you can run a while loop (this is > pseudocode): > > start = Time.now > while Time.now - start <= 20 > if ($ie.text.include? "Some text on the page") > Write to log file that page loaded in Time.now-start seconds > end > end > > Write to log file that page did not load within 20 seconds > > Alternatively, you can use a Timeout, which neatly sidesteps the > freeze while a page loads (actual code): > > require 'watir' > require 'timeout' > mylog= File.new( Time.now.strftime("%d-%b-%y") + ".csv",'a') > $ie = Watir::IE.new > ltitle = "" > start = Time.now > begin > Timeout::timeout(20) do > $ie.goto("http://www.localhost") > ltitle = $ie.title > if $ie.text.include?("Home") > stop = Time.now > mylog.puts Time.now.strftime("%I:%M:%S%p").to_s + "," + > "Page Loaded Successfully" + "," + (stop-start).to_s > else > mylog.puts Time.now.strftime("%I:%M:%S%p").to_s + "," + > "Failed to load the URL" + "," + ltitle.to_s > end > end > rescue Timeout::Error > mylog.puts Time.now.strftime("%I:%M:%S%p").to_s + "," + "Taking > more time to respond" + ",20" > rescue => e > mylog.puts Time.now.strftime("%I:%M:%S%p").to_s + "," + "Failed to > load the URL" + "," + ltitle.to_s + "," + e.to_s > end > $ie.close > > Hope that helps! > > On Jul 5, 11:54 pm, Soori <sure...@gmail.com> wrote: > > > Hi All, > > > I would like to monitor the load time of an web page once in a 15 mins > > for 2hrs, i should log in a file if the load time of that web page > > exceeds 20secs, I tried with following code, but sometimes my page > > takes more than 100 secs to load, am getting that message after that > > 100 sec, It would be better if i get the entry on log file immediately > > after exceeding the 20 secs.Please help me in this front. Thanks in > > advance for ur help. > > > require 'watir' > > mylog= File.new( Time.now.strftime("%d-%b-%y") + ".csv",'a') > > $ie=IE.new > > begin > > startTime=Time.now > > $ie.goto('http://localhost/') > > x=Time.now-startTime > > ltitle=$ie.title > > if x > 20 > > mylog.puts Time.now.strftime("%I:%M:%S%p").to_s + "," + "Taking > > more time to respond" + "," + x.to_s > > > elsif $ie.text.include?("Home") > > mylog.puts Time.now.strftime("%I:%M:%S%p").to_s + "," + "Page > > Loaded Successfully" + "," + x.to_s > > else > > mylog.puts Time.now.strftime("%I:%M:%S%p").to_s + "," + "Failed to > > load the URL" + "," + ltitle.to_s > > end > > rescue => e > > mylog.puts Time.now.strftime("%I:%M:%S%p").to_s + "," + "Failed to > > load the URL" + "," + ltitle.to_s + "," + e.to_s > > end > > > /Soori --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---