I am using Appium 1.7 and Android 8 on real device. But I am stuck with swipe up. tried with different combinations. Could you please provide an easy code for swipe functionality?
Tried:
private void scrollDown() {
//if pressX was zero it didn't work for me
int pressX = driver.manage().window().getSize().width / 2;
// 4/5 of the screen as the bottom finger-press point
int bottomY = driver.manage().window().getSize().height * 4/5;
// just non zero point, as it didn't scroll to zero normally
int topY = driver.manage().window().getSize().height / 8;
//scroll with TouchAction by itself
scroll(pressX, bottomY, pressX, topY);
}
/*
* don't forget that it's "natural scroll" where
* fromY is the point where you press the and toY where you release it
*/
private void scroll(int fromX, int fromY, int toX, int toY) {
TouchAction touchAction = new TouchAction(driver);
touchAction.longPress(fromX, fromY).moveTo(toX, toY).release().perform();
}
But no luck..!!
According to this question: Appium - Java, How to automate swipe in android, the use of coordinates is Deprecated. I posted an answer there with the code that works for me in this case
you have to wait after pressing. This will work Can use this to swipe in any direction from point a to point b
You can perform scroll / swipe up action with below code:
You can tweak the code to perform left, down and right swipe. Let me know if this works for you.
i have used the below code to Swipe / Scroll and it is working perfectly
Code to Swipe UP
Code to Swipe DOWN
Code for carousel images swipe
Thanks!!!
Use this latest code this is working for Appium Java Client 7.2.0
This gives me the solution: