APP_性能测试_Monkey02Script

MonkeyScript
MonkeyScript是一组可以被Monkey识别的命令集合
 优点:MonkeyScript可以完成重复固定的操作
 使用:adb shell monkey -f
 
MonkeyScript命令
DispatchTrackball
 轨迹球事件
 DispatchTrackball(long downtime,long eventtide,int action,float x,float y,float pressure,float size,int metastate,float xprecision,float yprecision,int device,int edgeflags)
 注意:按一个键需要两个轨迹球事件
DispatchTrackball参数详解
#long downtime指键最初被按下的时间
#long eventtide指事件发生的时间
#int action指具体操作的动作,如按下
#float x,float y指x和y的坐标
#float pressure压力事件的大小(0~1) #float size指触摸的记事值(0~1)
#int metastate指当前按下mate键的标识
#float xprecision,float yprecision指x和y坐标的精确值
#int device事件的来源(0~x)
#int edgeflags指超出屏幕了范围
action:0代表按下,1代表弹起
 
 ————————————————————————————————————————————————————————————————————
脚本部分:
手机—设置开发者选项—设置—关于手机—版本号、连续点击7次提示 开发者模式—开发者模式里面有个指针位置
写脚本

typ=user
count=10
speed=1.0
start data >>
LaunchActivity(com.android.browser,com.android.browser.BrowserActivity)
UserWait(8000)
DispatchPointer(10,10,0,200,100,1,1,-1,1,1,0,0)
DispatchPointer(10,10,1,200,100,1,1,-1,1,1,0,0)
DispatchPress(112)
UserWait(1000)
DispatchString(www.baidu.com)
DispatchPress(66)
UserWait(5000)

调用的时候需要把文件传到手机虚拟机里执行monkey命令

执行脚本:执行了11个事件

 ——————————————————————————————————————————————————————————————————

MonkeyRunner

完成自动化、简单的ui截图

MonkeyRunner提供了系列的API
MonkeyRunner可以完成模拟事件及截图操作
MonkeyRunner:用来连接设备或模拟器的
MonkeyDevice:提供安装、卸载应用,发送模拟事件
MonkeyImage:完成图像保存及对比的操作
例如:
MonkeyRunner
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage 
MonkeyRunner.alert("youme","sha","en")
 

 

 

 
posted @ 2019-06-01 14:27  大佳佳  阅读(185)  评论(0编辑  收藏  举报