Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for taking a screenshot with null viewport should be possible #247

Merged
merged 2 commits into from Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppeteer/element_handle.rb
Expand Up @@ -569,7 +569,7 @@ def screenshot(type: nil,
capture_beyond_viewport: capture_beyond_viewport,
from_surface: from_surface)
ensure
if needs_viewport_reset
if needs_viewport_reset && viewport
@page.viewport = viewport
end
end
Expand Down
17 changes: 17 additions & 0 deletions spec/integration/launcher_spec.rb
Expand Up @@ -274,6 +274,23 @@
end
end

it 'should take Element screenshots when defaultViewport is null', sinatra: true do
options = default_launch_options.merge(
default_viewport: nil,
)

Puppeteer.launch(**options) do |browser|
page = browser.new_page
page.goto("#{server_prefix}/grid.html")
page.evaluate('() => window.scrollBy(50, 100)')
element_handle = page.query_selector('.box:nth-of-type(3)')
screenshot = element_handle.screenshot

# FIXME: It would be better to check the height of this screenshot here.
expect(screenshot.size).to be > 100
end
end

it 'should set the debugging port' do
options = default_launch_options.merge(
debugging_port: 9999,
Expand Down