Hi Maumita, I had problems with pages comming back as "loaded" even though were still loading and so i changed the wait method slightly and it works fine now.
def wait(last_url = nil) #puts "In wait function " isLoadingDocument = "" start = Time.now while isLoadingDocument != "0" # puts "WWWW #{BROWSER_VAR}=#{WINDOW_VAR}.getBrowser(); # {BROWSER_VAR}.selectedBrowser.webProgress.busyFlags" isLoadingDocument = js_eval("#{BROWSER_VAR}=# {WINDOW_VAR}.getBrowser(); # {BROWSER_VAR}.selectedBrowser.webProgress.busyFlags") # isLoadingDocument = js_eval("#{BROWSER_VAR}=# {WINDOW_VAR}.getBrowser(); # {BROWSER_VAR}.webProgress.isLoadingDocument;") # puts "Is browser still loading page: #{isLoadingDocument}" #puts "Is browser still loading page: #{isLoadingDocument}" sleep(0.25) # Derek Berner 5/16/08 # Raise an exception if the page fails to load if (Time.now - start) > 300 raise "Page Load Timeout" end end # Derek Berner 5/16/08 # If the redirect is to a download attachment that does not reload this page, this # method will loop forever. Therefore, we need to ensure that if this method is called # twice with the same URL, we simply accept that we're done. $jssh_socket.send("#{BROWSER_VAR}.contentDocument.URL;\n", 0) url = read_socket() if(url != last_url) # Check for Javascript redirect. As we are connected to Firefox via JSSh. JSSh # doesn't detect any javascript redirects so check it here. # If page redirects to itself that this code will enter in infinite loop. # So we currently don't wait for such a page. # wait variable in JSSh tells if we should wait more for the page to get loaded # or continue. -1 means page is not redirected. Anyother positive values means wait. jssh_command = "var wait = -1; var meta = null; meta = # {BROWSER_VAR}.contentDocument.getElementsByTagName('meta'); if(meta != null) { var doc_url = # {BROWSER_VAR}.contentDocument.URL; for(var i=0; i< meta.length;++i) { var content = meta[i].content; var regex = new RegExp(\"^refresh$\", \"i\"); if(regex.test(meta[i].httpEquiv)) { var arrContent = content.split(';'); var redirect_url = null; if(arrContent.length > 0) { if(arrContent.length > 1) redirect_url = arrContent[1]; if(redirect_url != null) { regex = new RegExp(\"^.*\" + redirect_url + \"$\"); if(!regex.test(doc_url)) { wait = arrContent[0]; } } break; } } } } wait;" #puts "command in wait is : #{jssh_command}" jssh_command = jssh_command.gsub(/\n/, "") $jssh_socket.send("#{jssh_command}; \n", 0) wait_time = read_socket(); #puts "wait time is : #{wait_time}" begin wait_time = wait_time.to_i if(wait_time != -1) sleep(wait_time) # Call wait again. In case there are multiple redirects. $jssh_socket.send("#{BROWSER_VAR} = # {WINDOW_VAR}.getBrowser(); \n",0) read_socket() wait(url) end rescue end end set_browser_document() run_error_checks() return self end On 28 Mai, 14:36, Maumita <maumita.majum...@gmail.com> wrote: > Hi, > > Iam new in Watir. We are designing a web site through which user can > buy items like we have in AMAZON. > > I have written a script to capture the landing page load response > timing (see below) > > require 'watir' # watir controller > include Watir > require 'test/unit' > #require 'watir/WindowHelper' > > class TC_TimeResponse < Test::Unit::TestCase > > def test_TimeResponse > ie = Watir::IE.new > ie.goto("URL") > ie.text_field(:name, 'userName').set('') > ie.text_field(:name, 'password').set('') > ie.button(:value, 'Login').click > ie.maximize > ie.image(:src, /logo/).click > p 'ie.down_load_time_Home Page for 85: > '+ie.down_load_time.to_s > end > end > > This script works fine and it displayed the page load timing in > console. > > Basically, the landing page contains information about 9 items along > with their image of fixed size 79 * 79. > I observed that sometime the script runs and displayed the result of > page load timing but few of the images is still not loaded. > > My question:- > 1. How I can verify whether all the images have been loaded or not? > 2. Is there any other way to find out the actual page load timing > including the images of the items. > > Please this is an urgent requirement for my project. > Waiting for solution. > > Thanks > Maumita --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---