-
Notifications
You must be signed in to change notification settings - Fork 102
Make screenshots high dpi aware #116
Make screenshots high dpi aware #116
Conversation
|
👍 |
|
@benurb thanks for the PR. Unfortunately this won't do the trick. |
|
@christian-bromann, which platforms don't support |
|
@TheSavior it might be a good first approach but we need a fallback in case for native app testing where we can't use I first checked mdn which doesn't have any information about support so I thought it is a new thing but apparently it has pretty good support according to caniuse. Ok let's merge this then. |
Make screenshots high dpi aware
|
Hey @christian-bromann Ben |
|
This solution doesn't work for me. When I have width set to 1336px and execute webdrivercss on retina display screenshots are two times smaller 668px. Another problem is calculations. Everything is callculated after resizing but when screenshot is resized units are not proportional. E.g I want to capture header which has 65px height screenshot base width is 1336px because of devicePixelRatio = 2 screenshot is resized to 668px. New height of header should be 32,5px but webdriver is getting 65px, which is wrong value. When I comment this PR everyting seems to be working. |
|
Hey @kierzniak can you please supply a little more info about your setup (Browser, Operating System, Screen)? I'm not able to reproduce your problem on my MacBook Pro 15" Retina (neither Phantom, nor Chrome). Also this PR should not change any image dimensions. It just fixes the problem that only a quarter of the screen is visible on retina (2:1 physical:virtual pixels) screenshots. Note that the image dimensions did not change. The config was: {
name: '_',
x: 0,
y: 0,
width: 100,
height: 100,
screenWidth: [500]
}Also the cropped element looks like on non-retina displays. Regards, |
|
@benurb There is even issue on chromedriver bug tracker: https://bugs.chromium.org/p/chromedriver/issues/detail?id=752 |


Hello!
this PR scales down screenshots taken on high DPI displays (e.g. apple's retina) to their logical dimensions before processing them further. This fixes images cut in half/thirds on this type of display.
The other solution discussed in #52 (multiplying all pixel values with the physical/logical pixel ratio) is probably good, too, but harder to implement. This PR can be a first step as it at least prevents screenshots from being cut in half 😄
Best regards
Ben