Appium九宫格滑动解锁

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

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

具体实现

 

posted @ 2018-11-12 15:24  爱吃橙子  阅读(368)  评论(0编辑  收藏  举报