Appium 求教:安卓自动化 long_press 长按变点击 问题

April · 2018年09月03日 · 最后由 jack 回复于 2019年07月10日 · 1343 次阅读

appium 版本:1.6.1
安卓版本:6.0
我的代码如下:

print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
TouchAction(self.driver).long_press(element, None, None, 5000).perform()
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))

执行没有报错,打印的时间也确实相差 5 秒,但是手机界面没有出现快捷操作(正常情况长按会出现快捷操作小图标),而是直接点进来,跳入新的界面。
appium 日志貌似也很正常,日志如下:

{}}],"sessionId":"c7351609-c95f-4e5c-b033-6fe7d7fafcda"}
[MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"longPress","options":{"x":null,"y":null,"duration":5000}},{"action":"release","options":{}}],"c7351609-c95f-4e5c-b033-6fe7d7fafcda"]
[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:touchLongClick","params":{"x":0,"y":0,"duration":5000}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:touchLongClick","params":{"x":0,"y":0,"duration":5000}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: touchLongClick
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][720,1208]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Performing TouchLongClick using element? false x: 360, y: 604, duration: 5000
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.performTouch() result: null
[HTTP] <-- POST /wd/hub/session/c7351609-c95f-4e5c-b033-6fe7d7fafcda/touch/perform 200 5194 ms - 76
[HTTP] 

请问这个是什么原因呢

共收到 2 条回复 时间 点赞

改成 TouchAction(self.driver).long_press(element).wait(5000).release().perform()
试下

你好,你的滑动有效果吗?为什么我的执行完成后界面没有滑动呢,日志里也没报错。还有 Responding to client with driver.performTouch() result: null,为什么这个返回是 Null 呢

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