標籤:java用戶端 ESS and element androi duration ted you touch
今天使用appium 6.1.0 java用戶端,發現長按longpress(element),無法使用。如下代碼在5.0.4 版本是可以正常啟動並執行,
WebElement noteDelete = driver.findElementByXPath("//android.widget.ListView[@resource-id=‘android:id/list‘]/android.widget.RelativeLayout[1]"); int x = noteDelete.getLocation().getX(); int y = noteDelete.getLocation().getY(); TouchAction action = new TouchAction(driver); Duration duration = Duration.ofMillis(2000); //按壓1秒 action.press(x,y).waitAction(duration).moveTo(x,y).release().perform(); //方式一 長按和滑動都適用 action.longPress(noteDelete).release().perform(); //方式二 長按
這段代碼再6.1.0是無法使用的,最後安裝api提示,修改代碼如下,實際適用選中一種方法就可以了
WebElement noteDelete = driver.findElementByXPath("//android.widget.ListView[@resource-id=‘android:id/list‘]/android.widget.RelativeLayout[1]"); int x = noteDelete.getLocation().getX(); int y = noteDelete.getLocation().getY(); Duration duration = Duration.ofMillis(2000); TouchAction action = new TouchAction(driver); action.longPress(PointOption.point(x,y)).release().perform(); //長按 action.press(PointOption.point(x,y)) //長按和滑動都適用 .waitAction(WaitOptions.waitOptions(duration)) .moveTo(PointOption.point(x,y)) .release() .perform();
java appium用戶端 6.1.0android長按及滑動變更