1. 程式人生 > >Appium九宮格滑動解鎖

Appium九宮格滑動解鎖

info eight oca ESS 代碼實現 inf appium web element

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

具體實現

技術分享圖片

Appium九宮格滑動解鎖