获取工具 一、下载adb: 第一种方式:下载Android platform-tools,安装完成后运行,install下载tools工具 。打开“我的电脑”—》属性—》系统高级设置—》环境变量—》编辑Path变量,将Android platform-tools路径添加到系统环境变量里。 第二种方式:直接下载adb工具将文件地址 加入环境变量
检查是否安装成功:
win+r cmd 输入 adb 展示详细信息安装正确
二、关于adb 的命令: 1.adb devices , 获取设备列表及设备状态
2.adb shell am monitor:获取包名(打开想要获取包名的APP即可)
3.查看app启动页Activity adb shell dumpsys window | findstr mCurrentFocus 命令,可以查看当前启动中的应用信息 打开app的时候启动该命令
4.monkey命令
adb shell monkey -p 包名 -v 10000 >d:/ford.log 全屏,防止点击到状态栏: adb shell settings put global policy_control immersive.full=* 取消全屏: adb shell settings put global policy_control null
5.appium python启动 启动appium程序 打开python:
引入一个包 appium-clent-agent
#coding=utf-8
from appium import webdriver
desired_caps = {
"platformName":"Android",
"platformVersion":"10.0.0",
"deviceName":"MQS7N19423008360",
"appPackage":"com.changanford.evos",
"appActivity":"com.changanford.evos.SplashActivity",
"automationName":"UiAutomator1",
"unicodeKeyboard":True,
"resetKeyboard":True,
"noReset":True
}
driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
三、.appcrawler 1.下载appcrawler https://pan.baidu.com/s/1dE0JDCH! 2.启动appium
1.2确保adb devices 设备在线
2.命令行启动appcrawler: 2.1启动安装好了的app: java -jar xxx.jar --capability “appPackage=包名,appActivity=启动页activity” -c xxxx.yml 2.2未安装程序启动app: java -jar D:/xxxx.jar -a xxx.apk -c xxxt1.yml
2.3查看jar包所在文件夹中的测试文件夹 index.html 3.修改yml配置信息
---
pluginList: []
#是否截图
saveScreen: true
#报告title
reportTitle: "FORD_report_20211110"
resultDir: "FORD_report"
# 在执行操作后等待多少毫秒刷新
waitLoading: 500
waitLaunch: 500
# 结果报告是否展示没有遍历被取消的控件
showCancel: true
# 最大运行时间
maxTime: 5000
# 默认的最大深度10, 结合baseUrl可很好的控制遍历的范围
maxDepth: 10
# appium的capability通用配置
capability:
noReset: "true"
fullReset: "false"
appium: "http://127.0.0.1:4723/wd/hub"
deviceName: "MQS7N19423008360"
appPackage: "com.changanford.evos"
appActivity: "com.changanford.evos.SplashActivity"
automationName: "uiautomator1"
platformName: "Android"
testcase:
name: "TesterHome AppCrawler"
steps:
- given: []
when: null
then: []
xpath: "/*"
action: "Thread.sleep(5000)"
actions: []
times: 0
#定义了哪些控件应该要被遍历到
selectedList:
- given: []
when: null
then: []
# 发现按钮
xpath: "//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.View[1]"
action: null
actions: []
times: 0
- given: []
when: null
then: []
#社区按钮 这个列表
xpath: "//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.view.View[1]"
action: null
actions: []
times: 0
- given: []
when: null
then: []
# 商城按钮列表
xpath: "//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[4]/android.widget.FrameLayout[1]/android.view.View[1]"
action: null
actions: []
times: 0
- given: []
when: null
then: []
# 我的
xpath: "//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[5]/android.widget.FrameLayout[1]/android.view.View[1]"
action: null
actions: []
times: 0
#哪些控件应该被先遍历
firstList: [
xpath: '//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]',
xpath: '//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]',
xpath: '//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[4]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]',
xpath: '//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[5]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]'
]
#哪些控件应该被最后遍历
lastList:
- given: []
when: null
then: []
xpath: ""
action: null
actions: []
times: 0
- given: []
when: null
then: []
xpath: "//me.majiajie.pagerbottomtabstrip.internal.CustomItemLayout/android.widget.FrameLayout[3]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]"
action: null
actions: []
times: 0
backButton:
- given: []
when: null
then: []
xpath: ""
action: null
actions: []
times: 0
# 特定条件触发动作的设置
triggerActions:
# 手机号
- given: []
when: null
then: []
xpath: '//*[@resource-id="com.changanford.evos:id/et_login_mobile"]'
action: 11000001048
actions: []
times: 1
# 验证码
- given: [ ]
when: null
then: [ ]
xpath: '//*[@resource-id="com.changanford.evos:id/et_login_sms_code"]'
action: 123456
actions: [ ]
times: 1
#遇到以下xpath点击
- xpath: '//*[@resource-id="com.changanford.evos:id/cancel"]'
- xpath: '//*[@resource-id="com.changanford.evos:id/submit"]'
- xpath: '//*[@resource-id="com.android.permissioncontroller:id/permission_allow_button"]'
- xpath: '//*[@resource-id="com.android.permissioncontroller:id/permission_deny_button"]'
- xpath: '//*[@resource-id="com.changanford.evos:id/btn_login"]'
# 自动生成的xpath表达式里可以包含的匹配属性
xpathAttributes:
- "name"
- "label"
- "value"
- "resource-id"
- "content-desc"
- "instance"
- "text"
# 先按照深度depth排序,再按照list排序,最后按照selected排序。后排序是优先级别最高的
sortByAttribute:
- "depth"
- "list"
- "selected"
findBy: "default"
defineUrl: []
baseUrl: []
appWhiteList: []
urlBlackList: []
urlWhiteList: []
blackList:
- given: []
when: null
then: []
xpath: ".*[0-9]{2}.*"
action: null
actions: []
times: 0
beforeRestart: []
beforeElement:
- given: []
when: null
then: []
xpath: "/*"
action: "Thread.sleep(500)"
actions: []
times: 0
afterElement: []
afterPage: []
afterPageMax: 2
tagLimitMax: 2
tagLimit:
- given: []
when: null
then: []
xpath: "确定"
action: null
actions: []
times: 1000
- given: []
when: null
then: []
xpath: "取消"
action: null
actions: []
times: 1000
- given: []
when: null
then: []
xpath: ""
action: null
actions: []
times: 1000
assertGlobal: []
|