自动遍历测试

占楼占楼占楼占楼

先占楼,至少输入8个字

占楼占楼占楼占楼

占楼,再来4字哈

占楼占楼占楼占楼

占楼占楼占楼占楼

来了来了~~~~

新人报道

课间作业 - 云配置

pluginList: []
saveScreen: true
reportTitle: "自动遍历测试实战-课间作业"
resultDir: "20200315132212"
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 2
capability:
  noReset: "true"
  fullReset: "false"
  appium: "http://127.0.0.1:4723/wd/hub"
  appPackage: com.xueqiu.android
  appActivity: .view.WelcomeActivityAlias
testcase:
  name: "行情-市场板块遍历"
  steps:
  - xpath: "//android.widget.TextView[@text='行情']"	
action: click
then:
- //*[contains(@text,'市场')]
selectedList:
  - xpath: //*[contains(@text,"A股")]
  - xpath: //*[contains(@text,"港股")]
  - xpath: //*[contains(@text,"美股")]
  - xpath: //*[contains(@text,"全球")]
  - xpath: //*[contains(@text,"基金")]
  - xpath: //*[contains(@text,"期货")]
  - xpath: //*[contains(@text,"更多")]
firstList: []
lastList: []
backButton:
- xpath: "Navigate up"
triggerActions: []
xpathAttributes:
- "name"
- "label"
- "value"
- "resource-id"
- "content-desc"
- "instance"
- "text"
sortByAttribute:
- "depth"
- "list"
- "selected"
findBy: "default"
defineUrl: []
baseUrl: []
appWhiteList: []
urlBlackList: []
urlWhiteList: []
  # - ".*Main.*"
blackList:
  - xpath: //*[contains(@resource-id,"action_search")]
  - xpath: //*[contains(@resource_id,"action_message")]
  - xpath: //*[contains(@text,'自选股')]
  - xpath: 雪球
  - xpath: 交易
  - xpath: 我的
beforeRestart: []
beforeElement:
- given: []
  when: null
  then: []
  xpath: "/*"
  action: "Thread.sleep(1000)"
  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: []

占楼,至少八个字

  • appcrawler版本:appcrawler-2.4.0-jar-with-dependencies.jar

  • 配置文件:

---
pluginList: []
saveScreen: true
reportTitle: ""
resultDir: "20200315113533"
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 10
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: 行情
  - xpath: 市场
    action: click
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
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"
- "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: []

指定steps报错了,报错信息如下:
2020-03-15 13:02:32 INFO [Crawler.163.start] run steps
2020-03-15 13:02:32 INFO [Crawler.237.runSteps] run testcases
2020-03-15 13:02:32 INFO [AutomationSuite.13.beforeAll] beforeAll
AutomationSuite:
2020-03-15 13:02:32 INFO [AutomationSuite.21.$anonfun$new$1] testcase start
2020-03-15 13:02:32 INFO [AutomationSuite.28.$anonfun$new$2] Step(null,null,null,行情,null,null,0)
2020-03-15 13:02:32 INFO [AutomationSuite.31.$anonfun$new$2] 行情
2020-03-15 13:02:32 INFO [AutomationSuite.32.$anonfun$new$2]
2020-03-15 13:02:32 INFO [Crawler.996.doElementAction] current element = Steps.tag=TextView.depth=12.id=tab_name.text=行情
2020-03-15 13:02:32 INFO [Crawler.997.doElementAction] current index = 1
2020-03-15 13:02:32 INFO [Crawler.998.doElementAction] current action = null
2020-03-15 13:02:32 INFO [Crawler.999.doElementAction] current xpath = //[@resource-id=“com.xueqiu.android:id/decor_content_parent”]//[@resource-id=“android:id/content”]//[@resource-id=“android:id/tabhost”]//[@resource-id=“android:id/tabs”]//*[@text=“行情” and @resource-id=“com.xueqiu.android:id/tab_name”]
2020-03-15 13:02:32 INFO [Crawler.1000.doElementAction] current url = Steps
2020-03-15 13:02:32 INFO [Crawler.1001.doElementAction] current tag path = hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TabHost/android.widget.LinearLayout/android.widget.TabWidget/android.widget.RelativeLayout/android.widget.TextView
2020-03-15 13:02:32 INFO [Crawler.1002.doElementAction] current file name = Steps.tag=TextView.depth=12.id=tab_name.text=行情
2020-03-15 13:02:32 INFO [AppCrawler$.59.saveReqHash] save reqHash to 1
2020-03-15 13:02:32 INFO [AppCrawler$.92.saveReqImg] save reqImg 20200315113533/1_Steps.tag=TextView.depth=12.id=tab_name.text=行情.click.png to 1
2020-03-15 13:02:32 INFO [AppCrawler$.76.saveReqDom] save reqDom to 1

  • run steps *** FAILED ***
    scala.MatchError: null
    at com.testerhome.appcrawler.Crawler.doElementAction(Crawler.scala:1012)
    at com.testerhome.appcrawler.AutomationSuite.$anonfun$new$2(AutomationSuite.scala:37)
    at com.testerhome.appcrawler.AutomationSuite.$anonfun$new$2$adapted(AutomationSuite.scala:27)
    at scala.collection.immutable.List.foreach(List.scala:389)
    at com.testerhome.appcrawler.AutomationSuite.$anonfun$new$1(AutomationSuite.scala:27)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
    at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
    at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
    at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
    at org.scalatest.Transformer.apply(Transformer.scala:22)

