AppCrawler 配置文件


java -jar appcrawler.jar --demo

demo.yml

# 插件列表
pluginList: [
  "com.testerhome.appcrawler.plugin.LogPlugin",
  "com.testerhome.appcrawler.plugin.TagLimitPlugin"
]
# 是否截圖
saveScreen: true
reportTitle: "Test Report"
# 結果目錄
resultDir: "D:\\appcrawler\\results\\20190907221950"
# 在執行操作后等待多少毫秒刷新
waitLoading: 500
waitLaunch: 6000
# 結果報告是否展示沒有遍歷被取消的控件
showCancel: true
# 最大運行時間
maxTime: 10800
# 默認的最大深度10, 結合baseUrl可很好的控制遍歷的范圍
maxDepth: 10
# appium的capability通用配置
capability:
  # Appium是否需要自動安裝和啟動應用。默認值true  
  autoLaunch: "true"
# 直接轉換到 WebView 上下文。 默認值 false    
  autoWebview: ""
# 不要在會話前重置應用狀態。默認值false。
  noReset: "true"
  fullReset: "false"
  appium: "http://127.0.0.1:4723/wd/hub"
  deviceName: "GWY0217124003040"
  appPackage: "com.xueqiu.android"
  appActivity: ".view.WelcomeActivityAlias"
  # dontStopAppOnReset: true
  automationName: "uiautomator2"
  platformName: "Android"
  #以下為重置手機輸入法為appium輸入法
  unicodeKeyboard: true
  resetKeyboard: true
# 測試用例
testcase:
  name: "demo1"
  steps:
  - given: []
    when: null
    then: []
    xpath: "/*"
    action: "Thread.sleep(5000)"
    actions: []
    times: 0
# 默認遍歷列表
selectedList:
- given: []
  when: null
  then: []
  xpath: "//android.widget.TextView[@text='交易']"
  action: "click"
  actions: []
  times: 0
- given: []
  when: null
  then: []
  xpath: "//android.widget.TextView[@text='我的']"
  action: "click"
  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: [ xpath: "//android.widget.TextView[@text='交易']", xpath: "//android.widget.TextView[@text='我的']" ] # 最后變量列表 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: "//android.widget.EditText[@text='請輸入手機號或郵箱']" action: "18701137212" actions: [] times: 1 - given: [] when: null then: [] xpath: "//android.widget.EditText[@text='請輸入登錄密碼']" action: "fengzi802300" actions: [] times: 1 - given: [] when: null then: [] xpath: "//android.widget.TextView[@text='登錄']" action: "click" actions: [] times: 1 # 自動生成的xpath表達式里可以包含的匹配屬性 xpathAttributes: - "name" - "label" - "value" - "resource-id" - "content-desc" - "instance" - "text" # 先按照深度depth排序,再按照list排序,最后按照selected排序。后排序是優先級別最高的 sortByAttribute: - "depth" - "list" - "selected" # 可選 default|android|id|xpath,默認狀態會自動判斷是否使用android定位或者ios定位 findBy: "default" # 用來確定url的元素定位xpath 他的text會被取出當作url因素 defineUrl: [] # 設置一個起始url和maxDepth, 用來在遍歷時候指定初始狀態和遍歷深度 baseUrl: [] # app白名單 appWhiteList: [] # url黑名單,用戶排除某些頁面 urlBlackList: [] # url白名單 urlWhiteList: [] # 黑名單列表 匹配風格, 默認排除內容是2個數字以上的控件 blackList: - given: [] when: null then: [] xpath: ".*[0-9]{2}.*" action: null actions: [] times: 0 # 在重啟session之前做的事情 beforeRestart: [] # 在執行action之前和之后默認執行的動作,比如等待 beforeElement: - given: [] when: null then: [] xpath: "/*" action: "Thread.sleep(500)" actions: [] times: 0 # 是否需要刷新或者滑動 afterElement: [] afterPage: [] # afterPage執行多少次后才不執行,比如連續滑動2次都沒新元素即取消 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 # 只需要寫given與then即可 assertGlobal: []

 

參數說明:

1.testcase

given:所有的先決條件(通過xpath的方式進行匹配)

when:先決條件成立后的行為

then:斷言集合

簡寫:

xpath:對應when里的xpath

action:對應when的action

2.動作支持 action

back 后退

backApp 回退到當前app

monkey 隨機事件

xxx() 執行代碼

Thread.sleep(3000)

driver.swipe(0.9,0.5,0.1,0.5)

click

longTap

其他為輸入操作

3.動作次數 times

0 無數次


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM