Skip to content

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

Open
jubishop wants to merge 2 commits intotwalpole:masterfrom
jubishop:master
Open

use scrollWidth and scrollHeight for full page screenshot saves.#87
jubishop wants to merge 2 commits intotwalpole:masterfrom
jubishop:master

Conversation

@jubishop
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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