利器 | AppCrawler 自动遍历测试实践(三):动手实操与常见问题汇总

本文详细介绍了AppCrawler自动遍历测试的配置与实战,包括testcase设置、selectedList、blackList、firstList、lastList、backButton、maxDepth等字段的使用,以及解决遍历过程中遇到的页面跳转、深度控制、元素遍历等问题,旨在帮助开发者更好地运用AppCrawler进行移动应用测试。
摘要由CSDN通过智能技术生成

上两篇文章介绍了自动遍历的测试需求、工具选择和 AppCrawler 的环境安装、启动及配置文件字段基本含义,这里将以实际案例更加细致的说明配置文件的用法和一些特殊场景的处理。

下面我们继续之前的例子,在雪球搜索框输入搜索内容后的页面开始:

  • testcase:设置测试用例,输入 alibaba 后,点选"阿里巴巴"

yaml 写法如下:

testcase:
  name: "XueQiuTestDemo AppCrawler"
  steps:
  - { xpath: "//*[contains(@resource-id,'image_cancel')]", action: click }
  - xpath: home_search
    action: click
  - xpath: search_input_text
    action: alibaba
  - { xpath: 阿里巴巴, action: click }

  • selectedList:遍历范围设定
  • 接上一步点选"阿里巴巴"后到达如下界面:

我们先看demo配置文件中的原始写法,如下:

selectedList:
- given: []
  when: null
  then: []
  xpath: "//*[contains(name(), 'Button')]"
  action: null
  actions: []
  times: 0
- given: []
  when: null
  then: []
  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

原始文件中将所有可点击的控件类型都包括了进去,再加上了部分 text 长度的限制 现在我们按照自己平常的简便写法重新编写,先设置所有 clickable 等于 true 的控件进行点击:

selectedList:
 - { xpath: "//*[@clickable='true']", action: click }

  • blackList:黑名单,将不想要被点击的元素加入黑名单中
  • 配置文件原始写法如下,表示将带有2位数字的排除在外,可能是App中包含了很对关于股价展示的,不需要挨个点击:
blackList:
- given: []
  when: null
  then: []
  xpath: ".*[0-9]{2}.*"
  action: null
  actions: []
  times: 0

我们现在希望不要点击到叉号

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值