好像你步骤里不写action的话就会报错。。反正我这边是这样的,不写就会报你这个错,写了aciton: click 就没报错了

课间作业

---
pluginList: []
saveScreen: true
reportTitle: ""
resultDir: ""
waitLoading: 2000
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 10
capability:
  appPackage: com.xueqiu.android
  appActivity: .view.WelcomeActivityAlias
  platformName: Android
  automationName: uiautomator2
  noReset: true
  fullReset: false
  appium: "http://127.0.0.1:4723/wd/hub"
testcase:
  name: "XueQiu Market"
  steps:
  - xpath: "//*[@text='行情']"
    action: click
  - xpath: "//*[@text='市场']"
    action: click
selectedList:
- xpath: "//*[contains(@resource-id,'title_container')]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView"
  # 顶部 A股、港股、美股等

- xpath: "//*[contains(@resource-id,'indicator')]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout[contains(@resource-id,'title_container')]/android.widget.TextView"
  # 沪深、板块、科创等

- xpath: "//*[@resource-id='com.xueqiu.android:id/indices']//*[@clickable='true']"
  action: click
  # 中间栏目 新股新债图标等(有滑动如何解决?)

- xpath: "//*[contains(@resource-id,'quote_center_entrance_container')]//*[@clickable='true']"
  action: click
  # 港股 中间图标部分

- xpath: "//*[@resource-id='com.xueqiu.android:id/indices_pager']/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout"
  action: click
  # 中间指数部分(设置了但未点击?)

firstList:
- xpath: "//*[@resource-id='com.xueqiu.android:id/indices_pager']/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout"
  action: click
  # 中间指数部分(设置了但未点击?)
lastList:
- xpath: "//*[@resource-id='com.xueqiu.android:id/indices']//*[@clickable='true']"
  action: click
  # 中间栏目 新股新债图标等(有滑动如何解决?)

- xpath: "//*[contains(@resource-id,'quote_center_entrance_container')]//*[@clickable='true']"
  action: click
  # 港股 中间图标部分
- xpath: "//*[contains(@resource-id,'indicator')]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout[contains(@resource-id,'title_container')]/android.widget.TextView"
  # 沪深、板块、科创等

- xpath: "//*[contains(@resource-id,'title_container')]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.TextView"
  # 顶部 A股、港股、美股等

backButton:
- given: []
  when: null
  then: []
  xpath: "Navigate up"
  action: ""
  actions: []
  times: 0
triggerActions: []
xpathAttributes:
- "name"
- "label"
- "value"
- "resource-id"
- "content-desc"
#- "instance"
- "text"
sortByAttribute:
- "depth"
- "list"
- "selected"
findBy: "default"
defineUrl: []
baseUrl: []
appWhiteList: []
urlBlackList: []
urlWhiteList: []
blackList: []
beforeRestart: []
beforeElement:
- given: []
  when: null
  then: []
  xpath: "/*"
  action: "Thread.sleep(1000)"
  actions: []
  times: 0
afterElement: []
afterPage: []
afterPageMax: 2
tagLimitMax: 20
tagLimit:
- given: []
  when: null
  then: []
  xpath: "确定"
  action: ""
  actions: []
  times: 1000
- given: []
  when: null
  then: []
  xpath: "取消"
  action: ""
  actions: []
  times: 1000
- given: []
  when: null
  then: []
  xpath: "share_comment_guide_btn_name"
  action: ""
  actions: []
  times: 1000
assertGlobal: []


:grin:谢谢天马,每个步骤都加上action就OK了!

课间作业

注:testcase中不写action或值为null会报错

---
# 插件使用,默认提供ProxyPlugin、LogPlugin、tagLimitPlugin
# 可自定义插件扩展功能更好的遍历策略(放在项目的plugins下)
pluginList: []
# 保存操作页面的截图
saveScreen: true
# 生成报告名称
reportTitle: ""
# 运行结果目录
resultDir: "20200315150559"
# 等待加载时间(即每个操作超时时间)
waitLoading: 500
waitLaunch: 6000
showCancel: true
# 最大运行时间,即本次遍历运行时间?
maxTime: 120
# 最深遍历程度
maxDepth: 3
# appium启动项配置
capability:
  appPackage: "com.xueqiu.android"
  appActivity: ".view.WelcomeActivityAlias"
  noReset: "true"
  fullReset: "false"
  appium: "http://127.0.0.1:4723/wd/hub"
