Permalink
Browse files

Merge pull request #28264 from y-yagi/do_not_take_screenshot_if_drive…

…r_does_not_support_it

Do not take screenshot if driver does not support screenshot
  • Loading branch information...
eileencodes committed Mar 5, 2017
2 parents 0a7e91a + 2ee4058 commit c21f71c7ef5682be89d94d58bc950e6412850c5d
@@ -22,7 +22,7 @@ def take_screenshot
# 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 @@ def inline_base64(path)
def failed?
!passed? && !skipped?
end
def supports_screenshot?
page.driver.public_methods(false).include?(:save_screenshot)
end
end
end
end
@@ -1,5 +1,6 @@
require "abstract_unit"
require "action_dispatch/system_testing/test_helpers/screenshot_helper"
require "capybara/dsl"
class ScreenshotHelperTest < ActiveSupport::TestCase
test "image path is saved in tmp directory" do
@@ -25,4 +26,28 @@ class ScreenshotHelperTest < ActiveSupport::TestCase
end
end
end
test "rack_test driver does not support screenshot" do
begin
original_driver = Capybara.current_driver
Capybara.current_driver = :rack_test
new_test = ActionDispatch::SystemTestCase.new("x")
assert_not new_test.send(:supports_screenshot?)
ensure
Capybara.current_driver = original_driver
end
end
test "selenium driver supports screenshot" do
begin
original_driver = Capybara.current_driver
Capybara.current_driver = :selenium
new_test = ActionDispatch::SystemTestCase.new("x")
assert new_test.send(:supports_screenshot?)
ensure
Capybara.current_driver = original_driver
end
end
end

0 comments on commit c21f71c

Please sign in to comment.