Skip to content

Commit 7255946

Browse files
committed
Scroll to Element for APK/IPA : improve logs
1 parent a17e23a commit 7255946

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

source/src/main/java/org/cerberus/core/service/appium/impl/AppiumService.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ private boolean scrollDown(TestCaseExecution testCaseExecution, By element, int
445445
int i = 0;
446446

447447
do {
448+
i++;
448449
boolean isPresent = driver.findElements(element).size() > 0;
449450
if (isPresent && driver.findElement(element).isDisplayed()) {
450451

@@ -454,19 +455,20 @@ private boolean scrollDown(TestCaseExecution testCaseExecution, By element, int
454455

455456

456457
if (distanceFromMiddleOfTheScreen > 0) {
457-
scroll(driver, pressX, topY, pressX, topY + distanceFromMiddleOfTheScreen + vOffset);
458-
testCaseExecution.addExecutionLog(ExecutionLog.STATUS_INFO, "[Action:ScrollTo] : Element " + element + " displayed. Perform another scroll to get it at the middle of the screen after applied the offset (" + hOffset + ";" + vOffset + ") scrolling from coord("+pressX+";"+topY+") to coord("+pressX+";"+topY + distanceFromMiddleOfTheScreen + vOffset+")");
458+
int targetCoordinateY = topY + distanceFromMiddleOfTheScreen + vOffset;
459+
scroll(driver, pressX, topY, pressX, targetCoordinateY);
460+
testCaseExecution.addExecutionLog(ExecutionLog.STATUS_INFO, "[Action:ScrollTo] : Element " + element + " displayed. Perform another scroll to get it at the middle of the screen after applied the offset (" + hOffset + ";" + vOffset + ") scrolling from coord("+pressX+";"+topY+") to coord("+pressX+";"+targetCoordinateY+")");
459461
} else if (distanceFromMiddleOfTheScreen < 0 ){
460-
scroll(driver, pressX, bottomY, pressX, bottomY + distanceFromMiddleOfTheScreen + vOffset);
461-
testCaseExecution.addExecutionLog(ExecutionLog.STATUS_INFO, "[Action:ScrollTo] : Element " + element + " displayed. Perform another scroll to get it at the middle of the screen after applied the offset (" + hOffset + ";" + vOffset + ") scrolling from coord("+pressX+";"+bottomY+") to coord("+pressX+";"+bottomY + distanceFromMiddleOfTheScreen + vOffset+")");
462+
int targetCoordinateY = bottomY + distanceFromMiddleOfTheScreen + vOffset;
463+
scroll(driver, pressX, bottomY, pressX, targetCoordinateY);
464+
testCaseExecution.addExecutionLog(ExecutionLog.STATUS_INFO, "[Action:ScrollTo] : Element " + element + " displayed. Perform another scroll to get it at the middle of the screen after applied the offset (" + hOffset + ";" + vOffset + ") scrolling from coord("+pressX+";"+bottomY+") to coord("+pressX+";"+targetCoordinateY+")");
462465
}
463466

464467
return true;
465468
} else {
466469
scroll(driver, pressX, bottomY, pressX, topY);
467470
testCaseExecution.addExecutionLog(ExecutionLog.STATUS_INFO, "[Action:ScrollTo] : Element "+element+" not displayed. Scrolled "+i+"/"+numberOfScrollDown+" from coord("+pressX+";"+bottomY+") to coord("+pressX+";"+topY+")");
468471
}
469-
i++;
470472

471473
} while (i < numberOfScrollDown);
472474

0 commit comments

Comments
 (0)