I'm having trouble with scrolling down to a certain element in an iOS and Android app. Since the update from Appium 1.6.3 to 1.7.1 and io.appium to 6.1.0 the swipe method is deprecated and the only solution for it is to use TouchActions.
I tried to solve it with TouchActions but it didn't scroll at all or the scroll direction was wrong.
My solution so far looks like this, maybe someone can explain what I'm doing wrong:
public void scrollDownUntilElementVisible(WebElement element){
TouchAction touchAction = new TouchAction(getDriver());
for(int i=0; i<dimensions.getHeight();i++){
if(element.isDisplayed()){
break;
}else{
touchAction.press(0,0).moveTo(element).release().perform();
}
}
}
It's not the complete code, but I hope you get the idea.
How would it work if I would use the x,y-coordinates instead of the webElement I look for in my example? It does not work like the swipe method from the version before, or I didn't do it right. Maybe someone can explain it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…