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

use scrollWidth and scrollHeight for full page screenshot saves. #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/capybara/apparition/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,15 @@ def render(options)
%w[x y width height].each_with_object({}) { |key, hash| hash[key] = pos[key] }
elsif options[:full]
evaluate <<~JS
{ width: document.documentElement.clientWidth, height: document.documentElement.clientHeight}
{ width: document.documentElement.scrollWidth, height: document.documentElement.scrollHeight}
JS
else
evaluate <<~JS
{ width: window.innerWidth, height: window.innerHeight }
JS
end
options[:clip] = { x: 0, y: 0, scale: scale }.merge(clip_options)
options[:captureBeyondViewport] = true
command('Page.captureScreenshot', **options)
end['data']
end
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def session_url(path)

create_screenshot file, full: true
expect(FastImage.size(file)).to eq(
@driver.evaluate_script('[document.documentElement.clientWidth, document.documentElement.clientHeight]')
@driver.evaluate_script('[document.documentElement.scrollWidth, document.documentElement.scrollHeight]')
)
end

Expand Down Expand Up @@ -203,7 +203,7 @@ def session_url(path)
create_screenshot file, full: true, selector: '#penultimate'

expect(FastImage.size(file)).to eq(
@driver.evaluate_script('[document.documentElement.clientWidth, document.documentElement.clientHeight]')
@driver.evaluate_script('[document.documentElement.scrollWidth, document.documentElement.scrollHeight]')
)
end

Expand Down