自动遍历测试


执行java -jar appcrawler-2.4.0-jar-with-dependencies.jar --capability "appPackage=com.xueqiu.android,appActivity=.view.WelcomeActivityAlias"报错,
appium 报500 错误 。

pluginList:
saveScreen: true
reportTitle: “”
resultDir: “20200329205240”
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 3
capability:
appPackage: com.xueqiu.android
noReset: “true”
fullReset: “false”
appium: “http://127.0.0.1:4723/wd/hub
testcase:
name: “TesterHome AppCrawler”
steps:

  • xpath: “//[contains(@resource-id, ‘tabs’)]//[@text=‘行情’]”
    action: click
  • xpath: “//*[@text=‘市场’]”
    action: click
    actions:
    times: 0
    selectedList:
  • xpath: “//[@resource-id=‘com.xueqiu.android:id/indicator’]//[contains(@class,‘TextView’)]”
  • xpath: “//[@resource-id=‘com.xueqiu.android:id/indices’]//[@clickable=‘true’]”
    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
    firstList:
    lastList:
  • xpath: “//[@resource-id=‘com.xueqiu.android:id/indicator’]//[contains(@class, ‘TextView’)]”
    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”
  • “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:

课间作业:进入雪球app-行情-市场,遍历上半部分大标题和子标题

  • 问题1:执行到美股页面,标普500没有点击,反而点击行业板块
---
pluginList: []
saveScreen: true
reportTitle: "测试报告"
resultDir: "20200421110529"
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 10
# App启动信息
capability:
  appPackage: "com.xueqiu.android"
  appActivity: ".view.WelcomeActivityAlias"
  noReset: "true" # 不清理数据
  fullReset: "false"
  dontStopAppOnReset: "true" # 不停止app进程
  appium: "http://127.0.0.1:4723/wd/hub" # 连接appium服务

testcase:
# 测试用例名称
  name: "test_market"
  steps:
  - xpath: "//*[contains(@resource-id,'tab_name')and@text='行情']"
    action: click # 点击行情
  - xpath: "//*[contains(@resource-id,'title_text')and@text='市场']"
    action: click # 点击市场

selectedList:
# 大标题
- xpath: "//*[@resource-id='com.xueqiu.android:id/indicator']//*[contains(@class, 'TextView')]"
# A股、港股、美股、基金、更多股票指数入口
- xpath: "//*[@resource-id='com.xueqiu.android:id/indices_pager']//*[contains(@class,'TextView')]"
# A股专栏
- xpath: "//*[@resource-id='com.xueqiu.android:id/entrance_view_pager']//*[contains(@class,'TextView')]"
# 港股、美股专栏
- xpath: "//*[@resource-id='com.xueqiu.android:id/quote_center_entrance_container']//*[contains(@class,'TextView')]"

firstList: []
lastList:
# 最后点击A股等大标题元素
- xpath: "//*[@resource-id='com.xueqiu.android:id/indicator']//*[contains(@class, 'TextView')]"

backButton:
# 港股、美股开户无法返回,添加黑名单优先关闭
- xpath: "//*[contains(@resource-id, 'action_bar_close')]"
  action: click
#  actions: []
  times: 1
triggerActions:
- given: []
  when: null
  then: []
  xpath: "share_comment_guide_btn"
  action: null
  actions: []
  times: 0
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: 0
tagLimitMax: 50
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: []

课间作业

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: click
  - xpath: 市场
    action: click
selectedList:
#- xpath: "//*[@resource-id= 'com.xueqiu.android:id/indicator']"
# - xpath: "//*[contains(@resource-id, 'title_container')]/android.widget.TextView"
# A股开户 港股 全球
- xpath: "//*[@resource-id= 'com.xueqiu.android:id/indicator']//*[contains(@resource-id,'title_text')]"
# 沪深板块
- xpath: "//*[@resource-id= 'com.xueqiu.android:id/title_container']/*[@class='android.widget.TextView']"
#  A股开户 港股 全球 + 沪深板块
# - xpath: "//*[@resource-id= 'com.xueqiu.android:id/indicator']//*[@class='android.widget.TextView']"

# 上证指数
- xpath: "//*[@resource-id= 'com.xueqiu.android:id/index_name']"
# 新股新债
- xpath: "//*[@resource-id= 'com.xueqiu.android:id/entrance_view_pager']//*[@class='android.widget.TextView']"


firstList:
- xpath: "//*[@resource-id= 'com.xueqiu.android:id/entrance_view_pager']//*[@class='android.widget.TextView']"
- xpath: "//*[@resource-id= 'com.xueqiu.android:id/index_name']"
- xpath: "//*[@resource-id= 'com.xueqiu.android:id/title_container']/*[@class='android.widget.TextView']"
lastList:
- xpath: "//*[@resource-id= 'com.xueqiu.android:id/indicator']//*[contains(@resource-id,'title_text')]"