Appium 使用 TouchAction 滑动不起作用

jack · 2019年07月10日 · 最后由 jack 回复于 2019年07月15日 · 404 次阅读

代码:
actions.press(PointOption.point(sX,sY)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3))).moveTo(PointOption.point(eX,eY)).release().perform();

日志:
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:touchMove","params":{"x":180,"y":1053}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: touchMove
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][1080,1920]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Performing TouchMove using element? false x: 180, y: 1053
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":true,"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:touchUp","params":{"x":180,"y":1053}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:touchUp","params":{"x":180,"y":1053}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: touchUp
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][1080,1920]
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Performing TouchUp using element? false x: 180, y: 1053
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":true,"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [W3C (436c6643)] Responding to client with driver.performTouch() result: null

界面上没有滑动的效果,不知道啥原因,跟这个有关系吗?这么为什么返还 null 呢?Responding to client with driver.performTouch() result: null

共收到 3 条回复 时间 点赞
jack #1 · 2019年07月10日 Author

补充一下:appium 版本用的 1.12.0, java-clinet 用的 7.0.0

试试这个吧

new TouchAction(driver).press(PointOption.point(start_x, start_y))
                .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(Math.round(duration))))
                .moveTo(PointOption.point(end_x, end_y)).release().perform();
jack #3 · 2019年07月15日 Author

解决了,坐标理解错了,位置交交互一下就好了

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册