alibaba / macaca

Automation solution for multi-platform. 多端自动化解决方案
https://macacajs.github.io
MIT License
3.16k stars 418 forks source link

安卓touch的drag方法会同时触发滑动和长按事件 #972

Closed yuanjie111 closed 4 years ago

yuanjie111 commented 4 years ago

method: POST url: /wd/hub/session/f1a10791-4bf3-49a3-8ccb-1121f5f3266a/actions, jsonBody: {"actions":[{"fromX":118,"fromY":1667,"toX":118,"toY":1167,"duration":1,"steps":100,"type":"drag"}]}

调用方法: this.touch('drag',{ // 元素中心点 fromX: x, fromY: y, // 目标坐标 toX, toY, // 时长 duration: 1, // duration:1, steps:100 }).then(resolve) }

macaca-bot commented 4 years ago

This is the translated issue:


Android touch drag method will be triggered simultaneously slide and press events

  Node.js checklist:

  node env: C: \ Program Files \ nodejs \ node.exe   node version: v8.9.2

  Android checklist:

  JAVA version is 1.8   JAVA_HOME is set to C: \ Program Files \ Java \ jdk1.8.0_121   ANDROID_HOME is set to C: \ android-sdk   Platforms is set to C: \ android-sdk \ platforms \ android-28   ADB tool is set to C: \ android-sdk \ platform-tools \ adb.exe   GRADLE_HOME is set to D: \ gradle \ gradle-4.6-all \ gradle-4.6

method: POST url: / wd / hub / session / f1a10791-4bf3-49a3-8ccb-1121f5f3266a / actions, jsonBody: { "actions": [{ "fromX": 118, "fromY": 1667, "toX": 118, "toY": 1167, "duration": 1, "steps": 100, "type": " drag "}]}

Call the method: this.touch ( 'drag', {                 // element central point                 fromX: x, fromY: y,                 // target coordinates                 toX, toY,                 // duration                 duration: 1,                 // duration: 1,                 steps: 100             }). Then (resolve)         }

niaoshuai commented 4 years ago

try use adb command ........

houseshi commented 4 years ago

可以先用 adb命令解决这个问题。

    // adb 拖动 命令
    String cmdString = "adb shell input swipe"+ " " + x + " "+ y + " " + fX + " "+ fY;
    BaseUtils.exec2(cmdString);
macaca-bot commented 4 years ago

This is the translated issue comment: @houseshi


This problem can be resolved with the adb command.

        // adb command drag         String cmdString = "adb shell input swipe" + "" + x + "" + y + "" + fX + "" + fY;         BaseUtils.exec2 (cmdString);