Appium 设备操作API(根据坐标滑动)

it2025-01-10  13

根据坐标滑动swipe(startx, starty, endx, endy, duration):从(startx,starty)滑到(endx,endy),分duration步滑,每一步用时是5毫秒。坐标获取方式:a)手机--开发者选项--指针位置 b)hierarchyviewer c)uiautomatorviewer举例:File screen = driver.getScreenshotAs(OutputType.FILE);try {BufferedImage bufferedImage = ImageIO.read(screen);width = bufferedImage.getWidth();int height = bufferedImage.getHeight();System.out.println("width:"+width+"height:"+height);driver.swipe(width/2,height*3/4, width/2,height/4, 1000);} catch (IOException e) {e.printStackTrace();}备注:获取手机屏幕的大小,然后再实现滑动。

转载于:https://www.cnblogs.com/kon0/p/6528807.html

最新回复(0)