1.adb devices -获取appid ,确认已连接
2.adb shell dumpsys activity top |grep ACTIVITY -获取当前包
或adb shell logcat |grep START-获取包名及activity
3.下载:https://github.com/zhangzhao4444/Maxim
进入Maxim-master 执行
adb shell CLASSPATH=/sdcard/monkey.jar:/sdcard/framework.jar exec app_process /system/bin tv.panda.test.monkey.Monkey -p com.sobot.demo --uiautomatormix --running-minutes 2 -v -v
解释含义
adb push framework.jar monkey.jar /sdcard
com.sobot.demo【被测试包名】
-v -v 【详情日志级别 最大 -v -v -v】
tv.panda.test.monkey.Monkey 【驱动文件,不做修改】
配置 max.xpath.actions
, 例如【通过配置文件可以自定义执行场景】
[
{
"prob": 1,
"activity":"tv.panda.account.activity.WebLoginActivity",
"actions": [
{
"xpath": "//*[@class='android.widget.EditText']",
"action": "INPUTTEXT",
"text": "13810751000",
"index": 0,
"throttle": 300
},
{
"xpath": "//*[@class='android.widget.EditText']",
"action": "INPUTTEXT",
"text": "123400",
"index": 1,
"throttle": 300
},
{
"xpath": "//*[@content-desc='登录' and @class='android.view.View']",
"index": 0,
"action": "CLICK",
"throttle": 1000
}]
},
{
"prob": 1,
"actions": [
{
"xpath": "//*[@class='android.view.View']",
"index": 0,
"action": "SWIPE",
"args": "10,1000,800,1000,100",
"throttle": 3000
}]
},
{
"prob": 1,
"actions": [
{
"xpath": "//*[@class='android.view.View']",
"index": 0,
"action": "TOUCH",
"args": "500,1000",
"throttle": 1000
}]
},
{
"prob": 1,
"actions": [
{
"xpath": "//*[@class='android.view.View']",
"index": 0,
"action": "KEYEVENT",
"keycode": 4,
"throttle": 1000
}]
}
]
上述包含3个特殊事件 发生概率prob =1 为100%发生 仅当 当前activity 为 tv.panda.account.activity.WebLoginActivity
时或无activity配置时做事件查找 xpath 为待查找控件的xpath 支持复杂型xpath,支持 index 索引选择 throttle 为该特殊步骤执行完后sleep n 毫秒 Action 支持
-
Click 点击匹配到的xpath控件
-
INPUTTEXT 在匹配到的xpath控件中输入 text 指定字符,输入需要提前安装adbkeyboard
-
TOUCH 点击指定坐标 args = (x,y)
-
SWIPE 按执行路径滑动 args = (x1,y1,x2,y2,step)
-
KEYEVENT 执行键盘事件 keycode
注 配置完成后请贴在 json.cn 检查格式,注意” : , 非中文 将该文件 push 到 /sdcard/max.xpath.actions
更多配置见下载地址 文档说明