参考地址
maxim:https://github.com/zhangzhao4444/Maxim
adbkeyboard: https://github.com/senzhk/ADBKeyBoard
monkey :UI/Application Exerciser Monkey | Android 开发者 | Android Developers
appcrawler:https://github.com/seveniruby/AppCrawler
monkey
- 产生事件
- 监控设备
- 1、是否运行在指定的app
- 2、app是否崩溃
- 3、app开启的子应用发生错误
maxim
介绍
- 对 Android Monkey 进行改进
- 基于遍历规则
- 高性能
用法
* adb push framework.jar /sdcard
* adb push monkey.jar /sdcard
执行命令:
adb shell CLASSPATH=/sdcard/monkey.jar:/sdcard/framework.jar exec app_process /system/bin tv.panda.test.monkey.Monkey -p com.panda.videoliveplatform --uiautomatormix --running-minutes 60 -v -v
遍历策略
- 模式 DFS (深度遍历算法 --uiautomatordfs )
- Mix模式 (—uiautomatormix )
- Troy 模式(选择策略,优先级遍历)
增加配置,实现特殊场景
- 增加白名单
- 增加黑名单
- 配置控件优先级,Troy模式
- 特殊配置(比如登录操作)
- 截图,dump.xml文件保存
增加白名单
- 修改文件 awl.strings
- 通过命令获取页面名称,首先打开模拟器要获取的页面,然后在命令行输入这条命令
adb shell dumpsys window |grep mCurrentFocus
。
- 通过命令获取页面名称,首先打开模拟器要获取的页面,然后在命令行输入这条命令
课上的demo如下:
修改文件 awl.strings
内容
com.xueqiu.android.common.MainActivity
com.xueqiu.android.stockmodule.stockdetail.StockDetailActivity
- 将文件push到手机中(/sdcard/)
- 运行增加参数: --act-whitelist-file /sdcard/awl.strings
黑名单 ,黑区域场景
- 场景:
- 1、控制某个坐标范围不被点击
- 2、屏蔽某个控件
- 3、当控件存在某个区域内,屏蔽该区域
- 应用:
- 1、配置文件
- 2、将文件推送到手机上
demo:
[
{
"activity":"com.xueqiu.android.stockmodule.stockdetail.StockDetailActivity",
"bounds": "[18,724][1419,1935]"
}
]
特殊配置(比如完成输入特定内容)
- 场景:
- 1、配置输入信息
- 2、登录操作
- 配置 max.xpath.actions
- 运行
- 安装 adbkeyboard (https://github.com/senzhk/ADBKeyBoard )
- 配置输入法:adb shell ime set com.android.adbkeyboard/.AdbIME
- 无须配置参数
demo:
注意格式 ,只支持json格式。
[
{
"prob":1,
"activity":"com.xueqiu.android.common.account.LoginActivity",
"actions":[
{
"xpath":"//*[@resource-id='com.xueqiu.android:id/login_account']",
"action":"INPUTTEXT",
"text":"18612466299",
"throttle":500
},
{
"xpath":"//*[@resource-id='com.xueqiu.android:id/login_password']",
"action":"INPUTTEXT",
"text":"123456",
"throttle":500
},
{
"xpath":"//*[@text='登录' and @class='android.widget.TextView']",
"index":0,
"action":"CLICK",
"throttle":2000
}
]
}
]
AppCrawler
官方:https://github.com/seveniruby/AppCrawler