繁体   English   中英

Android - Appium向下滑动不起作用

[英]Android - Appium Swipe down 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);
    }

你能帮我解决一下我在做错的事吗?
任何帮助将受到高度赞赏。

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

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();
    }

通过上述方法调用:

向上滚动: swipeVertical((AppiumDriver)driver,0.9,0.1,0.5,3000);

向下滚动: swipeVertical((AppiumDriver)driver,0.1,0.9,0.5,3000);

使用此代码上下滑动

TouchAction t=new TouchAction(driver);

//long press, for atleast 1 sec first and move the object

        WebElement First=driver.findElementByXPath("//*[@***First Element Path***]");

        WebElement second=driver.findElementByXPath("//*[@***Second Element Path***]");
t.longPress(longPressOptions().withElement(element(First)).withDuration(ofSeconds(3))).moveTo(element(second)).release().perform();

希望这可以帮助 :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM