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

Conversation

jubishop
Copy link

@jubishop jubishop commented Dec 5, 2021

I noticed that the bottom of my screenshots were getting cut off...it wasn't expanding quite far enough. When I switched to cuprite, however, it would work and capture the entire viewport properly. I studied the difference and cuprite is using scrollWidth and scrollHeight at https://github.com/rubycdp/ferrum/blob/3253bf1d028945b434ffb8e3d42636342ebf15bc/lib/ferrum/page/screenshot.rb#L66

I noticed that the bottom of my screenshots were getting cut off...it wasn't expanding quite far enough.  When I switched to `cuprite`, however, it would work and capture the entire viewport properly.  I studied the difference and `cuprite` is using `scrollWidth` and `scrollHeight` at https://github.com/rubycdp/ferrum/blob/3253bf1d028945b434ffb8e3d42636342ebf15bc/lib/ferrum/page/screenshot.rb#L66
@jubishop
Copy link
Author

jubishop commented Dec 5, 2021

based on my understanding from articles like https://medium.com/@jbbpatel94/difference-between-offsetheight-clientheight-and-scrollheight-cfea5c196937 this makes sense that it should be scrollHeight..

@jubishop
Copy link
Author

I also noticed adding options[:captureBeyondViewport] = true was necessary to always get the full screenshot. gotten from https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshot

@olleolleolle
Copy link

Been running this a 3-4 months in a big codebase, and it works a charm. Anything else needed for this to be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants