Appium九宫格滑动解锁

1、适配各种机型,首先获取整个解锁元素的坐标

Appium九宫格滑动解锁

2、代码实现

   WebElement lockPattern = driver.findElement(By.id("com.android.settings:id/lockPattern"));
        int x = lockPattern.getLocation().getX();
        int y = lockPattern.getLocation().getY();
        int w = lockPattern.getSize().getWidth();
        int h = lockPattern.getSize().getHeight();
        TouchAction ta = new TouchAction(driver);
        ta.press(x+w/6,y+h/6).waitAction(Duration.ofMillis(1000)).moveTo(2*w/6,0)
                .waitAction(Duration.ofMillis(1000)).moveTo(0,2*h/6)
                .waitAction(Duration.ofMillis(1000)).moveTo(0,2*h/6)
                .waitAction(Duration.ofMillis(1000)).moveTo(2*w/6,0)
                .release().perform();

具体实现

Appium九宫格滑动解锁

 

Appium九宫格滑动解锁

上一篇:mac os app 开发


下一篇:Go-内置函数之append、recover用法