Appium [XCUITest] Appium1.6.3 如何实现复杂手势 (手势解锁)?

CNO · 2016年12月22日 · 最后由 Stepthen 回复于 2018年04月13日 · 1530 次阅读

我司 APP 打开之后有一个九宫格密码,需要用手势滑动,在网上找到了这种写法 (js 的):

var action = new wd.TouchAction(driver);
return action
    .press({x:100,y:400})
    .wait(500)
    .moveTo({x:0,y:-100})
    .wait(500)
    .moveTo({x:100,y:200})
    .release()
    .perform();

接着报错:

Error: [performTouchAction([{"action":"press","options":{"x":100,"y":400}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"x":0,"y":-100}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"x":100,"y":200}},{"action":"release","options":{}}])] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: Support for this gesture is not yet implemented. Please contact an Appium dev
     at exports.newError (node_modules/wd/lib/utils.js:139:13)
     at node_modules/wd/lib/callbacks.js:75:19
     at node_modules/wd/lib/webdriver.js:174:5
     at Request._callback (node_modules/wd/lib/http-utils.js:87:7)
     at Request.self.callback (node_modules/request/request.js:368:22)
     at Request.<anonymous> (node_modules/request/request.js:1219:14)
     at IncomingMessage.<anonymous> (node_modules/request/request.js:1167:12)
     at endReadableNT (_stream_readable.js:974:12)
     at _combinedTickCallback (internal/process/next_tick.js:74:11)
     at process._tickCallback (internal/process/next_tick.js:98:9)

Appium log:

[HTTP] --> POST /wd/hub/session/d13f2301-c581-413b-bfc5-b77a8e05e5c9/touch/perform [{"action":"press","options":{"x":100,"y":400}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"x":0,"y":-100}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"x":100,"y":200}},{"action":"release","options":{}}]
[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":100,"y":400}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"x":0,"y":-100}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"x":100,"y":200}},{"action":"release","options":{}}],"d13f2301-c581-413b-bfc5-b77a8e05e5c9"]
[debug] [XCUITest] Executing command 'performTouch'
[debug] [XCUITest] Received the following touch action: press-wait-moveTo-wait-moveTo-release
[HTTP] <-- POST /wd/hub/session/d13f2301-c581-413b-bfc5-b77a8e05e5c9/touch/perform 501 3 ms - 164 
[HTTP] --> DELETE /wd/hub/session/d13f2301-c581-413b-bfc5-b77a8e05e5c9 {}
[debug] [MJSONWP] Calling AppiumDriver.deleteSession() with args: ["d13f2301-c581-413b-bfc5-b77a8e05e5c9"]
[debug] [JSONWP Proxy] Proxying [DELETE /session/d13f2301-c581-413b-bfc5-b77a8e05e5c9] to [DELETE http://localhost:8100/session/FACEA869-D671-4DE1-B0FD-1C2F7CB8CE2D] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\n  \"value\" : {\n\n  },\n  \"sessionId\" : \"603F69DB-14B8-4393-8A23-9775B1269BB0\",\n  \"status\" : 0\n}"

看了一下支持手势的代码:

https://github.com/appium/appium-xcuitest-driver/blob/master/lib/commands/gesture.js#L26

Appium 只支持简单的滑动,而且就是一条直线的方向的滑动:press-wait-moveto-release,但是绘制一个手势密码至少需要一个 90 度的转弯press-wait-moveto-moveto-release,敢问何解?

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 13 条回复 时间 点赞
匿名 #2 · 2016年12月24日

你这个写法应该是对的,但是在 perform 前面是不是应该调用一下 release()?

—— 来自 TesterHome 官方 安卓客户端

CNO #4 · 2016年12月29日 Author

#1 楼 @lose 我是按照你这个来的,如果你懂一点 Node 的代码,看看这段代码https://github.com/appium/appium-xcuitest-driver/blob/master/lib/commands/gesture.js#L26-L41,现在的 Appium1.6.3 只有 ··press-wait-moveTo-release,press-moveTo-release,这种拖动,还不支持自己组合

CNO #5 · 2016年12月29日 Author

#2 楼 @kgtdy 写掉了,但是问题还在的

CNO #6 · 2016年12月29日 Author

#3 楼 @A_tester 不是,我的问题是,在 XCUITest 上,appium 根本就不能 moveTo 两次,他只能 press-moveTo-release,不能像你们这样的组合拖动。

同有问题,好像是 WDA 已经支持,但是 Appium 还不支持

CNO #8 · 2016年12月29日 Author

#7 楼 @qq386169040-github 好吧,只能坐等了更新版本了

请问 [debug] [XCUITest] Waiting for WebDriverAgent server to finish loading... 这个问题是怎么解决的 。。

@Cononico 这个问题解决了吗?最近也碰到了

楼主,请问解决了吗?

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册