samnissen / watir-screenshot-stitch

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

The README is wrong about display resolution detection and macOS #25

Closed samnissen closed 6 years ago

samnissen commented 6 years ago

As mentioned in #24:

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 README should be updated to at least reflect the new detection strategy. Ideally, it would also note the dependence on the CSS selectors of the browser being driven, and note that odd behavior can result when viewports are resized or moved into different monitors.