Monkey

Monkey启动步骤

1、连接移动设备

  adb connect 127.0.0.1:62001

2、连接成功后输入命令

  adb shell monkey 100

操作事件

1、触摸事件

2、手势事件

3、二指缩放事件

4、轨迹事件

5、屏幕旋转事件

6、基本导航事件

7、主要导航事件

8、系统按键事件

9、启动Activity事件

10、键盘事件

11、其他类型事件

 

Monkey 参数

  • 常规类参数
  • 事件类参数
  • 约束类参数
  • 调试类参数

常规类参数:包括帮助参数和日志信息参数。

1、帮助类参数

  monkey -h

2、日志级别

  adb shell monkey -v -v -v 1000

0级,除启动提示、测试完成和最终结果外提供较少信息

1级,提供较详细测试信息,如逐个发送到Activity的事件

2级,提供更详细安装信息,如测试中被选中或未被选中的Activity

1000:随机事件数

 

事件类参数

主要作用是对随机事件进行调控,从而使其遵照设定运行

1、执行指定脚本

  adb shell monkey -f 脚本名称

2、伪随机数生成种子值

使用 -s 命令可以重复执行之前的为随机操作

adb shell monkey -s <count>

3、设置间隔  如果你希望在每个指令之间加上固定的间隔时间,可以用--throttle命令

adb shell monkey --throttle 3000  5

 

调整事件百分比

adb shell monkey -v --pct-事件 百分比 200

 

约束类参数

1、包约束

-p:后面接一个或多个包名

  adb shell monkey -v -p 包名 200

  adb shell monkey -v -p 包名 -p 包名 200

 

2、activity类约束

如果你希望将monkey限制在一个或几个类别中,使用如下命令:

adb shell monkey -c 

 

调试类参数

1、应用程序奔溃后继续发送事件

monkey在应用程序奔溃后继续发送事件,需用到--ignore-crashes

  adb shell monkey --ignore-crashes  200

2、超时错误继续发送事件 

需要用到 --ignore-timeouts

  adb shell monkey 200 --ignore-timeouts

3、应用程序权限错误发生后继续发送事件

需要用到 --ignore-security-exceptions

  adb shell monkey 200 --ignore-security-exceptions

 

posted on 2018-10-09 17:35  破折号  阅读(244)  评论(0编辑  收藏  举报