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();
具体实现
原文地址:https://www.cnblogs.com/fulucky/p/9946700.html
时间: 2024-10-11 22:01:16