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來執行遍歷

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章