lib/watirspec/watir.rb in watirspec-0.1.5 vs lib/watirspec/watir.rb in watirspec-0.1.6

- old
+ new

@@ -61,9 +61,26 @@ @down_load_time = Time.now - start_load_time run_error_checks sleep @pause_after_wait unless no_sleep @down_load_time end + + # Closes the browser even if #wait throws an exception. + # It happens mostly when #run_error_checks throws some exception. + def close + return unless exists? + @closing = true + @ie.stop + begin + wait + rescue + end + chwnd = @ie.hwnd.to_i + @ie.quit + while Win32API.new("user32", "IsWindow", 'L', 'L').Call(chwnd) == 1 + sleep 0.3 + end + end end module PageContainer #:nodoc:all # patch for .click_no_wait def eval_in_spawned_process(command) \ No newline at end of file