分类:
分三类:MonkeyRunner、MonkeyDevice、MonkeyImage
MonkeyRunner
提供连接真机和模拟器、输入、暂停、警告框等方法。
- 常用方法
1、waitForConnection(float timeout,string deviceid)
2、sleep(times)
MonkeyDevice
提供了安装和卸载程序包、开启Activity、发送按键和点击事件、运行测试包等方法。
- 常用方法
1、 installPackage (string path)
2、removePackage (string package)
3、 startActivity (string uri, string action, string data, string mimetype, iterable categories dictionary extras, component component, flags)
4、touch (integer x, integer y, integer type)
【参数说明】
integer x:x坐标值。
integer y:y坐标值。
integer type:key event类型(如DOWN、UP、DOWN_AND_UP)
5、drag (tuple start, tuple end, float duration, integer steps)
【参数说明】
tuple start:拖拽起始位置,为tuple类型的(x,y)坐标点。
tuple end:拖拽终点位置,为tuple类型的(x,y)坐标点。
float duration:拖拽手势持续时间,默认为1.0s。
integer steps:插值点的步数,默认值为10。
MonkeyImage
在测试过程中用来保存各种格式的测试截图,并可以进行图像对比。
- 常用方法
1、takeSnapshot()
进行屏幕截图
2、writeToFile(‘写入的文件名\截图命名’,‘截图的格式例如jpg等’)
保存图像文件到指定的文件路径