twalpole / apparition

Capybara driver for Chrome using CDP
MIT License
363 stars 46 forks source link

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

Open jubishop opened 2 years ago

jubishop commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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