lib/watir-webdriver/window_switching.rb in watir-webdriver-0.3.4 vs lib/watir-webdriver/window_switching.rb in watir-webdriver-0.3.5

- old
+ new

@@ -114,11 +114,11 @@ def locate handle = if @selector.has_key?(:index) @driver.window_handles[Integer(@selector[:index])] else - @driver.window_handles.find { |handle| matches?(handle) } + @driver.window_handles.find { |wh| matches?(wh) } end handle or raise Exception::NoMatchingWindowFoundException, @selector.inspect end @@ -127,9 +127,12 @@ matches_title = @selector[:title].nil? || @selector[:title] === @driver.title matches_url = @selector[:url].nil? || @selector[:url] === @driver.current_url matches_title && matches_url } + rescue Selenium::WebDriver::Error::NoSuchWindowError, Selenium::WebDriver::Error::NoSuchDriverError + # the window may disappear while we're iterating. + false end end # Window end # Watir