Android自动化测试初探(五): 再述模拟键盘鼠标事件(adb shell 实现)

Android自动化测试初探(五): 再述模拟键盘鼠标事件(adb shell 实现)

字体: |上一篇下一篇|打印 |我要投稿

  命令格式2:adb shell sendevent [device] [type] [code] [value]

  如: adb shell sendevent /dev/input/event0 1 229 1 代表按下按下menu键

  adb shell sendevent /dev/input/event0 1 229 0 代表按下松开menu键

  说明:上述的命令需组合使用

  另外所知道的命令如下:

  Key Name CODE

  MENU 229

  HOME 102

  BACK (back button) 158

  CALL (call button) 231

  END (end call button) 107

  2.发送鼠标事件(Touch):

  命令格式:adb shell sendevent [device] [type] [code] [value]

  情况1:在某坐标点上touch

  如在屏幕的x坐标为40,y坐标为210的点上touch一下,命令如下

  adb shell sendevent /dev/input/event0 3 0 40
  adb shell sendevent /dev/input/event0 3 1 210
  
  adb shell sendevent /dev/input/event0 1 330 1 //touch
  adb shell sendevent /dev/input/event0 0 0 0 //it must have
  
  adb shell sendevent /dev/input/event0 1 330 0 //untouch
  adb shell sendevent /dev/input/event0 0 0 0 //it must have

  注:以上六组命令必须配合使用,缺一不可

  情况2:模拟滑动轨迹(可下载并采用aPaint软件进行试验)

  如下例是在aPaint软件上画出一条开始于(100,200),止于(108,200)的水平直线

  adb shell sendevent /dev/input/event0 3 0 100 //start from point (100,200)
  adb shell sendevent /dev/input/event0 3 1 200
  
  adb shell sendevent /dev/input/event0 1 330 1 //touch
  adb shell sendevent /dev/input/event0 0 0 0
  
  adb shell sendevent /dev/input/event0 3 0 101 //step to point (101,200)
  adb shell sendevent /dev/input/event0 0 0 0
  …………………… //must list each step, here just skip
  adb shell sendevent /dev/input/event0 3 0 108 //end point(108,200)
  adb shell sendevent /dev/input/event0 0 0 0
  
  adb shell sendevent /dev/input/event0 1 330 0 //untouch
  adb shell sendevent /dev/input/event0 0 0 0


转自:http://www.51testing.com/html/65/n-215865-2.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值