[ http://jira.openqa.org/browse/WTR-463?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20074#action_20074 ]
Jarmo Pertman commented on WTR-463: ----------------------------------- I guess i managed to fix it now. The problem is probably that IE windows were closed during the iteration. I guess that closing the window altered the state of the shell.Windows collection itself. It is not recommended and quite often doesn't work when you're modifying the collection while you're iterating over it. Ruby's #each and `for` seem to work okay, but i guess this #each on win32ole doesn't. So for example if i had 5 windows opened then only few of them were iterated over (2 if i remember correctly). Now it closes all the windows. This is the commit: https://github.com/bret/watir/commit/ca7d0ec78ad80d44b57c11fa4ad72d2bc09d2e37 I also fixed the problem where IE with open tabs didn't close. It seems that when IE has multiple tabs opened then the handle to the window is the same and #close waited as long as the window with the specified handle doesn't exist, which doesn't ever happen when tabs are involved. This is the commit: https://github.com/bret/watir/commit/69ebad80835421a90d3b198fc377f8e4c84b7bf4 Could you please apply these changes locally to your 1.7.0.rc1 and check if it works for you too. > 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