app穩定性、遍歷工具——appcrawler

AppCrawler

對app進行快速遍歷,底層引擎基於appium,支持Android和iOS。適合做隨機遍歷 或者 定製業務流遍歷。
https://github.com/seveniruby/AppCrawler   (由於github只能上傳100M以內,所以版本不是最新的)

 騰訊也有使用:https://security.tencent.com/index.php/blog/msg/105

1.appcrawler介紹

功能:

  • 自動化探索測試, 遍歷基本的界面, 瞭解主要界面的可用性. 比如兼容性, 基本功能
  • 利用遍歷獲取app的加載時間和性能數據, 需要藉助其他的性能數據抓取工具,比如OneApm, NewRelic
  • 利用遍歷驗證app的內存泄漏以及穩定性等功能, 需要藉助LeakCanary和MLeaksFinder
  • 自動化迴歸測試. UI diff 驗證新老版本的功能差異. 並識別細節的問題
  • 抓取接口請求 輔助驗證一些模塊基本接口, 並輔助分析接口調用流程. 爲接口測試做準備

2.安裝教程+問題解決:(目前最新版本2.1.0)

https://testerhome.com/wiki/appcrawler

https://seveniruby.gitbooks.io/appcrawler/content/

參考appetizers的相關配置,可以瞭解到appcrawler的使用需要以下參數:

給的示例配置文件:

---
pluginList:
- "com.testerhome.appcrawler.plugin.TagLimitPlugin"
- "com.testerhome.appcrawler.plugin.ReportPlugin"
logLevel: "TRACE"
reportTitle: "Keep"
saveScreen: true
screenshotTimeout: 20
currentDriver: "android"
showCancel: true
tagLimitMax: 3
tagLimit:
- xpath: //*[../*[@selected='true']]
  count: 12
maxTime: 10800
resultDir: ""
capability:
  newCommandTimeout: 120
  launchTimeout: 120000
  platformVersion: ""
  platformName: "Android"
  autoWebview: "false"
  autoLaunch: "true"
  noReset: "true"
  androidInstallTimeout: 180000
androidCapability:
  deviceName: "192.168.0.102:5555"
  appPackage: "com.gotokeep.keep"
  appActivity: ".activity.SplashActivity"
  app: ""
  appium: "http://127.0.0.1:4723/wd/hub"
#  automationName: uiautomator2
  automationName: macaca
  reuse: 3
#  nativeWebScreenshot: "true"
defineUrl:
- //*[@selected='true' and contains(name(), 'TextView')]/@text
appWhiteList:
- android
- com.shafa.market
baseUrl:
- ".*MainActivity"
- ".*SNBHomeView.*"
maxDepth: 20
headFirst: true
enterWebView: true
urlBlackList:
- .*OutdoorSummaryMap.*
- .*PersonalPage.*
- .*Training.*
- .*FriendRank.*
- .*\\.base\\.Container.*
- ".*球友.*"
- ".*png.*"
- ".*Talk.*"
- ".*Chat.*"
- ".*Safari.*"
- "WriteStatus.*"
- "Browser.*"
- "MyselfUser"
- ".*MyselfUser.*"
- ".*股市直播.*"
#urlWhiteList:
#- ".*Main.*"
backButton:
- //*[contains(@resource-id, "left_button")]
#defaultBackAction:
#- import sys.process._;
#- Thread.sleep(5000)
#- val name=Seq("adb", "shell", "dumpsys window windows | grep mCurrentFocus").!!.split(" ")(4).split("/")(0)
#- println(s"kill package ${name}")
#- Seq("adb", "shell", s"am force-stop ${name}").!!
#firstList:
#- //*[contains(@resource-id, "layout_picker_view_container"]
selectedList:
#android非空標籤
- //*[@clickable='true']
- //*[@clickable='true']//*[contains(name(), 'Text') and string-length(@text)>0 and string-length(@text)<10 ]
#通用的button和image
- //*[@clickable='true']//*[contains(name(), 'Button')]
- //*[@clickable='true']//*[contains(name(), 'Image')]
#todo:如果多個規則都包含相同控件, 如何排序
#處於選中狀態的同級控件最後點擊
lastList:
- //*[../*[@selected='true']]
- //*[../../*/*[@selected='true']]
- //*[../../*/*[@selected='true'] and contains(@resource-id, 'tab_')]
- //*[contains(name(), "HorizontalScrollView")]
- //*[@resource-id='com.gotokeep.keep:id/layout_bottom']
blackList:
- ".*\\.[0-9].*"
- ".*[0-9][0-9].*"
- //*[contains(@resource-id, "wrapper_in_custom_title_bar")]//*[contains(@resource-id, "right_button")]
- //*[contains(@resource-id, "share")]
- //*[contains(@text, "開始第")]
- //*[contains(@resource-id, "lock")]
- //*[contains(@text, "舉報")]
triggerActions:
- xpath: //*[contains(@resource-id, "layout_picker_view_container")]//*[@text="確定"]
- xpath: //*[contains(@resource-id, "content-wrapper_dialog")]//*[@text="不發了"]
- xpath: //*[@text="拒絕"]
- xpath: //*[@text="結束訓練"]
- xpath: //*[contains(@resource-id, "quit_confirm_button")]//*[contains(@text, "確定")]
- xpath: //*[contains(@resource-id, "layout_right_second_button")]//*[contains(@resource-id, "right_second_button")]
  action: yoga
  times: 1
- xpath: //*[contains(@text, "微信朋友圈")]
- xpath: //*[contains(@text, "發送")]
- xpath:
asserts:
- given:
  - //*[@text="胸部"]
  when: []
  then:
  - //*[contains(@text, "success")]
  - //*[@package="com.gotokeep.keep"]


#所有view的葉子節點 一般表示遊戲
#- action: monkey
#  xpath: //android.view.View[not(*) and contains(@bounds, "[0,0]") ]
#  times: 20
#startupActions:
#- println(driver)
#beforeElementAction:
#- xpath: //*[@resource-id="com.shafa.market:id/nav"]//android.widget.TextView
#  action: MiniAppium.event(21)
#- Thread.sleep(3000)
#- println(driver.getPageSource())
#afterElementAction:
#- println(driver)
#afterUrlFinished:
#- monkey()

 

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