简体   繁体   English

在 appium 中拖放更快

[英]drag&drop faster in appium

I am testing application trough appium with webdriver.io library.我正在使用 webdriver.io 库通过 appium 测试应用程序。 In there I have simple JS code, where I open screen testing application and then draw the line from one point to another.在那里我有简单的 JS 代码,在那里我打开屏幕测试应用程序,然后从一个点到另一个点画线。 Problem is I don't know how to change speed which the line is drawing.问题是我不知道如何改变线条绘制的速度。 I couldn't find any documentation.我找不到任何文档。

Here is all my code:这是我的所有代码:

const wdio = require("webdriverio")
const opts = {
  port: 4723,
  capabilities: {
    platformName: "Android",
    deviceName: "cbb3309d",
    appPackage: "jp.rallwell.siriuth.touchscreentest",
    appActivity: ".TouchScreenTestActivity",
    automationName: "UiAutomator2",
    noReset: true,
  }
}

function timeout(ms) {
  return new Promise(resolve => setTimeout(resolve, ms))
}

async function main() {
  const client = await wdio.remote(opts)
  client.setTimeouts(15000)
  await timeout(5000)
  client.touchAction([
        { action: 'longPress', x: 500, y: 100,},
        { action: 'moveTo', x: 500, y: 2000},
        'release'
])
}

main()

I found there is another function for it so I created my own function:我发现它还有另一个函数,所以我创建了自己的函数:

async function dragAndDrop(options) {
    let actions = new wd.W3CActions(driver);
    let touchInput = actions.addTouchInput();
    touchInput.pointerMove({
        duration: 0,
        x: options.fromX,
        y: options.fromY
    });
    touchInput.pointerDown({
        button: 0
    });
    touchInput.pause({
        duration: options.pressTime
    });
    touchInput.pointerMove({
        duration: options.moveTime,
        x: options.toX,
        y: options.toY
    });
    touchInput.pause({
        duration: options.releaseTime
    });
    touchInput.pointerUp({
        button: 0
    });
    await actions.perform();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM