Skip to content

Commit

Permalink
Scroll to Element for APK/IPA : improve logs
Browse files Browse the repository at this point in the history
  • Loading branch information
bcivel committed Jan 22, 2025
1 parent a17e23a commit 7255946
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ private boolean scrollDown(TestCaseExecution testCaseExecution, By element, int
int i = 0;

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

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


if (distanceFromMiddleOfTheScreen > 0) {
scroll(driver, pressX, topY, pressX, topY + distanceFromMiddleOfTheScreen + vOffset);
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+")");
int targetCoordinateY = topY + distanceFromMiddleOfTheScreen + vOffset;
scroll(driver, pressX, topY, pressX, targetCoordinateY);
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+")");
} else if (distanceFromMiddleOfTheScreen < 0 ){
scroll(driver, pressX, bottomY, pressX, bottomY + distanceFromMiddleOfTheScreen + vOffset);
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+")");
int targetCoordinateY = bottomY + distanceFromMiddleOfTheScreen + vOffset;
scroll(driver, pressX, bottomY, pressX, targetCoordinateY);
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+")");
}

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

} while (i < numberOfScrollDown);

Expand Down

0 comments on commit 7255946

Please sign in to comment.