Sha256: 9d9aaab70c7e01627c00b119a382cb6fed9ad380e118889ba2ddde3151e18da0
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require 'fileutils' require_relative 'image_wrangler' module Gatling class CaptureElement include ImageWrangler def initialize element_to_capture, *element_to_exclude @reference_image_path = Gatling::Configuration.reference_image_path @element_to_capture = element_to_capture # @element_to_exclude = element_to_exclude.first end def capture screenshot = self.take_screenshot screenshot = exclude(screenshot, @element_to_exclude) if @element_to_exclude Gatling::ImageWrangler.crop_element(screenshot, @element_to_capture) end def take_screenshot temp_dir = File.join(@reference_image_path, 'temp') FileUtils.mkdir_p(temp_dir) unless File.exists?(temp_dir) #captures the uncropped full screen begin temp_screenshot_filename = File.join(temp_dir, "temp-#{Process.pid}.png") Capybara.page.driver.browser.save_screenshot(temp_screenshot_filename) temp_screenshot = Magick::Image.read(temp_screenshot_filename).first rescue raise "Could not save screenshot to #{temp_dir}. Please make sure you have permission" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gatling-1.0.9 | lib/gatling/capture_element.rb |