我司 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
,敢问何解?