lib/webrat/selenium/selenium_session.rb in diabolo-webrat-0.4.4.2 vs lib/webrat/selenium/selenium_session.rb in diabolo-webrat-0.5.1

- old
+ new

@@ -1,9 +1,12 @@ require "webrat/core/save_and_open_page" require "webrat/selenium/selenium_rc_server" -require "webrat/selenium/application_server" +require "webrat/selenium/application_server_factory" +require "webrat/selenium/application_servers/base" +require "selenium" + module Webrat class TimeoutError < WebratError end class SeleniumResponse @@ -148,12 +151,14 @@ while (Time.now - begin_time) < timeout value = nil begin value = yield - rescue ::Spec::Expectations::ExpectationNotMetError, ::Selenium::CommandError, Webrat::WebratError - value = nil + rescue Exception => e + unless is_ignorable_wait_for_exception?(e) + raise e + end end return value if value sleep 0.25 @@ -180,18 +185,26 @@ if $browser.chrome_backend? $browser.capture_entire_page_screenshot(filename, '') else $browser.capture_screenshot(filename) end - open_in_browser(filename) + open_in_browser(filename) + end - protected + protected + def is_ignorable_wait_for_exception?(exception) #:nodoc: + if defined?(::Spec::Expectations::ExpectationNotMetError) + return true if exception.class == ::Spec::Expectations::ExpectationNotMetError + end + return true if [::Selenium::CommandError, Webrat::WebratError].include?(exception.class) + return false + end def setup #:nodoc: Webrat::Selenium::SeleniumRCServer.boot - Webrat::Selenium::ApplicationServer.boot + Webrat::Selenium::ApplicationServerFactory.app_server_instance.boot create_browser $browser.start extend_selenium @@ -200,10 +213,10 @@ end def create_browser $browser = ::Selenium::Client::Driver.new(Webrat.configuration.selenium_server_address || "localhost", - Webrat.configuration.selenium_server_port, Webrat.configuration.selenium_browser_key, "http://#{Webrat.configuration.application_address}:#{Webrat.configuration.application_port}") + Webrat.configuration.selenium_server_port, Webrat.configuration.selenium_browser_key, "http://#{Webrat.configuration.application_address}:#{Webrat.configuration.application_port}") $browser.set_speed(0) unless Webrat.configuration.selenium_server_address at_exit do silence_stream(STDOUT) do $browser.stop