Android - Appium Swipe down not working

后端 未结 2 1347
遇见更好的自我
遇见更好的自我 2020-12-18 10:28

I am trying to swipe down contact screen but its not working.

Here is the code I have tried.

public void Swipedown() throws InterruptedException
{
         


        
2条回答
  •  难免孤独
    2020-12-18 11:14

    Use below method for swiping down/up:

    public static void swipeVertical(AppiumDriver driver, double startPercentage, double finalPercentage, double anchorPercentage, int duration) throws Exception {
            Dimension size = driver.manage().window().getSize();
            int anchor = (int) (size.width * anchorPercentage);
            int startPoint = (int) (size.height * startPercentage);
            int endPoint = (int) (size.height * finalPercentage);
            new TouchAction(driver).press(anchor, startPoint).waitAction(Duration.ofMillis(duration)).moveTo(anchor, endPoint).release().perform();
        }
    

    Call above method by:

    For scroll up: swipeVertical((AppiumDriver)driver,0.9,0.1,0.5,3000);

    For scroll down: swipeVertical((AppiumDriver)driver,0.1,0.9,0.5,3000);

提交回复
热议问题