From 2ee4058cc5c9327ddc5bfecc05e625320dd166a1 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Wed, 1 Mar 2017 07:54:28 +0900 Subject: Do not take screenshot if driver does not support screenshot `Capybara::RackTest::Driver` does not support taking screenshots. If call `#save_screenshot` on `Capybara::RackTest::Driver` will raise the error. ```ruby Error: UsersTest#test_visiting_the_index: Capybara::NotSupportedByDriverError: Capybara::Driver::Base#save_screenshot ``` To prevent errors, if driver does not support screenshot, do not call it. --- .../system_testing/test_helpers/screenshot_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb index ddc961cf84..e37f6d02aa 100644 --- a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +++ b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb @@ -22,7 +22,7 @@ module ActionDispatch # fails add +take_failed_screenshot+ to the teardown block before clearing # sessions. def take_failed_screenshot - take_screenshot if failed? + take_screenshot if failed? && supports_screenshot? end private @@ -55,6 +55,10 @@ module ActionDispatch def failed? !passed? && !skipped? end + + def supports_screenshot? + page.driver.public_methods(false).include?(:save_screenshot) + end end end end -- cgit v1.2.3