码迷,mamicode.com
首页 > 其他好文 > 详细

自动遍历测试

时间:2019-08-26 20:44:06      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:swipe   sea   guide   ted   white   text   har   als   col   

前沿:

1、版本迭代过程中,为了保证新功能之外 还要保证原有老功能不受影响且运行正常, 而老功能回归遍历的工作量太大,优先级又相对较低;不适合投入较大工作量;

2、使用UI自动化测试做回归遍历又有一些弊端, case过于繁琐,case量大,且运行case后的断言不易包含过多验证点; 因此使用UI自动化偏向于维护主流核心业务,且稳定性较高,链路不要太复杂为宜;

3、现有的monkey可控性差,稳定性差,不支持定制;

4、自动化遍历工具还适用于做健壮性测试;性能测试;专项测试等;

因此急需引入新的开源自动化遍历工具appcrawler, 解决以上痛点.

项目地址: https://github.com/seveniruby/AppCrawler

 

执行方法:

1、下载完成后, 启动Appium(该开源项目是基于Appium开发的);

2、在项目路径下 运行  生成配置文

java -jar appcrawler-2.4.0-jar-with-dependencies.jar --demo

  

3、自定义配置文件  vim demo.yml

pluginList: []

saveScreen: true     #是否截图

reportTitle: ""    #测试报告名字

resultDir: "20190826111341"

waitLoading: 500           #操作后的等待页面加载时间

waitLaunch: 6000         #加载app等待时间 ,一般会有加载广告

showCancel: true         #遍历页面时 页面中没有遍历到的内容是否展示

maxTime: 10800       #最多执行时间

maxDepth: 10        #遍历深度

capability:         #capability 是appium相关配置 除了appium(配置服务地址),其余项与appium配置一致

  noReset: "true"

  fullReset: "false"

  appium: "http://127.0.0.1:4723/wd/hub"

testcase:          #testcase用例配置  启动app后基础测试用例  自动化用例 比如想遍历某个模块,就配置进入该模块的步骤

  name: "TesterHome AppCrawler"

  steps:

  - given: []   #先决条件

    when: null  #条件成立后的执行行为

    then: []    #断言

    xpath: "/*" #when行为中的元素定位

    action: "Thread.sleep(5000)" #when行为元素的操作

    actions: []

    times: 0

 

 - when:   #简写形态,可以直接写when 寻找定位元素后 对其进行操作

    xpath: "/*" #when行为中的元素定位  元素定位可以使用xpath  正则  包含关系

       action: "Thread.sleep(5000)" #when行为元素的操作  默认是点击行为  可以改成函数driver.swipe(,,,) monkey随机事件,长按longTap,后退backApp(可以定制),

 - xpath:我的

   action:点击

  then:

 

selectedList:      #selectedList 被选择控件清单列表,列表中没有 遍历过程中将不会被选中  可以在这个地方设置用例的遍历模块范围

- given: []

  when: null

  then: []

  xpath: "//*[contains(name(), ‘Button‘)]"   #遍历页面所有button

  action: null

  actions: []

  times: 0

- given: []

  when: null

  then: []                     #遍历所有文本 且文本可被点击 长度小于10

  xpath: "//*[contains(name(), ‘Text‘) and @clickable=‘true‘ and string-length(@text)<10]"

  action: null

  actions: []

  times: 0

- given: []

  when: null

  then: []

  xpath: "//*[@clickable=‘true‘]/*[contains(name(), ‘Text‘) and string-length(@text)<10]"

  action: null

  actions: []

  times: 0

- given: []

  when: null

  then: []

  xpath: "//*[contains(name(), ‘Image‘) and @clickable=‘true‘]"

  action: null

  actions: []

  times: 0

- given: []

  when: null

  then: []

  xpath: "//*[@clickable=‘true‘]/*[contains(name(), ‘Image‘)]"

  action: null

  actions: []

  times: 0

