korimo / firewatir

Automatically exported from code.google.com/p/firewatir
0 stars 0 forks source link

Add time out in firewatir.rb wait() method, so that it will not hangup #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
$br.goto a_new_url some times hangup.
It happens once for every 1000 pages, I think.  But each time it happens,
it hang up the listening portion of Firewatir.

What is the expected output? What do you see instead?
The browser should go to a new URL, but it hangup.
In this particular ocacion, the browser hangup for 8 hours, receiving
millions of lines of messages in read_socket():

latest data length is: 4, content is: true
latest data length is: 4, content is: true
latest data length is: 4, content is: true
latest data length is: 4, content is: true
latest data length is: 4, content is: true
latest data length is: 4, content is: true
latest data length is: 4, content is: true
latest data length is: 4, content is: true
latest data length is: 4, content is: true
latest data length is: 4, content is: true

Then it wake up, because of server's cookie expiredn in 8 hours.

So there are some strange behaviors of Jssh, and also how the Firewatir
interprete the received data in the stream.

What version of the product are you using? On what operating system?
Firewatir 1.1.1

Please provide any additional information below.

Proposed fix is to add a timeout counter in firewatir.rb's wait() method:

        #
        # Description:
        #   Waits for the page to get loaded.
        #
        def wait()
            #puts "In wait function "
            isLoadingDocument = ""

            # add timeout - andrew chen
            # time out at max_wait_minute for a page load
            # if more than the max time, just give up
            max_wait_minute = 3
            sleep_time = 0.1
            wait_count = max_wait_minute * 60.0 / sleep_time
            counter = 0
            while isLoadingDocument != "false"

$jssh_socket.send("#{BROWSER_VAR}=#{WINDOW_VAR}.getBrowser();
#{BROWSER_VAR}.webProgress.isLoadingDocument;\n" , 0)
                isLoadingDocument = read_socket()
                #puts "Is browser still loading page: #{isLoadingDocument}"
                sleep 0.05
                counter += 1
                # give up if certain time is passed
                if counter > wait_count
                  puts "Tried #{max_wait_minute} minutes, Firewatir give up
this action"
                  break
                end
            end

            # Check for Javascript redirect. As we are connected to Firefox
via JSSh. JSSh

For specific test cases, you can email chen at foreopen.com

~Andrew Chen

Original issue reported on code.google.com by hang...@gmail.com on 8 Jul 2008 at 4:36

GoogleCodeExporter commented 9 years ago

Original comment by ang...@gmail.com on 29 Jul 2008 at 9:23