Appium 使用 node 的 client,做滑动 swipe,对可滚动的应用,没有任何效果.但是用手操作正常,请教哪位帮忙看看

zdhsoft · 2016年12月09日 · 1757 次阅读

使用 node 的 client,做滑动 swipe,对可滚动的应用,没有任何效果.但是用手操作正常,请教哪位帮忙看看.
滑动的函数

function doTouch(e) {
    var a1 = new wd.TouchAction();
    a1.press({ x: 360, y: 640 })
        .wait(1000)
        .moveTo({ x: 0, y: -500 })
        .wait(300)
        .moveTo({ x: 0, y: 500 })
        .wait(300)
        .release();
    driver.performTouchAction(a1, onCB);
}

下面是调用的代码

driver.init(desired)
    .sleep(3000)
    .elementByXPath('//android.widget.TextView[@text=\'通讯录\']', onCB)
    .click()
    .sleep(1000)
    .then(doTouch)

appium 的日志也显示操作成功.

[debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":360,"y":640}},{"action":"moveTo","options":{"x":0,"y":-500}},{"action":"wait","options":{"ms":300}},{"action":"moveTo","options":{"x":0,"y":500}},{"action":"wait","options":{"ms":300}},{"action":"release","options":{}}],"22f23ee5-e019-4a8d-b765-70b90f6577d8"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:touchDown","params":{"x":360,"y":640}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:touchDown","params":{"x":360,"y":640}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: touchDown
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][720,1280]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Performing TouchDown using element? false x: 360, y: 640
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:touchMove","params":{"x":360,"y":140}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:touchMove","params":{"x":360,"y":140}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: touchMove
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][720,1280]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Performing TouchMove using element? false x: 360, y: 140
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:touchMove","params":{"x":360,"y":640}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:touchMove","params":{"x":360,"y":640}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: touchMove
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][720,1280]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Performing TouchMove using element? false x: 360, y: 640
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:touchUp","params":{"x":360,"y":640}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:touchUp","params":{"x":360,"y":640}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: touchUp
[debug] [AndroidBootstrap] Received command result from bootstrap
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Display bounds: [0,0][720,1280]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Performing TouchUp using element? false x: 360, y: 640
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":true}
共收到 0 条回复 时间 点赞
zdhsoft 关闭了讨论 12月12日 10:30
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册