korimo / firewatir

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

Firefox.close fails to close window[n] (n > 0) if window[0] has same URL #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Environment:
* Linux Ubuntu 7.10
* Firefox 2.0.x
* firewatir 1.1.1
* Ruby 1.8.6.

What steps will reproduce the problem?
1. have Firefox window [0] open with a URL
2. ff=Firefox.new
   ff.goto(URL) # the same URL as window [0]
   ff.close

What is the expected output? What do you see instead?

Expected results is that a new Firefox window is opened
and is closed after about 2 seconds.

Actual behavior is that a new Firefox window is opened
(which works fine for extracting info), but that window is
not closed with the ff.close call.

Probable Cause:

in file: firewatir.rb ; line 378
                window_number = find_window("url", @window_url)

it finds the first window (window_number == 0), while
that is not the actual window that we want to close. So,
the code (correctly) decides not to close that window 0.

                # If matching window found. Close the window.
                if(window_number > 0)

More complex scenario's are imaginable, where e.g. window[1] is
closed if it has the same URL as window[n] with n > 1 and the
wrong window is closed.

I have applied the patch below to firewatir.rb and tested
successfully in 3scenario's:
1) the (old) window[0] has a different URL open
2) the (old) window[0] has the same URL open
3) the (new) window[n] is destroyed before ff.close is called
(around line 378)
<                 window_number = find_window("url", @window_url)
< 
<                 # If matching window found. Close the window.
<                 if(window_number > 0)
<                     $jssh_socket.send("
getWindows()[#{window_number}].close();\n", 0)

---
>                 $jssh_socket.send("var window_exists =
getWindows()[#{@@current_window}]; window_exists;\n", 0)
>                 answer = read_socket();
>                 # If window is still alive, close the window.
>                 unless answer =~ /ReferenceError/
>                     $jssh_socket.send("
getWindows()[#{@@current_window}].close();\n", 0)

I use the response that starts with "ReferenceError" to detect (hopefully
more reliably) if the window with the reference @@current_window is still
alive or not.

Is there a more formal process available for submitting patches ?

Thanks,

Peter Vandenabeele
(peter AT vandenabeele DOT com)

Original issue reported on code.google.com by peter.va...@gmail.com on 18 Apr 2008 at 3:16

GoogleCodeExporter commented 9 years ago
You can submit the patch to firewatir group and I'll test it here and will 
commit the
changes to SVN.

Original comment by ang...@gmail.com on 21 Apr 2008 at 6:23

GoogleCodeExporter commented 9 years ago
moved to http://jira.openqa.org/browse/WTR-390

Original comment by zeljko.f...@gmail.com on 4 Nov 2009 at 10:28

GoogleCodeExporter commented 9 years ago
Ticket moved to http://jira.openqa.org/browse/WTR. Please see comments for
the exact URL.

Original comment by zeljko.f...@gmail.com on 20 Nov 2009 at 10:39