app稳定性、遍历工具-Maxim

目录

1.参考文档:

2.实际应用

3.报告展示:(报告这块做的不是很优美)

4.特殊事件支持

4.1例如登录操作:

4.2控件优先级(一定要遍历的控件):


1.参考文档:

https://github.com/zhangzhao4444/Maxim

https://testerhome.com/topics/11884

高速uiautomator控件解析算法的Android Monkey,支持多种模式运行。属于暴力快速遍历+性能捕获, 更能测试App 稳定性。

参考文档:
https://github.com/zhangzhao4444/Maxim

https://testerhome.com/topics/16909、

https://testerhome.com/topics/19618

https://testerhome.com/topics/11719

https://testerhome.com/topics/11884
 

2.实际应用

1.github上下载对应repo,push对应jar到手机的/sdcard上:

2.想要测试路径截图:

注:​​​​​​​

  • 配置true为小写,这里官方文档有点问题
  • 需要push max.config到/sdcard中

3.测试路径截图过多,会增加干扰信息,可以开启只崩溃时截图:

注:​​​​​​​

  • 配置true为小写,这里官方文档有点问题
  • 需要push max.config到/sdcard中

4.运行命令:

adb shell CLASSPATH=/sdcard/monkey.jar:/sdcard/framework.jar exec app_process /system/bin tv.panda.test.monkey.Monkey -p com.qunhe.designer --uiautomatormix --running-minutes 3 -v -v --throttle 400 --output-directory /sdcard/testreport/ --imagepolling

5.实际应用时的问题:

monkey的原命令:--ignore-crashes。通常,应用发生崩溃或异常时Monkey会停止运行。如果设置此项,Monkey将继续发送事件给系统,直到事件计数完成。但是如果启用了--running-minutes 则crash后会继续执行出现crash或者anr的后,会继续执行monkey,直到达到设定时间才会停止。maxim默认crash继续执行,直到达到设定时间才会停止。

3.报告展示:(报告这块做的不是很优美)

操作结果:覆盖到的activity和crash.log会存储在/sdcard/testreport目录下;相关crash截图也会存储在此目录:

同时,crash个数及相关log也会在命令提示符中展示:

4.特殊事件支持

4.1例如登录操作:

原文:https://testerhome.com/topics/11884
需要配置 max.xpath.action 文件
案例:

[
{
    "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
         }]
}
]

上述包含3个特殊事件
发生概率 prob =1 为100%发生
仅当 当前activity 为 tv.panda.account.activity.WebLoginActivity 时或无activity配置时做事件查找
xpath 为待查找控件的xpath 支持复杂型xpath,支持 index 索引选择
throttle 为该特殊步骤执行完后sleep n 毫秒
Action 支持
1.Click 点击匹配到的xpath控件
2.INPUTTEXT 在匹配到的xpath控件中输入 text 指定字符,输入需要提前安装adbkeyboard
3.TOUCH 点击指定坐标 args = (x,y)
4.SWIPE 按执行路径滑动 args = (x1,y1,x2,y2,step)

4.2控件优先级(一定要遍历的控件):

配置max.xpath.selector 控件优先级,max.xpath.selector 需要push 到/sdcard/

[
{
    "firstList":
    [
        {  "xpath": "//*[contains(@text,'绝地求生')]" }
    ],
    "selectList":
    [
        {  "xpath": "//*[@clickable='true']" },
        {  "xpath": "//*[@clickable='true']//*[contains(name(),'Text')]" },
        {  "xpath": "//*[@clickable='true']//*[contains(name(),'Button')]" },
        {  "xpath": "//*[@clickable='true']//*[contains(name(),'Image')]" }
    ],
    "lastList":
    [
        {  "xpath": "//*[../*[@selected='true']]" },
        {  "xpath": "//*[../../*/*[@selected='true']]" },
        {  "xpath": "//*[../../*/*[@selected='true'] and contains(@resource-id,'tab_')]" },
        {  "xpath": "//*[contains(@resource-id,'HorizontalScrollView')]" }
    ],
    "blackList":
    [
        {  "xpath": "//*[contains(@resource-id,'wrapper_in_custom_title_bar')]//*[contains(@resource-id,'right_button')]" },
        {  "xpath": "//*[contains(@resource-id,'share')]" }
    ]
}
]
控件选择策略会按 1first 2select 3last 并屏蔽black来执行遍历
发布了61 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_38204134/article/details/103368980