Skip to content

Commit 0cf027f

Browse files
committed
Fix getting devicePixelRatio on Chrome 58
1 parent e2e866b commit 0cf027f

File tree

1 file changed

+5
-4
lines changed
  • src/main/java/com/assertthat/selenium_shutterbug/utils/web

1 file changed

+5
-4
lines changed

src/main/java/com/assertthat/selenium_shutterbug/utils/web/Browser.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ public class Browser {
4040
private int docWidth = -1;
4141
private int viewportWidth = -1;
4242
private int viewportHeight = -1;
43-
private int currentScrollX;
44-
private int currentScrollY;
4543
private int scrollTimeout;
46-
private Long devicePixelRatio;
44+
private Double devicePixelRatio = 1.0;
4745

4846
public Browser(WebDriver driver, boolean useDevicePixelRatio) {
4947
this.driver = driver;
50-
devicePixelRatio = useDevicePixelRatio?((Long)executeJsScript(DEVICE_PIXEL_RATIO)):1;
48+
if(useDevicePixelRatio) {
49+
Object devicePixelRatio = executeJsScript(DEVICE_PIXEL_RATIO);
50+
this.devicePixelRatio = devicePixelRatio instanceof Double? (Double)devicePixelRatio: (Long)devicePixelRatio*1.0;
51+
}
5152
}
5253

5354
public static void wait(int milis) {

0 commit comments

Comments
 (0)