I’m trying to do a click on a element after scrolling but after the scroll it always keep going to the top of the screen, trying to reach for settings (no idea why)
Here’s the problem:
Here is my scroll method:
private void scroll(int fromX, int fromY, int toX, int toY) {
TouchAction touchAction = new TouchAction(driver);
try{
touchAction.longPress(fromX, fromY).moveTo(toX, toY).release().perform();
System.out.println(fromY);
System.out.println(toY);
}
catch(WebDriverException wd){
wd.getMessage();
}
}
public void scrollDown(int tries) throws InterruptedException {
int pressX = driver.manage().window().getSize().width / 2;
int bottomY = driver.manage().window().getSize().height * 4/5;
int topY = driver.manage().window().getSize().height / 8;
System.out.println("bottomY "+bottomY);
System.out.println("topY "+topY);
//int i = 0;
for(int i = 0; i<tries; i++) {
System.out.println("before: "+i);
scroll(pressX, bottomY, pressX, topY);
System.out.println("after: "+i);
}
}
I’m trying to click on a date from my calendar:
scrollDown(3);
By elChoseAgust1 = By.xpath("(//android.view.View[@content-desc=\"1\"])[16]");
System.out.println("elChoseAgust1: "+elChoseAgust1);
WebElement selectChoiceAgust1 = wait.until(ExpectedConditions.elementToBeClickable(elChoseAgust1));
System.out.println("selectChoiceAgust1: "+selectChoiceAgust1.getAttribute("name"));
selectChoiceAgust1.click();
Could anyone help me on this?
Thanks