zoukankan      html  css  js  c++  java
  • java appium客户端 6.1.0android长按及滑动变更

    今天使用appium 6.1.0 java客户端,发现长按longpress(element),无法使用。如下代码在5.0.4 版本是可以正常运行的,

            WebElement noteDelete = driver.findElementByXPath("//android.widget.ListView[@resource-id='android:id/list']/android.widget.RelativeLayout[1]");
            int x  = noteDelete.getLocation().getX();
            int y  = noteDelete.getLocation().getY();
            TouchAction action = new TouchAction(driver);
            Duration duration = Duration.ofMillis(2000);    //按压1秒
            action.press(x,y).waitAction(duration).moveTo(x,y).release().perform();   //方式一 长按和滑动都适用
            action.longPress(noteDelete).release().perform();   //方式二 长按

    这段代码再6.1.0是无法使用的,最后安装api提示,修改代码如下,longpress 和press 都可以,实际使用选中一种方法就可以了

            WebElement noteDelete = driver.findElementByXPath("//android.widget.ListView[@resource-id='android:id/list']/android.widget.RelativeLayout[1]");
            int x = noteDelete.getLocation().getX();
            int y = noteDelete.getLocation().getY();
            Duration duration =  Duration.ofMillis(2000);
            TouchAction action = new TouchAction(driver); 
            action.longPress(PointOption.point(x,y)).release().perform();  //长按
    
            action.press(PointOption.point(x,y))   //长按和滑动都适用
                    .waitAction(WaitOptions.waitOptions(duration))  
                    .moveTo(PointOption.point(x,y))
                    .release()
                    .perform();
  • 相关阅读:
    编译内核开始的小问题Unable to find the Ncurses libraries
    qq for linux Ubuntu 64位兼容
    ubuntu下安装lighttpd
    搭建boa服务器
    INI file and Iniparser
    kernel常用.gitignore配置
    光谱学习
    jump to case label fpermissive
    Qt通用方法及类库5
    Qt通用方法及类库1
  • 原文地址:https://www.cnblogs.com/testway/p/9343028.html
Copyright © 2011-2022 走看看