samnissen / watir-screenshot-stitch

Extends Watir to take full page screenshots of websites.
MIT License
17 stars 7 forks source link

Multiple screenshots when stitched to create a full page screenshot has white spaces in between #24

Closed sandeepnagra closed 6 years ago

sandeepnagra commented 6 years ago

Here's how it looks:

full-page-image.png full-page-image

samnissen commented 6 years ago

That should not happen! Is yours a Retina display? (<-- I'm guessing this is at the heart of our issue.) Which browser/version is this? Can you provide the code? I can't do much more for you without this information.

A workaround

I suggest you switch to using the base64_canvas method until we can resolve this.

About Retina

As I'm guessing our issue is about mis-identifying display resolution, its worth noting: The README says

macOS Retina

watir-screenshot-stitch assumes any user running macOS is displaying at 'Retina' resolution, therefore multiplies all screen resolutions by 2. Any other operating system will not trigger this multiplication.

But that's not technically true -- the gem tries to determine your screen resolution:

def retina?
   payload = %{var mq = window.matchMedia("only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen  and (min-device-pixel-ratio: 1.3), only screen and (min-resolution: 1.3dppx)"); return (mq && mq.matches || (window.devicePixelRatio > 1));}

  @browser.execute_script payload
end

The reasons I have not been more clear in the README are a) an accident (I updated the feature and forgot to update the README) and b) it can get pretty complicated: what happens on which browser/version can affect this, and things get very weird when you drag your window into different monitors.

I will file a bug to update the documentation, but at the moment I'm not entirely sure how to message what happens exactly, or even that my current approach is the best possible.

sandeepnagra commented 6 years ago

You are right @samnissen. The issue was due to multiple monitors. When I disconnect the second monitor and ran the test again, it came out fine.

So, I guess you can add a warning in README that multiple monitors can cause white spacing issue. BTW I am using a MAC and tested over Chrome 65.

full-page-image

samnissen commented 6 years ago

Thanks for raising -- addressing this will be tracked in #25