monkey命令详解(二)

monkey启动步骤:  
1、链接移动设备            adb connect 127.0.0.1:21503
2、链接成功输入命令     adb shell
3、进入指定目录            cd  /system/bin
 
数字代表含义:
0、触摸事件   1、手势事件    2、二指缩放事件    3、轨迹事件    4、屏幕旋转事件
5、基本导航事件    6、主要导航事件   7、系统按键事件   8启动Activity事件
9、键盘事件    10、其他类型事件
 
约束类参数:
指定APP                           adb shell monkey -p com.tal.kaoyan 500
执行指定脚本                   adb shell monkey -f /mnt/sdcard/test1
伪随机数生成种子值        adb shell monkey -s 666 100
设置时间间隔                   adb shell monkey --throttle 3000  5
调整触摸事件百分比        adb shell monkey -v -v --pct-touch 100 200
调整手势事件百分比        adb shell monkey -v -v --pct-motion 100 200
 
调试类参数:
应用程序崩溃后继续发送事件       adb shell monkey --ignore-crashes
超时错误继续发送事件                    adb shell monkey --ignore-timeouts
应用程序权限错误后继续发送事件     adb shell monkey --ignore-security-exceptions
 
实战练习:
adb shell monkey -p com.mixpace.android.mixpace            # 指定测试APP
--pct-touch 40 --pct-motion 25                         # 触摸事件40%、手势事件25%
--pct-appswitch 10                                        # Activity切换事件10%
--pct-rotation 5                                           # 横竖屏切换事件5%
-s 1666                                         # -s生成对应事件流,下次操作事件流完全相同
--throttle 400                                   # 设置间隔时间0.4秒
--ignore-crashes                               # 遇到崩溃后继续运行
--ignore-timeouts                              # 遇到没有响应继续运行
-v -v  200                                          # 设置日志级别、执行次数
 
monkey脚本运行后强制关掉:
1. adb shell
2. top | grep monkey
显示如下:
top | grep monkey
5447 0 1% S 10 262960K 10328K root com.android.commands.monkey
5447 0 0% S 10 262960K 10324K root com.android.commands.monkey
找到id为5447,然后再kill掉就OK了
3. adb shell
4. kill -9 5447
原文地址:https://www.cnblogs.com/yitao326/p/11271421.html