lib/capybara/screenshot/diff/stabilization.rb in capybara-screenshot-diff-0.14.0 vs lib/capybara/screenshot/diff/stabilization.rb in capybara-screenshot-diff-0.14.1
- old
+ new
@@ -47,11 +47,11 @@
next
else
last_image_change_at = Time.now
end
- check_max_wait_time(comparison, screenshot_started_at)
+ check_max_wait_time(comparison, screenshot_started_at, shift_distance_limit: shift_distance_limit)
end
previous_file_name = "#{comparison.new_file_name.chomp('.png')}_x#{format('%02i', i)}.png~"
FileUtils.mv comparison.new_file_name, previous_file_name
@@ -110,12 +110,14 @@
# TODO(uwe): Remove when chromedriver takes right size screenshots
reduce_retina_image_size(comparison.new_file_name)
# ODOT
end
- def check_max_wait_time(comparison, screenshot_started_at)
- assert (Time.now - screenshot_started_at) < Capybara.default_max_wait_time,
- "Could not get stable screenshot within #{Capybara.default_max_wait_time}s\n" \
+ def check_max_wait_time(comparison, screenshot_started_at, shift_distance_limit:)
+ shift_factor = shift_distance_limit ? (shift_distance_limit * 2 + 1) ^ 2 : 1
+ max_wait_time = Capybara.default_max_wait_time * shift_factor
+ assert (Time.now - screenshot_started_at) < max_wait_time,
+ "Could not get stable screenshot within #{max_wait_time}s\n" \
"#{stabilization_images(comparison.new_file_name).join("\n")}"
end
def assert_images_loaded(timeout: Capybara.default_max_wait_time)
return unless respond_to? :evaluate_script