Android - Appium向下滑动不起作用 [英] Android - Appium Swipe down not working

查看:959
本文介绍了Android - Appium向下滑动不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向下滑动联系人屏幕,但它无法正常工作。

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

这是我试过的代码。

public void Swipedown() throws InterruptedException
{
  // Select till which position you want to move the seekbar
  TouchAction action=new TouchAction((PerformsTouchActions) driver);
  Dimension dimensions = driver.manage().window().getSize();

  action.press(446,1404).moveTo(554,1500).release().perform(); 

    System.out.println("swipe down to set seekbar successfully");
    Thread.sleep(5000);
    }

你们可以帮我解决我在这里做错的事吗。

任何帮助将受到高度赞赏。

Can you guys help me what I am doing wrong here.
Any help will be highly appreciated.

推荐答案

使用以下方法向下/向上滑动:

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:

向上滚动: swipeVertical((AppiumDriver)驱动程序,0.9,0.1,0.5,3000);

向下滚动: swipeVertical((AppiumDriver)驱动程序,0.1,0.9,0.5,3000);

这篇关于Android - Appium向下滑动不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