Module: ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
- Included in:
- ActionDispatch::SystemTestCase
- Defined in:
- lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
Overview
Screenshot helper for system testing
Instance Method Summary collapse
-
#take_failed_screenshot ⇒ Object
Takes a screenshot of the current page in the browser if the test failed.
-
#take_screenshot ⇒ Object
Takes a screenshot of the current page in the browser.
Instance Method Details
#take_failed_screenshot ⇒ Object
Takes a screenshot of the current page in the browser if the test failed.
take_failed_screenshot
is included in application_system_test_case.rb
that is generated with the application. To take screenshots when a test fails add take_failed_screenshot
to the teardown block before clearing sessions.
35 36 37 |
# File 'lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb', line 35 def take_failed_screenshot take_screenshot if failed? && supports_screenshot? end |
#take_screenshot ⇒ Object
Takes a screenshot of the current page in the browser.
take_screenshot
can be used at any point in your system tests to take a screenshot of the current state. This can be useful for debugging or automating visual testing.
The screenshot will be displayed in your console, if supported.
You can set the RAILS_SYSTEM_TESTING_SCREENSHOT
environment variable to control the output. Possible values are:
inline
(default)-
display the screenshot in the terminal using the iTerm image protocol (iterm2.com/documentation-images.html).
simple
-
only display the screenshot path. This is the default value if the
CI
environment variables is defined.
artifact
-
display the screenshot in the terminal, using the terminal artifact format (buildkite.github.io/terminal/inline-images/).
23 24 25 26 |
# File 'lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb', line 23 def take_screenshot save_image puts display_image end |