Appium ruby+appium1.4.16.1+android 6.0.1+ 微信 连续侧滑屏幕出错

太阳糖 · 2017年03月17日 · 最后由 太阳糖 回复于 2017年03月20日 · 2023 次阅读

问题:打开微信连续侧滑,第一页可以滑动,到第二页再滑动就报错
部分代码:

@driver= Appium::Driver.new(caps)
@touch = Appium::TouchAction.new
@dirver.start_driver
@touch.swipe(start_x:1000,start_y:300,end_x:300,end_y:300,duration:1000).perform
@touch.swipe(start_x:1000,start_y:300,end_x:300,end_y:300,duration:1000).perform

日志:
{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}},"sessionId":"c19b459b-8c06-4ee4-9de4-f4c25a483bdf"}

info: --> POST /wd/hub/session/c19b459b-8c06-4ee4-9de4-f4c25a483bdf/timeouts/implicit_wait {"ms":0}
info: [debug] Set Android implicit wait to 0ms
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"c19b459b-8c06-4ee4-9de4-f4c25a483bdf"}
info: <-- POST /wd/hub/session/c19b459b-8c06-4ee4-9de4-f4c25a483bdf/timeouts/implicit_wait 200 0.791 ms - 76 {"status":0,"value":null,"sessionId":"c19b459b-8c06-4ee4-9de4-f4c25a483bdf"}
info: --> POST /wd/hub/session/c19b459b-8c06-4ee4-9de4-f4c25a483bdf/touch/perform {"actions":[{"action":"press","options":{"x":1000,"y":300}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":300,"y":300}},{"action":"release"}]}
info: [debug] Pushing command to appium work queue: ["swipe",{"startX":1000,"startY":300,"endX":300,"endY":300,"steps":6}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"swipe","params":{"startX":1000,"startY":300,"endX":300,"endY":300,"steps":6}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: swipe
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1440,2560]
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1440,2560]
info: [debug] [BOOTSTRAP] [debug] Swiping from [x=1000.0, y=300.0] to [x=300.0, y=300.0] with steps: 6
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"c19b459b-8c06-4ee4-9de4-f4c25a483bdf"}
info: <-- POST /wd/hub/session/c19b459b-8c06-4ee4-9de4-f4c25a483bdf/touch/perform 200 195.217 ms - 76 {"status":0,"value":true,"sessionId":"c19b459b-8c06-4ee4-9de4-f4c25a483bdf"}
info: --> POST /wd/hub/session/c19b459b-8c06-4ee4-9de4-f4c25a483bdf/touch/perform {"actions":[{"action":"press","options":{"x":1000,"y":300}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":300,"y":300}},{"action":"release"},{"action":"press","options":{"x":1000,"y":300}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":300,"y":300}},{"action":"release"}]}
info: <-- POST /wd/hub/session/c19b459b-8c06-4ee4-9de4-f4c25a483bdf/touch/perform 500 2.852 ms - 97
TypeError: Cannot read property 'element' of undefined
at C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-controller.js:937:20
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\underscore\underscore.js:227:11
at Function..each..forEach (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\underscore\underscore.js:153:9)
at Function..filter..select (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\underscore\underscore.js:226:7)
at [object Object]._.(anonymous function) as filter

我分析第二次滑动失败,是因为(日志)

info: --> POST /wd/hub/session/c19b459b-8c06-4ee4-9de4-f4c25a483bdf/touch/perform {"actions":[{"action":"press","options":{"x":1000,"y":300}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":300,"y":300}},{"action":"release"},{"action":"press","options":{"x":1000,"y":300}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":300,"y":300}},{"action":"release"}]}
跟第一次(日志)相比多了
{"action":"press","options":{"x":1000,"y":300}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":300,"y":300}},{"action":"release"}
导致服务不响应

尝试过的解决办法:
1.延长等待以及程序睡眠时间
2.升级 appium_lib 到最新版

问题依然存在,哪位同学也碰到过这样的问题,求分享!

共收到 2 条回复 时间 点赞

搞了一天,尝试了很多办法,暂时问题解决了,每次都新创建一个对象,这个问题应该 ruby 客户端(appium_lib)问题

Appium::TouchAction.new.swipe(start_x:1000,start_y:300,end_x:300,end_y:300,duration:1000).perform
Appium::TouchAction.new.swipe(start_x:1000,start_y:300,end_x:300,end_y:300,duration:1000).perform

问题我已经反映到 appium_lib 官方去了,在 9.3.5 中应该会有改善,更符合 ruby 面向对象的语法

太阳糖 关闭了讨论 03月20日 12:17
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册