module ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper

def take_screenshot

artifact format (https://buildkite.github.io/terminal-to-html/inline-images/).
* [+artifact+] Display the screenshot in the terminal, using the terminal
iTerm image protocol (https://iterm2.com/documentation-images.html).
* [+inline+] Display the screenshot in the terminal using the
This is the default value.
* [+simple+ (default)] Only displays the screenshot path.
control the output. Possible values are:
You can set the +RAILS_SYSTEM_TESTING_SCREENSHOT+ environment variable to

elements on the page at the time of the screenshot
save the HTML from the page that is being screenshotted so you can investigate the
You can set the +RAILS_SYSTEM_TESTING_SCREENSHOT_HTML+ environment variable to

one with +Capybara.save_path+
The default screenshots directory is +tmp/screenshots+ but you can set a different

The screenshot will be displayed in your console, if supported.

named with a sequential prefix (or 'failed' for failing tests)
to investigate changes at different points during your test. These will be
automating visual testing. You can take multiple screenshots per test
a screenshot of the current state. This can be useful for debugging or
+take_screenshot+ can be used at any point in your system tests to take

Takes a screenshot of the current page in the browser.
def take_screenshot
  increment_unique
  save_html if save_html?
  save_image
  puts display_image
end