Appium手势密码滑动之Z字形走势(java篇)
1、直接使用负的偏移量appium会报错,在后面加上moveto(1,1)就行了
2、直接看图说话
废话少说看代码如:
List<AndroidElement> element = driver.findElementsByAndroidUIAutomator("new UiSelector().resourceId(\"com.dsf.app:id/lpv_lock\")");
Thread.sleep(1000);
AndroidElement gelemt = element.get(0);
int startX = gelemt.getLocation().getX();
int startY = gelemt.getLocation().getY();
int height = gelemt.getSize().getHeight();
int width = gelemt.getSize().getWidth();
int xStep = width/6;
int yStep = height/6;
int beginX = startX+xStep;
int beginY = startY + yStep;
TouchAction ta = new TouchAction(driver);
ta.press(beginX, beginY).moveTo(xStep*2, 0).moveTo(xStep*2, 0).moveTo(-xStep*2,yStep*2).
moveTo(-xStep*2, yStep*2).moveTo(xStep*2, 0).moveTo(2*xStep, 0).moveTo(1, 1).release().perform();
Thread.sleep(6000);
ta.press(beginX, beginY).moveTo(xStep*2, 0).moveTo(xStep*2, 0).moveTo(-xStep*2,yStep*2).
moveTo(-xStep*2, yStep*2).moveTo(xStep*2, 0).moveTo(2*xStep, 0).moveTo(1, 1).release().perform();