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、GT),提供前端性能基线
- 利用遍历验证app的crash问题(appcrawler已支持),验证app的内存泄漏以及稳定性等功能(需要借助LeakCanary和MLeaksFinder)
- 增加代码覆盖率
- 自动化回归测试. UI diff 验证新老版本的功能差异. 并识别细节的问题
- 抓取接口请求 辅助验证一些模块基本接口, 并辅助分析接口调用流程. 为接口测试做准备
2.安装教程+问题解决:(目前最新版本2.4.0,对应appium版本1.12.0)
https://testerhome.com/wiki/appcrawler
https://seveniruby.gitbooks.io/appcrawler/content/
https://github.com/seveniruby/AppCrawler/tree/master/doc
参考appetizers的相关配置,可以了解到appcrawler的使用需要以下参数:
给的示例配置文件:
扫描二维码关注公众号,回复:
9277524 查看本文章
---
#插件列表
#pluginList:
#- "com.testerhome.appcrawler.plugin.FlowDiff"
#- "com.testerhome.appcrawler.plugin.ProxyPlugin"
#- "com.testerhome.appcrawler.plugin.TagLimitPlugin"
#- "com.testerhome.appcrawler.plugin.ReportPlugin"
reportTitle: AppCrawler-acp4.7
currentDriver: "android"
# 结果目录
resultDir: ""
# 最大运行时间
maxTime: 10800
logLevel: "TRACE"
#结果报告是否展示没有遍历被取消的控件
showCancel: true
#特定元素的tag布局层级完全一样时的遍历最大值
tagLimitMax: 4
tagLimit:
- xpath: //*[../*[@selected='true']]
count: 12
#是否截图
saveScreen: true
screenshotTimeout: 20
# appium的capability通用配置
capability:
newCommandTimeout: 120
launchTimeout: 120000
platformVersion: ""
platformName: ""Android""
# Appium是否需要自动安装和启动应用。默认值true
autoLaunch: "true"
# 直接转换到 WebView 上下文。 默认值 false
autoWebview: "false"
# 不要在会话前重置应用状态。默认值false。
noReset: "false"
androidInstallTimeout: 180000
# android专属配置 最后会和capability合并
androidCapability:
deviceName: "192.168.58.101:5555"
appPackage: "com.sinacp.ggaicai"
appActivity: "com.aicai.pluginhost.activity.MainActivity"
app: "/home/cmd/appcrawler/acp4.7p.apk"
# 你想使用的自动化测试引擎 可以是 uiautomator2 macaca 等 默认appium
automationName: appium/uiautomator2/macaca
appium: "http://127.0.0.1:4730/wd/hub"
macaca: "http://127.0.0.1:3456/wd/hub"
fullReset: false
noReset: true
reuse: 3
#以下为重置手机输入法为appium输入法
unicodeKeyboard: true
resetKeyboard: true
iosCapability:
deviceName: "iPhone 6 Plus"
bundleId: "com.sinacp.ggaicai"
screenshotWaitTimeout: "10"
platformVersion: "9.3"
autoAcceptAlerts: "true"
app: "/home/cmd/appcrawler/acp4.7p.apk"
appium: "http://127.0.0.1:4730/wd/hub"
#appWhiteList:
#- android
#- com.shafa.market
# 用来确定url的元素定位xpath 他的text会被取出当作url因素
#defineUrl:
- //*[@selected='true' and contains(name(), 'TextView')]/@text
# 设置一个起始url和maxDepth, 用来在遍历时候指定初始状态和遍历深度
#baseUrl:
- ".*MainActivity"
- ".*SNBHomeView.*"
# 默认的最大深度10, 结合baseUrl可很好的控制遍历的范围
maxDepth: 10
# 是否是前向遍历或者后向遍历
headFirst: true
# 是否遍历WebView控件
enterWebView: true
# url黑名单.用于排除某些页面
#urlBlackList:
- .*OutdoorSummaryMap.*
- .*PersonalPage.*
- .*Training.*
- .*FriendRank.*
- .*\\.base\\.Container.*
- ".*球友.*"
- ".*png.*"
- ".*Talk.*"
- ".*Chat.*"
- ".*Safari.*"
- "WriteStatus.*"
- "Browser.*"
- "MyselfUser"
- ".*MyselfUser.*"
- ".*股市直播.*"
#urlWhiteList:
#- ".*Main.*"
# 后退按钮标记, 主要用于iOS, xpath
#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"]
# 优先遍历元素特征列表
firstList:
#- "//*[contains(@resource-id,'com.acp.main:id/tvBottomTab4')]//android.widget.TextView"
- "//*[contains(@resource-id,'com.acp.main:id/tvBottomTab3')]//android.widget.TextView"
#- //*[contains(@resource-id, "layout_picker_view_container"]
# 默认遍历元素特征列表 需要注意的是firstList和lastList指定的元素必须包含在selectedList中
#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']
# 黑名单列表 matches风格, 默认排除内容是2个数字以上的控件
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, "举报")]
- "//*[contains(@resource-id,'com.acp.main:id/tvBottomTab4')]//android.widget.TextView"
- //*[@resource-id='com.acp.main:id/module_tj1_name']
- //*[@resource-id='com.acp.main:id/module_tj1_description']
# 引导规则. name, value, times三个元素组成
triggerActions:
- action: "yourname"
xpath: "//*[@resource-id='com.sinacp.ggaicai:id/etUserName']"
times: 1
- action: "yourpasswd"
xpath: "//*[@resource-id='com.sinacp.ggaicai:id/etPwd']"
times: 1
- xpath: //*[contains(@resource-id, "layout_picker_view_container")]//*[@text="确定"]
- xpath: //*[contains(@resource-id, "content-wrapper_dialog")]//*[@text="不发了"]
- xpath: //*[@text="拒绝"]
- xpath: //*[@text="结束训练"]