# 指定要操作的元素,遍历前工作
testcase:
  name: "test xueqiu"
  # 指定的多个操作元素
  steps:
  - xpath: //*[contains(@resource-id, "tab_name") and @text="行情"]
    action: click
  # 匹配某个条件的元素,默认click操作(testcase中不写action或值为null会报错),可以换成其他的操作如back、swipe
  - xpath: //*[contains(@resource-id, "title_text") and @text="市场"]
    action: click
# 需要被遍历的元素范围
selectedList:
# given、when、then?
# A股、港股、美股、全球、基金、期货、更多
- xpath: //*[contains(@resource-id, "viewpager")]//*[contains(@resource-id, "title_text")]
  times: 4
# A股下沪深、板块等,港股下港股、沪深港通等
- xpath: //*[contains(@resource-id, "pager")]/android.widget.TextView
  times: 3
# A股下新股新债、雪球热股等
- xpath: //*[contains(@resource-id, "entrance_view_pager")]/android.widget.TextView
  times: 3
# 下半部分带箭头标题栏:如A股-沪深下市场总览、大盘异动,A股-板块下行业板块等
- xpath: //android.widget.RelativeLayout[contains(@resource-id, "root")]
  times: 0
# 下半部分带箭头占一行标题栏:如A股-沪深下沪深榜单等
- xpath: //*[contains(@resource-id, "common_title")]
  times: 2
# 在selectedList中被优先遍历的元素
firstList: []
# 在selectedList中被最后遍历的元素
lastList:
- xpath: //*[contains(@resource-id, "viewpager")]//*[contains(@resource-id, "title_text")]
# 被测app中所有种类的返回按钮,方便某遍历中随机进行返回操作
backButton:
- xpath: //*[contains(@resource-id, "action_bar_back")]
- given: []
  when: null
  then: []
  xpath: //*[contains(@resource-id, "action_back")]
  action: click
  actions: []
  times: 0
# 遇到什么样的元素(xpath)执行什么操作(action)
triggerActions:
- given: []
  when: null
  then: []
  xpath: "share_comment_guide_btn"
  action: null
  actions: []
  # 表示本规则被应用几次,默认0表示永久生效
  times: 0
# 本次遍历支持的xpath定位方式,testcase、selectedList等定制的操作中xpath可用范围
xpathAttributes:
- "name"
- "label"
- "value"
- "resource-id"
- "content-desc"
- "instance"
- "text"
# 遍历策略的优先级(深度优先还是广度优先等)
sortByAttribute:
- "depth"
- "list"
- "selected"
findBy: "default"
defineUrl: []
baseUrl: []
appWhiteList: []
# appcrawler将每个页面定义为不同url,如 .Main
# 遍历的页面黑名单
urlBlackList: []
# 遍历的页面白名单,默认全部遍历
urlWhiteList: []
# 匹配条件的元素黑名单,遇到就跳过不操作
blackList:
- given: []
  when: null
  then: []
  xpath: ".*[0-9]{2}.*"
  action: null
  actions: []
  times: 0
beforeRestart: []
# 遇到匹配条件的元素之后执行的操作,如每个元素操作之后等待5s(防止操作太快页面还没加载完)
beforeElement:
- given: []
  when: null
  then: []
  xpath: "/*"
  action: "Thread.sleep(500)"
  actions: []
  times: 0
# 遇到匹配条件的元素之后执行的操作
afterElement: []
# 切换页面(url)之前的操作
afterPage: []
afterPageMax: 2
# 同一个tag操作的最大次数
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: []

课间作业

---
pluginList: []
saveScreen: true
reportTitle: ""
resultDir: ""
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 10
capability:
  appPackage: com.xueqiu.android
  appActivity: .view.WelcomeActivityAlias
  noReset: "true"
  fullReset: "false"
  dontStopAppOnReset: true
  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
selectedList:
- xpath: //*[@resource-id='com.xueqiu.android:id/indicator_layout']//*[contains(@class, 'TextView')]
         #中间下面涨幅榜部分

- xpath: //*[@resource-id='com.xueqiu.android:id/indicator']//*[contains(@class, 'TextView')]
         #顶部A股票部分
