lib/puppeteer/page.rb in puppeteer-ruby-0.40.7 vs lib/puppeteer/page.rb in puppeteer-ruby-0.41.0

- old
+ new

@@ -812,10 +812,14 @@ -> (frame) { frame.url == url } else predicate end + frames.each do |frame| + return frame if frame_predicate.call(frame) + end + wait_for_frame_manager_event( FrameManagerEmittedEvents::FrameAttached, FrameManagerEmittedEvents::FrameNavigated, predicate: frame_predicate, timeout: timeout, @@ -1019,19 +1023,29 @@ # @param full_page [Boolean] # @param clip [Hash] # @param quality [Integer] # @param omit_background [Boolean] # @param encoding [String] - def screenshot(type: nil, path: nil, full_page: nil, clip: nil, quality: nil, omit_background: nil, encoding: nil) + def screenshot(type: nil, + path: nil, + full_page: nil, + clip: nil, + quality: nil, + omit_background: nil, + encoding: nil, + capture_beyond_viewport: nil, + from_surface: nil) options = { type: type, path: path, full_page: full_page, clip: clip, quality: quality, omit_background: omit_background, encoding: encoding, + capture_beyond_viewport: capture_beyond_viewport, + from_surface: from_surface, }.compact screenshot_options = ScreenshotOptions.new(options) @screenshot_task_queue.post_task do screenshot_task(screenshot_options.type, screenshot_options) @@ -1056,29 +1070,33 @@ height = metrics['contentSize']['height'].ceil # Overwrite clip for full page at all times. clip = { x: 0, y: 0, width: width, height: height, scale: 1 } - screen_orientation = - if @viewport&.landscape? - { angle: 90, type: 'landscapePrimary' } - else - { angle: 0, type: 'portraitPrimary' } - end - @client.send_message('Emulation.setDeviceMetricsOverride', - mobile: @viewport&.mobile? || false, - width: width, - height: height, - deviceScaleFactor: @viewport&.device_scale_factor || 1, - screenOrientation: screen_orientation) + unless screenshot_options.capture_beyond_viewport? + screen_orientation = + if @viewport&.landscape? + { angle: 90, type: 'landscapePrimary' } + else + { angle: 0, type: 'portraitPrimary' } + end + @client.send_message('Emulation.setDeviceMetricsOverride', + mobile: @viewport&.mobile? || false, + width: width, + height: height, + deviceScaleFactor: @viewport&.device_scale_factor || 1, + screenOrientation: screen_orientation) + end end should_set_default_background = screenshot_options.omit_background? && format == 'png' set_transparent_background_color if should_set_default_background screenshot_params = { format: format, quality: screenshot_options.quality, clip: clip, + captureBeyondViewport: screenshot_options.capture_beyond_viewport?, + fromSurface: screenshot_options.from_surface?, }.compact result = @client.send_message('Page.captureScreenshot', screenshot_params) reset_default_background_color if should_set_default_background if screenshot_options.full_page? && @viewport