Class: Capybara::Screenshot::Diff::ScreenshotMatcher
- Inherits:
-
Object
- Object
- Capybara::Screenshot::Diff::ScreenshotMatcher
- Defined in:
- lib/capybara/screenshot/diff/screenshot_matcher.rb
Instance Attribute Summary collapse
-
#base_screenshot_path ⇒ Object
readonly
Returns the value of attribute base_screenshot_path.
-
#driver_options ⇒ Object
readonly
Returns the value of attribute driver_options.
-
#screenshot_full_name ⇒ Object
readonly
Returns the value of attribute screenshot_full_name.
-
#screenshot_path ⇒ Object
readonly
Returns the value of attribute screenshot_path.
Class Method Summary collapse
Instance Method Summary collapse
- #build_screenshot_matches_job ⇒ Object
- #cleanup ⇒ Object
-
#initialize(screenshot_full_name, options = {}) ⇒ ScreenshotMatcher
constructor
A new instance of ScreenshotMatcher.
Constructor Details
#initialize(screenshot_full_name, options = {}) ⇒ ScreenshotMatcher
Returns a new instance of ScreenshotMatcher.
14 15 16 17 18 19 20 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 14 def initialize(screenshot_full_name, = {}) @screenshot_full_name = screenshot_full_name @driver_options = Diff..merge() @screenshot_path = Screenshot.screenshot_area_abs / Pathname.new(screenshot_full_name).sub_ext(".png") @base_screenshot_path = ScreenshotMatcher.base_image_path_from(@screenshot_path) end |
Instance Attribute Details
#base_screenshot_path ⇒ Object (readonly)
Returns the value of attribute base_screenshot_path.
12 13 14 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 12 def base_screenshot_path @base_screenshot_path end |
#driver_options ⇒ Object (readonly)
Returns the value of attribute driver_options.
12 13 14 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 12 def @driver_options end |
#screenshot_full_name ⇒ Object (readonly)
Returns the value of attribute screenshot_full_name.
12 13 14 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 12 def screenshot_full_name @screenshot_full_name end |
#screenshot_path ⇒ Object (readonly)
Returns the value of attribute screenshot_path.
12 13 14 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 12 def screenshot_path @screenshot_path end |
Class Method Details
.base_image_path_from(screenshot_path) ⇒ Object
64 65 66 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 64 def self.base_image_path_from(screenshot_path) screenshot_path.sub_ext(".base.png") end |
Instance Method Details
#build_screenshot_matches_job ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 22 def build_screenshot_matches_job # TODO: Move this into screenshot stage, in order to re-evaluate coordinates after page updates return if BrowserHelpers.window_size_is_wrong?(Screenshot.window_size) # Stability Screenshoter Options # TODO: Move this into screenshot stage, in order to re-evaluate coordinates after page updates crop = calculate_crop_region() # Allow nil or single or multiple areas # TODO: Move this into screenshot stage, in order to re-evaluate coordinates after page updates if [:skip_area] # Cast skip area args to Region and makes relative to crop [:skip_area] = calculate_skip_area([:skip_area], crop) end [:driver] = Drivers.for() create_output_directory_for(screenshot_path) unless screenshot_path.exist? checkout_base_screenshot = { crop: crop, stability_time_limit: .delete(:stability_time_limit), wait: .delete(:wait) } take_comparison_screenshot(, , screenshot_path) return unless base_screenshot_path.exist? # Add comparison job in the queue [ screenshot_full_name, ImageCompare.new(screenshot_path.to_s, base_screenshot_path.to_s, ) ] end |
#cleanup ⇒ Object
60 61 62 |
# File 'lib/capybara/screenshot/diff/screenshot_matcher.rb', line 60 def cleanup FileUtils.rm_f(base_screenshot_path) end |