Skip to content

Commit 1d38f55

Browse files
author
Denys Zaiats
committed
[master] - hot fix for getting resolution
1 parent 2a12cfa commit 1d38f55

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/main/java/net/itarray/automotion/internal/DriverFacade.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,25 @@ private String getZoomScript() {
9898
}
9999

100100
private long retrievePageHeight() {
101-
if (!isAppiumAndroidContext()) {
101+
if (!isAppiumContext()) {
102102
if (getZoom().equals("100%")) {
103-
return (long) executeScript("if (self.outerHeight) {return self.outerHeight;} if (document.documentElement && document.documentElement.clientHeight) {return document.documentElement.clientHeight;}if (document.body) {return document.body.clientHeight;}");
103+
return (long) executeScript("if (window.innerHeight) {return window.innerHeight;} if (document.documentElement && document.documentElement.clientHeight) {return document.documentElement.clientHeight;}if (document.body) {return document.body.clientHeight;}");
104104
} else {
105105
return (long) executeScript("return document.getElementsByTagName('body')[0].offsetHeight");
106106
}
107107
} else {
108108
if (isAppiumNativeMobileContext() || isAppiumIOSContext()) {
109109
return driver.manage().window().getSize().getHeight();
110110
} else {
111-
return (long) executeScript("if (self.outerHeight) {return self.outerHeight;} if (document.documentElement && document.documentElement.clientHeight) {return document.documentElement.clientHeight;}if (document.body) {return document.body.clientHeight;}");
111+
return (long) executeScript("if (self.innerHeight) {return self.innerHeight;} if (document.documentElement && document.documentElement.clientHeight) {return document.documentElement.clientHeight;}if (document.body) {return document.body.clientHeight;}");
112112
}
113113
}
114114
}
115115

116116
private long retrievePageWidth() {
117-
if (!isAppiumAndroidContext()) {
117+
if (!isAppiumContext()) {
118118
if (getZoom().equals("100%")) {
119-
String script = "if (self.outerWidth) {return self.outerWidth;} if (document.documentElement && document.documentElement.clientWidth) {return document.documentElement.clientWidth;}if (document.body) {return document.body.clientWidth;}";
119+
String script = "if (window.innerWidth) {return window.innerWidth;} if (document.documentElement && document.documentElement.clientWidth) {return document.documentElement.clientWidth;}if (document.body) {return document.body.clientWidth;}";
120120
return (long) executeScript(script);
121121
} else {
122122
return (long) executeScript("return document.getElementsByTagName('body')[0].offsetWidth");
@@ -125,7 +125,7 @@ private long retrievePageWidth() {
125125
if (isAppiumNativeMobileContext() || isAppiumIOSContext()) {
126126
return driver.manage().window().getSize().getWidth();
127127
} else {
128-
return (long) executeScript("if (self.outerWidth) {return self.outerWidth;} if (document.documentElement && document.documentElement.clientWidth) {return document.documentElement.clientWidth;}if (document.body) {return document.body.clientWidth;}");
128+
return (long) executeScript("if (self.innerWidth) {return self.outerWidth;} if (document.documentElement && document.documentElement.clientWidth) {return document.documentElement.clientWidth;}if (document.body) {return document.body.clientWidth;}");
129129
}
130130
}
131131
}

src/main/java/net/itarray/automotion/internal/ResponsiveUIChunkValidatorBase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public ResponsiveUIChunkValidatorBase(UISnapshot snapshot, List<WebElement> webE
3030
if (!getDriver().isAppiumContext()) {
3131
try {
3232
((JavascriptExecutor) getDriver().getDriver()).executeScript("arguments[0].scrollIntoView();", webElements.get(0));
33+
((JavascriptExecutor) getDriver().getDriver()).executeScript("javascript:window.scrollBy(0,250);");
3334
} catch (Exception e) {}
3435
}
3536
}

src/main/java/net/itarray/automotion/internal/UIValidatorBase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public UIValidatorBase(UISnapshot snapshot, WebElement webElement, String readab
3939
if (!getDriver().isAppiumContext()) {
4040
try {
4141
((JavascriptExecutor) getDriver().getDriver()).executeScript("arguments[0].scrollIntoView();", webElement);
42+
((JavascriptExecutor) getDriver().getDriver()).executeScript("javascript:window.scrollBy(0,250);");
4243
} catch (Exception e) {}
4344
}
4445
}

0 commit comments

Comments
 (0)