- given: []

  when: null

  then: []

  xpath: "//*[contains(name(), ‘Image‘) and @name!=‘‘]"

  action: null

  actions: []

  times: 0

- given: []

  when: null

  then: []

  xpath: "//*[contains(name(), ‘Text‘) and @name!=‘‘ and string-length(@label)<10]"

  action: null

  actions: []

  times: 0

firstList: []  #优先遍历

lastList:    #最后遍历

- given: []

  when: null

  then: []

  xpath: "//*[@selected=‘true‘]/..//*"

  action: null

  actions: []

  times: 0

- given: []

  when: null

  then: []

  xpath: "//*[@selected=‘true‘]/../..//*"

  action: null

  actions: []

  times: 0

backButton:     #后退按钮

- given: []

  when: null

  then: []

  xpath: "Navigate up"

  action: null

  actions: []

  times: 0

triggerActions:      #遇到特点事件时触发动作, 一般处理弹窗

- given: []

  when: null

  then: []

  xpath: "share_comment_guide_btn"

  action: null

  actions: []

  times: 0

xpathAttributes:  #默认带哪些属性

- "name"

- "label"

- "value"

- "resource-id"

- "content-desc"

- "instance"  #动态变化的元素 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: []

4、执行 java -jar <appcrawler Path> -c demo.yml -capability "appPackage=,appActivity=" -o /path/report


pluginList: []
saveScreen: false
reportTitle: "演练"
resultDir: ""
waitLoading: 1000
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 10
capability:
appPackage: com.xueqiu.android
appActivity: .view.WelcomeActivityAlias
noReset: "true"
fullReset: "false"
unicodeKeyboard: true
resetKeyboard: true
appium: "http://127.0.0.1:4723/wd/hub"

testcase:
name: "TesterHome AppCrawler"
steps:
- xpath: //*[@text=‘行情‘]/../android.widget.ImageView              #点击行情
- xpath: //*[contains(@resource-id, ‘buttons_container‘)]//*[@text=‘私募‘]  #点击私募
- { xpath: 私募排行,action: back }                      #点击返回

selectedList:  #遍历模块范围
- xpath: //*[contains(@resource-id, ‘buttons_container‘)]//android.widget.TextView
- xpath: //*[contains(@resource-id, ‘ti_tab_indicator‘)]//android.widget.TextView
- xpath: //*[contains(@resource-id, ‘ll_stock_item_container‘)]//android.widget.TextView

firstList:
- xpath: 基金
lastList:
- xpath: 极速开户
backButton:
- xpath: 转到上一层级
triggerActions:   #遇到特定事件执行特定操作;遍历之前执行操作,进入固定页面  (也可以用于执行固定操作,如去弹框)
- xpath: //*[contains(@resource-id, ‘home_search‘)]//*[contains(@resource-id, ‘tv_search‘)]
times: 1
- xpath: //android.widget.EditText  #定位输入框
action: alibaba  #执行输入操作
times: 1
xpathAttributes:
- "name"
- "label"
- "value"
- "resource-id"
- "content-desc"
#- "instance"
- "text"
sortByAttribute:
- "depth"
- "list"
- "selected"
findBy: "xpath"
defineUrl: []
baseUrl: []
appWhiteList: []
urlBlackList: []
urlWhiteList: []
blackList:
- given: []
when: null
then: []
xpath: ".*[0-9]{2}.*"
action: ""
actions: []
times: 0
beforeRestart: []
beforeElement:
- given: []
when: null
then: []
xpath: "/*"
action: "Thread.sleep(500)"
actions: []
times: 0
afterElement: []
afterPage: []
afterPageMax: 2
tagLimitMax: 5
tagLimit:
- xpath: //*[contains(@resource-id, ‘ti_tab_indicator‘)]//android.widget.TextView
times: 10
assertGlobal: []

 

技术图片

 

自动遍历测试

标签:swipe   sea   guide   ted   white   text   har   als   col   

原文地址:https://www.cnblogs.com/1026164853qqcom/p/11411439.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!