class Applitools::Calabash::AndroidScreenshotProvider

Public Instance Methods

capture_screenshot(options = {}) click to toggle source
# File lib/applitools/calabash/calabash_screenshot_provider.rb, line 44
def capture_screenshot(options = {})
  sleep WAIT_BEFORE_SCREENSHOT
  result = nil
  Applitools::Calabash::Utils.using_screenshot(context) do |screenshot_path|
    screenshot = ::ChunkyPNG::Image.from_file(screenshot_path)
    save_debug_screenshot(screenshot, ['original', options[:debug_suffix]])
    viewport_size = Applitools::Calabash::EyesSettings.instance.viewport_size
    screenshot.crop!(0, 0, viewport_size[:width], viewport_size[:height])
    save_debug_screenshot(screenshot, ['cropped', options[:debug_suffix]])
    result = Applitools::Calabash::EyesCalabashAndroidScreenshot.new(
      Applitools::Screenshot.from_image(
        screenshot
      ),
      density: density
    )
  end
  result
end