写android自动化测试脚本命令

每隔1秒重复操作某一按钮:
#!/system/bin/sh
i=0
while
i=$((i+1))
  do
 echo "snapshot $i times"
 input tap 400 1240
 sleep 1.0
 done


按键操作命令:
adb shell input keyevent "value"
value值可以通过按键时打印adb logcat |grep -i "keycode"查找。

点击屏幕命令:
adb shell input tap 400 1240

获得点击屏幕事件的方法:
adb shell getevent

获得点击屏幕计算点击位置的坐标
adb shell getevent | grep -e "0035" -e "0036"

D:\server>adb shell input
usage: input ...
       input text <string>
       input keyevent <key code number or name>
       input [touchscreen|touchpad|touchnavigation] tap <x> <y>
       input [touchscreen|touchpad|touchnavigation] swipe <x1> <y1> <x2> <y2> [duration(ms)]
       input trackball press
       input trackball roll <dx> <dy>

在某坐标点上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
注:以上六组命令必须配合使用,缺一不可



细节可参考:
Android自动化测试shell脚本(飞车Asphalt5)
http://blog.csdn.net/lhzhang1985/article/details/6580595
Android adb shell 获得点击屏幕的位置坐标 
http://blog.csdn.net/liu_zhen_wei/article/details/12559277

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值