北京第三期_遍历测试_20180826

Monkey工具

参考连接:https://developer.android.com/studio/test/monkey

参数 用法 介绍
-p -p com.xueqiu.android 包名
-s -s 100 种子相同每次跑monkey的次序是一样的
–throttle –throttle 500 事件之间时间间隔 单位毫秒
–ignore-crashes –ignore-crashes 发生crash继续执行
–ignore-timeouts –ignore-timeouts 发生ANR继续运行
–pct-<事件类别> <百分比> –pct-appswitch 80 不同事件的占比调整
adb shell monkey -p com.xueqiu.android  -vvv 500 -s 100
adb shell monkey -p com.xueqiu.android -vvv --pct-motion 100 --throttle 1000 20

遍历测试

下载地址:http://10.130.33.185:8000/appcrawler-2.4.0-jar-with-dependencies.jar

源代码编译

git clone https://github.com/seveniruby/AppCrawler.git
git checkout 2.3.1
#如果有更新的话
git pull
#编译打包
mvn clean compile assembly:single
java -jar target/appcrawler-2.4.0-jar-with-dependencies.jar

YAML文件介绍: http://www.ruanyifeng.com/blog/2016/07/yaml.html

appcrawler配置说明:https://github.com/seveniruby/AppCrawler/blob/2.3.1/src/main/scala/com/testerhome/appcrawler/CrawlerConf.scala

AppCrawler

java -jar appcrawler-2.4.0-jar-with-dependencies.jar --capability "appPackage=com.xueqiu.android,appActivity=.view.WelcomeActivityAlias"

配置文件:

---
pluginList: []
saveScreen: true
#报告标题
reportTitle: "第三期演练"
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 10800
#深度控制
maxDepth: 2
#appium的设置
capability:
  appPackage: com.xueqiu.android
  appActivity: .view.WelcomeActivityAlias
  noReset: "true"
  fullReset: "false"
  appium: "http://127.0.0.1:4723/wd/hub"
#启动时候的过程控制
testcase:
  name: "TesterHome AppCrawler"
  steps:
  - xpath: "//*"
    action: "Thread.sleep(5000)"
#范围
selectedList:
- xpath: //*[@resource-id!='' and @clickable='true']/android.widget.ImageView
- xpath: //*[contains(@class, 'Image') and @resource-id!='' and @clickable='true']
- xpath: //android.widget.TextView[string-length(@text)<5 and @resource-id!='' ]
#顺序选择
firstList:
- xpath: //*[@resource-id!='' and @clickable='true']/android.widget.ImageView
- xpath: //*[contains(@resource-id, "tv_search")]
lastList:
- xpath: "//*[@selected='true']/../..//*"
backButton:
- given: []
  when: null
  then: []
  xpath: "Navigate up"
  action: null
  actions: []
  times: 0
#触发器
triggerActions:
- xpath: //*[contains(@class, "Edit")]
  action: alibaba
  times: 2
xpathAttributes:
- "name"
- "label"
- "value"
- "resource-id"
- "content-desc"
- "instance"
- "text"
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: "share_comment_guide_btn_name"
  action: null
  actions: []
  times: 1000
assertGlobal: []

半自动化

  dontStopAppOnReset: true

备注

  • 2.1.3与2.3.x版本配置不兼容,–demo参数可以生成各自的配置文件
  • firstList等配置不同,比如selectedList在2.1.3是个字符串数组,2.3.1的selectedList是个对象数组
  • 2.3.x windows上可能运行有问题

作业1

简单的遍历雪球首页

作业2

自动登陆,密码错也没关系

作业3

遍历雪球的行情页

关闭