lib/capybara/screenshot/diff/stabilization.rb in capybara-screenshot-diff-0.12.0 vs lib/capybara/screenshot/diff/stabilization.rb in capybara-screenshot-diff-0.12.1

- old
+ new

@@ -25,10 +25,11 @@ screenshot_started_at = last_image_change_at = Time.now loop.with_index do |_x, i| take_right_size_screenshot(comparison) break unless Capybara::Screenshot.stability_time_limit + if comparison.quick_equal? clean_stabilization_images(comparison.new_file_name) break end comparison.reset @@ -61,13 +62,15 @@ private def reduce_retina_image_size(file_name) return if !ON_MAC || !selenium? || !Capybara::Screenshot.window_size + saved_image = ChunkyPNG::Image.from_file(file_name) width = Capybara::Screenshot.window_size[0] return if saved_image.width < width * 2 + unless @_csd_retina_warned warn 'Halving retina screenshot. ' \ 'You should add "force-device-scale-factor=1" to your Chrome chromeOptions args.' @_csd_retina_warned = true end @@ -114,13 +117,15 @@ "#{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 + start = Time.now loop do pending_image = evaluate_script IMAGE_WAIT_SCRIPT break unless pending_image + assert (Time.now - start) < timeout, "Images not loaded after #{timeout}s: #{pending_image.inspect}" sleep 0.1 end end