vendor/gems/gems/firewatir-1.2.1/firewatir.rb
#
# Description:
#   Waits for the page to get loaded.
#

Waits for the page to get loaded.
Waits for the page to get loaded .
def wait(last_url = nil)
            isLoadingDocument = ""
            start = Time.now
            while isLoadingDocument != "false"
                isLoadingDocument = js_eval("#{BROWSER_VAR}=#{WINDOW_VAR}.getBrowser(); #{BROWSER_VAR}.webProgress.isLoadingDocument;")
                 if (Time.now - start) > 300
                    raise "Page Load Timeout"
                end
            end
            $jssh_socket.send("#{BROWSER_VAR}.contentDocument.URL;\n", 0)
            url = read_socket()
            if(url != last_url)
                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;"
                jssh_command = jssh_command.gsub(/\n/, "")
                $jssh_socket.send("#{jssh_command}; \n", 0)
                wait_time = read_socket();
                begin
                    wait_time = wait_time.to_i
                    if(wait_time != -1)
                        sleep(wait_time)
                        $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
def wait ( last_url = nil ) isLoadingDocument = "" start = Time . now while isLoadingDocument != "false" isLoadingDocument = js_eval ( "#{BROWSER_VAR}=#{WINDOW_VAR}.getBrowser(); #{BROWSER_VAR}.webProgress.isLoadingDocument;" ) if ( Time . now - start ) > 300 raise "Page Load Timeout" end end $jssh_socket . send ( "#{BROWSER_VAR}.contentDocument.URL;\n" , 0 ) url = read_socket ( ) if ( url != last_url ) 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;" jssh_command = jssh_command . gsub ( / \n / , "" ) $jssh_socket . send ( "#{jssh_command}; \n" , 0 ) wait_time = read_socket ( ) ; begin wait_time = wait_time . to_i if ( wait_time != - 1 ) sleep ( wait_time ) $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
Description:
Waits for the page to get loaded.
Description : Waits for the page to get loaded .
#puts "In wait function "
 #puts "Is browser still loading page: #{isLoadingDocument}"
 # Derek Berner 5/16/08
 # Raise an exception if the page fails to load
 # 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.
 # 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.
 #puts "command in wait is : #{jssh_command}"                
 #puts "wait time is : #{wait_time}"
 # Call wait again. In case there are multiple redirects.

last_url
<not_specific>