【问题标题】:adb shell input command changes when ran on multiple devices [duplicate]在多个设备上运行时 adb shell 输入命令发生变化[重复]
【发布时间】:2016-09-01 18:24:57
【问题描述】:

我目前正在使用 bash 和 adb 在 Android 设备上自动进行配置。当我在一台设备上运行我的代码时,“adb shell input tap xxx xxx”命令是 100% 准确的并且可以很好地完成它们的工作。

当我在多个设备上运行脚本时,坐标似乎发生了变化 - 设备开始点击屏幕上看似随机的点,就好像它们已经重新分配了新的位置。

从逻辑上讲,这里会发生什么?脚本的相关部分如下。

DeviceConfig () {

      #Location
      ./adb -s "$usb" shell am start -n com.android.settings/.Settings
      ./adb -s "$usb" shell input tap 215 695
      ./adb -s "$usb" shell input tap 1210 55
      #Icons
      ./adb -s "$usb" shell am start -n com.estrongs.android.pop/.view.FileExplorerActivity
      sleep 7
      ./adb -s "$usb" shell input tap 165 500
      ./adb -s "$usb" shell input tap 165 500
      ./adb -s "$usb" shell input tap 165 500
      ./adb -s "$usb" shell input tap 165 500
      sleep 1
      ./adb -s "$usb" shell input tap 155 150
      sleep 1
      ./adb -s "$usb" shell input tap 155 374
      sleep 1
      ./adb -s "$usb" shell input swipe 680 130 680 130 1500
      sleep 1
      ./adb -s "$usb" shell input tap 920 130
      sleep 1
      ./adb -s "$usb" shell input tap 1185 723
      sleep 1

}

for usb in $(./adb devices -l | awk '/ device usb:/{print $3}'); do DeviceConfig $usb ; done

【问题讨论】:

  • 与所描述的问题没有直接关系 - 但在开始活动时使用 am start -W 而不是之后插入固定延迟

标签: android bash shell adb


【解决方案1】:

我假设您在这里谈论的是相同的设备。

如果您的设备只是放置在水平表面上 - 某些设备可能处于不同的显示方向模式,这会扭曲您的坐标。

您可以确保所有设备都处于相同的位置(假设是直立的),也可以在运行自动化之前将它们设置为固定方向。或者更好的是 - 停止使用绝对坐标来模拟触摸。

【讨论】:

  • 在 Appium 之外是否有一个选项可以指向我想要点击的位置,比如 XML 屏幕截图等?
  • 使用 adb shell uiautomator dump 转储当前 UI 层次结构
猜你喜欢
  • 1970-01-01
  • 2021-11-06
  • 2014-08-20
  • 1970-01-01
  • 2022-07-12
  • 2020-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多