[ 
http://jira.openqa.org/browse/WTR-463?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20068#action_20068
 ] 

Alan Baird commented on WTR-463:
--------------------------------

I spent some time playing around with close_all today using Watir 1.7 --pre and 
noticed the following:

1) close_all seems to close every other window.  If I start with 3 windows, it 
closes the 1st and 3rd window opened, but not the 2nd.  If i start with 4 
windows, it closes the 1st and 3rd, but leaves the 2nd and 4th open.  If I have 
6 windows open, well, it follows the same pattern, leaving 3 windows open.  If 
I run the command once more it closes the 1st and 3rd remaining open windows, 
but not the 2nd. 

2) As the comments in close_all suggested, I implemented a while loop to call 
Watir::IE#close like so:

{code}
until Watir::IE.open_ies < 1 do
  Watir::IE.each {|ie| ie.close}
end
{code}
(I'm going from memory here so check my work)  I wrote open_ies to facilitate 
this - it just uses the each method to return a count of the number of open IE 
windows.  This method does pretty well at closing all IE windows.

3) If there are any IE's with a tab open, close_all will wait forever.  I 
imagine that this has something to do with the fact that the wait method 
doesn't know how to deal with tabs.

Note, I'm running all of this on Windows 7 with IE8.

> close_all throws exception in Watir 1.6.7
> -----------------------------------------
>
>                 Key: WTR-463
>                 URL: http://jira.openqa.org/browse/WTR-463
>             Project: Watir
>          Issue Type: Bug
>          Components: Wait
>    Affects Versions: 1.6.7
>         Environment: Windows XP, IE7
>            Reporter: Alan Baird
>            Assignee: Jarmo Pertman
>            Priority: Critical
>             Fix For: Soon
>
>
> Watir::IE.close_all appears to be broken in 1.6.7 (it's possible it's broke 
> in 1.6.6 but I don't think this was changed in 1.6.6).  Consider the 
> following code.  I have addded a line in Watir::Exception.until_with_timeout 
> to record the timeout that is being passed to Wait.until in line 10 of 
> module.rb.  This clearly shows that 0 is being passed to Wait.until.  This 
> causes the unexpected Watir::Wait::TimeoutError.
> {code}
> N:\gauntlet>irb --noreadline
> irb(main):001:0> require 'watir'
> => true
> irb(main):002:0> br = Watir::IE.new
> => #<Watir::IE:0x4108a48 url="about:blank" title="">
> irb(main):003:0> br.close
> => false
> irb(main):004:0> br = Watir::IE.new
> => #<Watir::IE:0x40f6de8 url="about:blank" title="">
> irb(main):005:0> Watir::IE.close_all
> the attach timeout is 0
> Watir::Wait::TimeoutError: timed out after 0 seconds
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.7/lib/watir/wait.rb:23:in 
> `until'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/module.rb:11:in 
> `until_with_timeout'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/modal_dialog.rb:16:in 
> `find_modal_from_window'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/modal_dialog.rb:36:in 
> `locate'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/modal_dialog.rb:86:in 
> `initialize'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/container.rb:188:in `new'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/container.rb:188:in 
> `modal_dialog'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/close_all.rb:29:in 
> `close_modal'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/close_all.rb:16:in 
> `close_all_but'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/ie-class.rb:245:in `each'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/ie-class.rb:240:in `each'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/close_all.rb:15:in 
> `close_all_but'
>         from 
> c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.7/lib/watir/close_all.rb:7:in 
> `close_all'
>         from (irb):5
> irb(main):006:0> puts Watir::IE.attach_timeout
> 2.0
> => nil
> {code}
> The culprit, I believe, is Watir::IE#close_modal: 
> {code}
> # close modal dialog. unlike IE#modal_dialog.close, does not wait for dialog
> # to appear and does not raise exception if no window is found.
> # returns true if modal was found and close, otherwise false
> def close_modal
>   begin
>     original_attach_timeout = IE.attach_timeout
>     IE.attach_timeout = 0
>     self.modal_dialog.close
>     true
>   rescue NoMatchingWindowFoundException, TimeOutException
>     false
>   ensure
>     IE.attach_timeout = original_attach_timeout
>   end
> end
> {code}
> What's weird is that it specifically states in the comment that this should 
> not raise an exception but it clearly is.  The reason is that line 28 in 
> close_all.rb sets the IE.attach_timeout to 0.  I tried commenting out this 
> line but it still raises a Watir::Wait::TimeoutError.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.openqa.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
Wtr-development mailing list
Wtr-development@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-development

Reply via email to