firstList: 
    - xpath: //*[@resource-id='com.xueqiu.android:id/indicator_layout']//*[contains(@class, 'TextView')]
         #优先执行,涨幅榜的遍历
         #执行顺序策略比较重要,如果先执行A股到最后由于不在A股的页签下,就无法点击到涨幅榜部分
         #关于深度设置:被测目标的深度如果小于设置的深度,发现还是会继续点击,此时是按照通用规则执行么
lastList:
    - xpath: //*[@resource-id='com.xueqiu.android:id/indicator']//*[contains(@class, 'TextView')]
         #最后执行A股票title的遍历
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: 20
  #最深层级12,偷懒设置成了20,发现行情与市场也算在深度范围内
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: []

课间作业:

---
pluginList: []
saveScreen: true
reportTitle: ""
resultDir: ""
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 10
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: //*[contains(@resource-id, 'tabs')]//*[@text='行情']
    action: click
  - xpath: 市场
    action: click

selectedList:
#A股、港股、美股、全球、基金等
- xpath: "//*[@resource-id='com.xueqiu.android:id/indicator']//*[contains(@class, 'TextView')]"
#上证指数、深证成指、创业板指等
- xpath: "//*[@resource-id='com.xueqiu.android:id/indices_pager']//*[@clickable='true']"
#新股新债、雪球热股、选股策略等
- 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')]"
#全球:各个指数的view
- xpath: "//*[@resource-id='com.xueqiu.android:id/recycler_view']//*[@clickable='true']"
#沪深、板块、科创等
- xpath: "//*[@resource-id='com.xueqiu.android:id/pager']//*[@resource-id='com.xueqiu.android:id/title_container']//*[contains(@class, 'TextView')]"

firstList:
- xpath: "//*[@resource-id='com.xueqiu.android:id/quote_center_entrance_container']//*[contains(@class, 'TextView')]"
- xpath: "//*[@resource-id='com.xueqiu.android:id/entrance_view_pager']//*[contains(@class, 'TextView')]"
- xpath: "//*[@resource-id='com.xueqiu.android:id/pager']//*[@resource-id='com.xueqiu.android:id/title_container']//*[contains(@class, 'TextView')]"
- xpath: "//*[@resource-id='com.xueqiu.android:id/indices_pager']//*[@clickable='true']"
- xpath: "//*[@resource-id='com.xueqiu.android:id/recycler_view']//*[@clickable='true']"

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



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: 10
tagLimitMax: 100
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: []

课间作业

---
pluginList: []
saveScreen: true
reportTitle: ""
resultDir: "20200318185718"
waitLoading: 500
waitLaunch: 6000
showCancel: true
maxTime: 10800
maxDepth: 10
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:
# 页面的最上面头部(A股、港股、美股等)
- xpath: "//*[contains(@resource-id, 'title_container')]/*/*/android.widget.TextView"
# (A股、港股、美股等)标签页下面的分标签(沪深、板块、场内、场外等)
- xpath: "//*[contains(@resource-id, 'indicator')]/*/*/*[contains(@resource-id, 'title_container')]/android.widget.TextView"
# A股页面下的大标签(雪球热股、龙虎榜等)
- xpath: "//*[contains(@resource-id, 'entrance_view_pager')]//android.widget.TextView"
# 美股页面下的大标签(选股策略等)
- xpath: "//*[contains(@resource-id, 'head_container')]/*/*[@class='android.widget.TextView' and not(contains(@resource-id, 'common_title'))]"
# 全球页面下的市场(恒生指数等)
- xpath: "//*[contains(@resource-id, 'recycler_view')]/*/android.widget.LinearLayout"
firstList: 
- xpath: "//*[contains(@resource-id, 'entrance_view_pager')]//android.widget.TextView"
- xpath: "//*[contains(@resource-id, 'head_container')]/*/*[@class='android.widget.TextView' and not(contains(@resource-id, 'common_title'))]"
- xpath: "//*[contains(@resource-id, 'indicator')]/*/*/*[contains(@resource-id, 'title_container')]/android.widget.TextView"
- xpath: "//*[contains(@resource-id, 'recycler_view')]/*/android.widget.LinearLayout"
lastList:
- xpath: "//*[contains(@resource-id, 'title_container')]/*/*/android.widget.TextView"
xpathAttributes:
- "name"
- "label"
- "value"
- "resource-id"
- "content-desc"
- "instance"
- "text"
sortByAttribute:
- "depth"
- "list"
- "selected"
findBy: "default"
defineUrl: []
baseUrl: []
appWhiteList: []
urlBlackList: []
urlWhiteList: []
blackList: []
beforeRestart: []
backButton:
- xpath: "//*[@content-desc='转到上一层级']"
- xpath: "//*[contains(@resource-id, 'action_back')]"
beforeElement: []
afterElement: []
afterPage: []
afterPageMax: 2
tagLimitMax: 10
tagLimit: []
assertGlobal: []


执行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: []