app自动化测试平台实战 1
android 源码 :https://android.googlesource.com/platform/system/core/+/refs/tags/android-6.0.0_r5/adb/
Monkey
基本语法:
$ adb shell monkey [options] <event-count>
monkey命令:
usage: monkey [-p ALLOWED_PACKAGE [-p ALLOWED_PACKAGE] ...]
[-c MAIN_CATEGORY [-c MAIN_CATEGORY] ...]
[--ignore-crashes] [--ignore-timeouts]
[--ignore-security-exceptions]
[--monitor-native-crashes] [--ignore-native-crashes]
[--kill-process-after-error] [--hprof]
[--pct-touch PERCENT] [--pct-motion PERCENT]
[--pct-trackball PERCENT] [--pct-syskeys PERCENT]
[--pct-nav PERCENT] [--pct-majornav PERCENT]
[--pct-appswitch PERCENT] [--pct-flip PERCENT]
[--pct-anyevent PERCENT] [--pct-pinchzoom PERCENT]
[--pct-permission PERCENT]
[--pkg-blacklist-file PACKAGE_BLACKLIST_FILE]
[--pkg-whitelist-file PACKAGE_WHITELIST_FILE]
[--wait-dbg] [--dbg-no-events]
[--setup scriptfile] [-f scriptfile [-f scriptfile] ...]
[--port port]
[-s SEED] [-v [-v] ...]
[--throttle MILLISEC] [--randomize-throttle]
[--profile-wait MILLISEC]
[--device-sleep-time MILLISEC]
[--randomize-script]
[--script-log]
[--bugreport]
[--periodic-bugreport]
[--permission-target-system]
COUNT
调用关系:
Script to start "monkey" on the device, which has a very rudimentary
# shell.
#
base=/system
export CLASSPATH=$base/framework/monkey.jar
trap "" HUP
exec app_process $base/bin com.android.commands.monkey.Monkey $*
命令:
adb shell monkey -p com.xueqiu.android --throttle 500 -s 100 100
adb shell monkey -p com.xueqiu.android --throttle 500 --pct-touch 10 --pct-syskeys 90 100
Maxim
工具下载:
git clone git@github.com:zhangzhao4444/Maxim.git
下载完成后,将两个jar推到手机:
adb push framework.jar /sdcard
adb push monkey.jar /sdcard
执行命令:
adb shell CLASSPATH=/sdcard/monkey.jar:/sdcard/framework.jar exec app_process /system/bin tv.panda.test.monkey.Monkey -p com.panda.videoliveplatform --uiautomatormix --running-minutes 60 -v -v
appcrawler
生成配置文件
java -jar appcrawler-2.4.0-jar-with-dependencies.jar --demo
样例1:
- 点击我的,进行滑动,点击设置
- 在设置页面完成自动化遍历
capability:
noReset: "true"
fullReset: "false"
appium: "http://127.0.0.1:4723/wd/hub"
appPackage: "com.xueqiu.android"
appActivity: ".view.WelcomeActivityAlias"
testcase:
name: "TesterHome AppCrawler"
steps:
- xpath: "我的"
action: click
- xpath: //*
action: driver.swipe(0.5,0.9,0.5,0.1)
- xpath: "设置"
action: click
triggeraction去掉广告,处理弹窗:
triggerActions:
- xpath: "//*[@resource-id='com.xueqiu.android:id/iv_close']"
action: click
selectedList完成先后遍历:
capability:
noReset: "true"
fullReset: "false"
appium: "http://127.0.0.1:4723/wd/hub"
appPackage: "com.xueqiu.android"
appActivity: ".view.WelcomeActivityAlias"
testcase:
name: "TesterHome AppCrawler"
steps:
- xpath: "//*[@resource-id='com.xueqiu.android:id/tv_search']"
action: click
- xpath: "//*[@resource-id='com.xueqiu.android:id/search_input_text']"
action: "alibaba"
- xpath: "//*[@text='阿里巴巴-SW']"
action: click
- xpath: "//*[@text='09988' and @resource-id='com.xueqiu.android:id/stockCode']"
action: click
selectedList:
- xpath: "//*[@resource-id='com.xueqiu.android:id/small_period_container']//android.widget.TextView"
- xpath: "//*[@resource-id='com.xueqiu.android:id/tab_indicator_view']//android.widget.TextView"
firstList:
- xpath: "//*[@resource-id='com.xueqiu.android:id/tab_indicator_view']//android.widget.TextView"
作业
点击搜索 alibaba ,点击后进行 selectedList完成先后遍历