android - 如何使用 ADB 使用 sendevent 命令向设备发送触摸事件?

标签 android automation adb touchscreen

我正在尝试使用 AndroidDebugBridge 将触摸事件发送到设备,以便我可以为 UI 测试做一些基本的自动化操作。我关注了 LINK 中的讨论.我可以使用 sendevent 在模拟器上模拟触摸,但无法在设备上执行相同操作。

与上面的链接一样,模拟器似乎为每次触摸发送 6 个事件(xcoord、ycoord、2 个用于按下、2 个用于释放),使用此信息发送事件很容易,但触摸屏的 getevent 用于设备似乎生成了太多的事件。

有人设法将触摸从 ADB 发送到设备吗?能否分享一下解决方法。

最佳答案

Android 带有一个 input 命令行工具,可以模拟各种输入事件。为了模拟敲击,它是:

input tap x y

您可以使用 adb shell (> 2.3.5) 远程运行命令:

adb shell input tap x y

关于android - 如何使用 ADB 使用 sendevent 命令向设备发送触摸事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3437686/

相关文章:

Android 改变 Spinner 的 TextView 颜色

android - Google API项目中的 "Google Play Android Developer"是什么

android - 如何使用Android ViewPager

android - 以编程方式从 String[] 添加按钮

node.js - 从 Nodejs 运行多个 Windows 命令

javascript - TestCafe 下拉选择器

unit-testing - 在 Win7 x64 中运行时 content_shell 崩溃

android - 有没有办法在没有整个 SDK 的情况下只安装 ADB?

android - Chrome 远程调试控制台无法在 Android 4.4.4 上运行

android - Android 基于跟踪和基于采样的方法分析之间的差异及其对报告的 CPU 时间的影响