问题描述:
- 环境:mac电脑
- 移动端型号:vivo y70s
- 移动端系统:android 10 系统
- 问题复述:github上下载appcrawler的源代码,然后运行自带的xueqiu_private.yml配置文件,出现Exception in thread “main” scala.MatchError: [app, appium, autoLaunch, autoWebview, deviceName, launchTimeout, newCommandTimeout, noReset, platformName, platformVersion] (of class java.util.Collections$UnmodifiableSet)的报错
相关log文件
zhouguopingdeMacBook-Pro:appcrawler zhouguoping$ java -jar appcrawler-2.4.0.jar -c /Users/zhouguoping/IdeaProjects/AppCrawler/src/test/scala/com/testerhome/appcrawler/it/xueqiu_private.yml
2021-05-24 09:53:30 INFO [AppCrawler$.86.main]
AppCrawler 2.4.0 [霍格沃兹测试学院特别纪念版]
Appium 1.8.1 Java8 tested
app爬虫, 用于自动遍历测试. 支持Android和iOS, 支持真机和模拟器
致谢: 晓光 泉龙 杨榕 恒温 mikezhou yaming116 沐木
2021-05-24 09:53:30 INFO [AppCrawler$.203.parseParams] Find Conf /Users/zhouguoping/IdeaProjects/AppCrawler/src/test/scala/com/testerhome/appcrawler/it/xueqiu_private.yml
2021-05-24 09:53:31 INFO [AppCrawler$.223.parseParams] use default appium address 4723
2021-05-24 09:53:31 INFO [AppCrawler$.230.parseParams] appium address = Some(http://127.0.0.1:4723/wd/hub)
2021-05-24 09:53:31 INFO [AppCrawler$.242.parseParams] result directory = 20210524095330
2021-05-24 09:53:31 INFO [Crawler.130.start] set xpath attribute with List(name, label, value, resource-id, content-desc, instance, text)
2021-05-24 09:53:31 INFO [Crawler.135.start] set xpath
2021-05-24 09:53:31 INFO [Crawler.89.$anonfun$loadPlugins$2] com.testerhome.appcrawler.plugin.TagLimitPlugin@3976ebfa
2021-05-24 09:53:31 INFO [Crawler.89.$anonfun$loadPlugins$2] com.testerhome.appcrawler.plugin.ReportPlugin@4833eff3
2021-05-24 09:53:31 INFO [Crawler.89.$anonfun$loadPlugins$2] com.testerhome.appcrawler.plugin.FreeMind@56928e17
2021-05-24 09:53:31 INFO [TagLimitPlugin.19.init] com.testerhome.appcrawler.plugin.TagLimitPlugin init
2021-05-24 09:53:31 INFO [ReportPlugin.19.init] com.testerhome.appcrawler.plugin.ReportPlugin init
2021-05-24 09:53:31 INFO [FreeMind.19.init] com.testerhome.appcrawler.plugin.FreeMind init
2021-05-24 09:53:31 INFO [ReportPlugin.21.start] reportPath=/Users/zhouguoping/software/appcrawler/20210524095330
2021-05-24 09:53:31 INFO [ReportPlugin.24.start] create /Users/zhouguoping/software/appcrawler/20210524095330/tmp/ directory
2021-05-24 09:53:31 INFO [Crawler.138.start] prepare setup Appium
2021-05-24 09:53:31 INFO [Crawler.250.setupAppium] afterPageMax=2
2021-05-24 09:53:32 INFO [Crawler.273.setupAppium] use AppiumClient
2021-05-24 09:53:32 INFO [Crawler.274.setupAppium] Map(newCommandTimeout → 120, launchTimeout → 120000, platformVersion → 10, platformName → Android, appium → http://127.0.0.1:4723/wd/hub, autoWebview → false, autoLaunch → true, noReset → false)
Exception in thread “main” scala.MatchError: [app, appium, autoLaunch, autoWebview, deviceName, launchTimeout, newCommandTimeout, noReset, platformName, platformVersion] (of class java.util.Collections$UnmodifiableSet)
at com.testerhome.appcrawler.driver.AppiumClient.appium(AppiumClient.scala:94)
at com.testerhome.appcrawler.driver.AppiumClient.(AppiumClient.scala:40)
at com.testerhome.appcrawler.Crawler.setupAppium(Crawler.scala:277)
at com.testerhome.appcrawler.Crawler.start(Crawler.scala:139)
at com.testerhome.appcrawler.AppCrawler$.startCrawl(AppCrawler.scala:322)
at com.testerhome.appcrawler.AppCrawler$.parseParams(AppCrawler.scala:290)
at com.testerhome.appcrawler.AppCrawler$.main(AppCrawler.scala:91)
at com.testerhome.appcrawler.AppCrawler.main(AppCrawler.scala)
直接将后缀名为.log的文件拖入输入框即可
相关代码(包括log文件,都要使用markdown代码格式,)
appium: "http://127.0.0.1:4723/wd/hub"
defineUrl:
- “//*[@selected=‘true’]/@text”
- “//*[@selected=‘true’]/@text”
- “//*[contains(name(), ‘NavigationBar’)]/@label”
baseUrl:
- “.*MainActivity”
- “.SNBHomeView.”
maxDepth: 8
headFirst: true
enterWebView: true
urlBlackList:
- “.球友.”
- “.png.”
- “.Talk.”
- “.Chat.”
- “.Safari.”
- “WriteStatus.*”
- “Browser.*”
- “MyselfUser”
- “.MyselfUser.”
- “.股市直播.”
#urlWhiteList:
#- “.Main.”
backButton:
- xpath: //*[@resource-id=‘action_back’]
- xpath: //*[@resource-id=‘android:id/up’]
- xpath: //*[@resource-id=‘android:id/home’]
- xpath: //*[@resource-id=‘android:id/action_bar_title’]
- xpath: //*[@name=‘nav_icon_back’]
- xpath: //*[@name=‘Back’]
- xpath: //*[@name=‘返回’]
- xpath: “//*[contains(name(), ‘Button’) and @name=‘取消’]”
- xpath: “//*[contains(name(), ‘Button’) and @label=‘返回’]”
- xpath: “//*[contains(name(), ‘Button’) and @name=‘关闭’]”
- xpath: “//*[contains(name(), ‘Button’) and @name=‘首页’]”
firstList:
- xpath: “//[contains(name(), ‘Popover’)]//”
- xpath: “//[contains(name(), ‘Window’)][3]//”
- xpath: “//[contains(name(), ‘Window’)][2]//”
selectedList:
#android非空标签
- xpath: //*[@clickable=“true”]//android.widget.TextView[string-length(@text)>0 and string-length(@text)<20]
- xpath: //android.widget.EditText
#ios
- xpath: //*[contains(name(), ‘Text’) and string-length(@value)>0 and string-length(@value)<20 ]
#通用的button和image
- xpath: //*[contains(name(), ‘Button’)]
- xpath: //*[contains(name(), ‘Image’)]
#todo:如果多个规则都包含相同控件, 如何排序
#处于选中状态的同级控件最后点击
lastList:
- xpath: //[contains(@resource-id, ‘header’)]//
- xpath: //[contains(@resource-id, ‘indicator’)]//
#股票 组合
- xpath: //[…/[@selected=‘true’]]
#港股 美股
- xpath: //[…/…//*[@selected=‘true’] and @resource-id=‘’]
#tab标签
- xpath: //[…/…//*[@selected=‘true’] and contains(@resource-id, ‘tab_’)]
#ios 沪深 港股等栏目
- xpath: //[…/[@value=‘1’]]
#ios 底层tab栏
- xpath: //[contains(name(), ‘Button’) and …/[contains(name(), ‘Button’) and @value=‘1’]]
#tab低栏
- xpath: //[contains(@resource-id,‘tabs’)]//
blackList:
#排除掉ios的状态栏
- xpath: “//[contains(name(), ‘StatusBar’)]//”
#股票分组编辑. 同一个imageview有2个图代表不同的状态. 没法区分, 只能设置为黑名单
- xpath: //*[@resource-id=‘com.xueqiu.android:id/edit_group’]
- String: “.*Safari”
- String: “.电话.”
- String: “.Safari.”
- String: “发布”
- String: “action_bar_title”
- String: “.浏览器.”
- String: “message”
- String: “.*home”
- String: “首页”
- String: “Photos”
- String: “地址”
- String: “网址”
- String: “拉黑”
- String: “举报”
- String: “camera”
- String: “Camera”
- String: “nav_icon_home”
- String: “stock_item_.*”
- String: “.[0-9]{2}.”
- String: “发送”
- String: “保存”
- String: “确定”
- String: “up”
- String: “user_profile_icon”
- String: “selectAll”
- String: “cut”
- String: “copy”
- String: “send”
- String: “买[0-9]*”
- String: “卖[0-9]*”
- String: “聊天.*”
- String: “拍照.*”
- String: “发表.*”
- String: “回复.*”
- String: “加入.*”
- String: “赞助.*”
- String: “微博.*”
- String: “球友.*”
- String: “.开户.”
triggerActions:
- xpath: “//*[contains(@resource-id, ‘iv_close’)]”
- xpath: “//*[@resource-id=‘com.xueqiu.android:id/button_login’]”
times: 1
- action: “15600534760”
xpath: “//*[@resource-id=‘com.xueqiu.android:id/login_account’]”
times: 1
- xpath: “//*[@resource-id=‘com.xueqiu.android:id/login_account’]”
times: 1
- action: “hys2xueqiu”
xpath: “//*[@resource-id=‘com.xueqiu.android:id/login_password’]”
times: 1
- xpath: “button_next”
times: 1
- action: “15600534760”
xpath: “//*[contains(name(), ‘StaticText’) and contains(@name, ‘登录’)]”
times: 1
- action: “15600534760”
xpath: “//*[contains(name(), ‘TextField’) and contains(@value, ‘手机’)]”
times: 1
- action: “hys2xueqiu”
xpath: “//*[contains(name(), ‘SecureTextField’)]”
times: 1
- xpath: “//*[contains(name(), ‘Button’) and contains(@name, ‘登 录’)]”
times: 1
- xpath: “.*立即登录”
times: 2
- xpath: “//*[@name=‘登 录’]”
times: 2
- xpath: “//*[@name=‘登录’]”
times: 2
- action: “scroll left”
xpath: “专题”
times: 1
- xpath: “点此.*”
- xpath: “^放弃$”
- xpath: “不保存”
- xpath: “^确定$”
- xpath: “^关闭$”
- xpath: “^取消$”
- xpath: “稍后再说”
- xpath: “Cancel”
- xpath: “这里可以.*”
- xpath: “.搬到这里.”
- xpath: “我要退出”
- xpath: “tip_click_position”
- xpath: “common guide icon ok”
- xpath: “icon quotationinformation day”
times: 1
- xpath: “icon stock close”
- xpath: “隐藏键盘”
#一个神奇的符号
- xpath: //*[@label=‘✕’ and visible=‘true’]
times: 10
- action: 123
xpath: //*[contains(name(), “EditText”)]
times: 10
pri: 0
- xpath: 我知道了
tagLimit:
- xpath: //[…/[@selected=‘true’]]
count: 12
- xpath: //[…/…//*[@selected=‘true’]]
count: 12
capabilities.asMap().keySet() match {
case android if android.contains("appPackage")
| capabilities.getCapability("app").toString.trim.takeRight(4).contains(".apk") =>{
platformName="Android"
config("platformName", platformName)
driver = new AndroidDriver[WebElement](new URL(url), capabilities)
}
case ios if ios.contains("bundleId")
| ios.contains("udid")
| capabilities.getCapability("app").toString.trim.takeRight(4).contains(".ipa")
| capabilities.getCapability("app").toString.trim.takeRight(4).contains(".app") =>{
platformName="iOS"
config("platformName", platformName)
driver = new IOSDriver[WebElement](new URL(url), capabilities)
}
}
没有给出appPackage或者bundleid,不知道是Android还是iOS。加下这两个其中一个设置。
思寒老师是说的这项appPackage么?这一项上面有贴出来的
---
pluginList:
- "com.testerhome.appcrawler.plugin.FlowDiff"
#- "com.testerhome.appcrawler.plugin.ProxyPlugin"
logLevel: "TRACE"
saveScreen: true
showCancel: true
reportTitle: AppCrawler雪球内部版
screenshotTimeout: 20
tagLimitMax: 2
currentDriver: "android"
maxTime: 10800
resultDir: ""
capability:
newCommandTimeout: 120
launchTimeout: 120000
platformVersion: "10"
platformName: "Android"
autoWebview: "false"
autoLaunch: "true"
noReset: "false"
androidCapability:
deviceName: "000003b60e2cbcce"
appPackage: "com.xueqiu.android"
appActivity: ".view.WelcomeActivityAlias"
app: ""
appium: ```"http://127.0.0.1:4723/wd/hub"```
fullReset: false
noReset: true
automationName: uiautomator2
iosCapability:
deviceName: "iPhone 7 Plus"
bundleId: "com.xueqiu"
screenshotWaitTimeout: "10"
platformVersion: "10.2"
autoAcceptAlerts: "true"
automationName: xcuitest
app: "/Users/seveniruby/Library/Developer/Xcode/DerivedData/Snowball-ckpjegabufjxgxfeqyxgkmjuwmct/Build/Products/Debug-iphonesimulator/Snowball.app"
appium: ```"http://127.0.0.1:4723/wd/hub"```
defineUrl:
- "//*[@selected='true']/@text"
- "//*[@selected='true']/@text"
- "//*[contains(name(), 'NavigationBar')]/@label"
baseUrl:
- ".*MainActivity"
- ".*SNBHomeView.*"
maxDepth: 8
headFirst: true
enterWebView: true
urlBlackList:
- ".*球友.*"
- ".*png.*"
- ".*Talk.*"
- ".*Chat.*"
- ".*Safari.*"
- "WriteStatus.*"
- "Browser.*"
- "MyselfUser"
- ".*MyselfUser.*"
- ".*股市直播.*"
#urlWhiteList:
#- ".*Main.*"
backButton:
- xpath: //*[@resource-id='action_back']
- xpath: //*[@resource-id='android:id/up']
- xpath: //*[@resource-id='android:id/home']
- xpath: //*[@resource-id='android:id/action_bar_title']
- xpath: //*[@name='nav_icon_back']
- xpath: //*[@name='Back']
- xpath: //*[@name='返回']
- xpath: "//*[contains(name(), 'Button') and @name='取消']"
- xpath: "//*[contains(name(), 'Button') and @label='返回']"
- xpath: "//*[contains(name(), 'Button') and @name='关闭']"
- xpath: "//*[contains(name(), 'Button') and @name='首页']"
firstList:
- xpath: "//*[contains(name(), 'Popover')]//*"
- xpath: "//*[contains(name(), 'Window')][3]//*"
- xpath: "//*[contains(name(), 'Window')][2]//*"
selectedList:
#android非空标签
- xpath: //*[@clickable="true"]//android.widget.TextView[string-length(@text)>0 and string-length(@text)<20]
- xpath: //android.widget.EditText
#ios
- xpath: //*[contains(name(), 'Text') and string-length(@value)>0 and string-length(@value)<20 ]
#通用的button和image
- xpath: //*[contains(name(), 'Button')]
- xpath: //*[contains(name(), 'Image')]
#todo:如果多个规则都包含相同控件, 如何排序
#处于选中状态的同级控件最后点击
lastList:
- xpath: //*[contains(@resource-id, 'header')]//*
- xpath: //*[contains(@resource-id, 'indicator')]//*
#股票 组合
- xpath: //*[../*[@selected='true']]
#港股 美股
- xpath: //*[../../*/*[@selected='true'] and @resource-id='']
#tab标签
- xpath: //*[../../*/*[@selected='true'] and contains(@resource-id, 'tab_')]
#ios 沪深 港股等栏目
- xpath: //*[../*[@value='1']]
#ios 底层tab栏
- xpath: //*[contains(name(), 'Button') and ../*[contains(name(), 'Button') and @value='1']]
#tab低栏
- xpath: //*[contains(@resource-id,'tabs')]//*
blackList:
#排除掉ios的状态栏
- xpath: "//*[contains(name(), 'StatusBar')]//*"
#股票分组编辑. 同一个imageview有2个图代表不同的状态. 没法区分, 只能设置为黑名单
- xpath: //*[@resource-id='com.xueqiu.android:id/edit_group']
- ".*Safari"
- ".*电话.*"
- ".*Safari.*"
- "发布"
- "action_bar_title"
- ".*浏览器.*"
- "message"
- ".*home"
- "首页"
- "Photos"
- "地址"
- "网址"
- "拉黑"
- "举报"
- "camera"
- "Camera"
- "nav_icon_home"
- "stock_item_.*"
- ".*[0-9]{2}.*"
- "发送"
- "保存"
- "确定"
- "up"
- "user_profile_icon"
- "selectAll"
- "cut"
- "copy"
- "send"
- "买[0-9]*"
- "卖[0-9]*"
- "聊天.*"
- "拍照.*"
- "发表.*"
- "回复.*"
- "加入.*"
- "赞助.*"
- "微博.*"
- "球友.*"
- ".*开户.*"
triggerActions:
- xpath: "//*[contains(@resource-id, 'iv_close')]"
- xpath: "//*[@resource-id='com.xueqiu.android:id/button_login']"
times: 1
- action: "15600534760"
xpath: "//*[@resource-id='com.xueqiu.android:id/login_account']"
times: 1
- xpath: "//*[@resource-id='com.xueqiu.android:id/login_account']"
times: 1
- action: "hys2xueqiu"
xpath: "//*[@resource-id='com.xueqiu.android:id/login_password']"
times: 1
- xpath: "button_next"
times: 1
- action: "15600534760"
xpath: "//*[contains(name(), 'StaticText') and contains(@name, '登录')]"
times: 1
- action: "15600534760"
xpath: "//*[contains(name(), 'TextField') and contains(@value, '手机')]"
times: 1
- action: "hys2xueqiu"
xpath: "//*[contains(name(), 'SecureTextField')]"
times: 1
- xpath: "//*[contains(name(), 'Button') and contains(@name, '登 录')]"
times: 1
- xpath: ".*立即登录"
times: 2
- xpath: "//*[@name='登 录']"
times: 2
- xpath: "//*[@name='登录']"
times: 2
- action: "scroll left"
xpath: "专题"
times: 1
- xpath: "点此.*"
- xpath: "^放弃$"
- xpath: "不保存"
- xpath: "^确定$"
- xpath: "^关闭$"
- xpath: "^取消$"
- xpath: "稍后再说"
- xpath: "Cancel"
- xpath: "这里可以.*"
- xpath: ".*搬到这里.*"
- xpath: "我要退出"
- xpath: "tip_click_position"
- xpath: "common guide icon ok"
- xpath: "icon quotationinformation day"
times: 1
- xpath: "icon stock close"
- xpath: "隐藏键盘"
#一个神奇的符号
- xpath: //*[@label='✕' and visible='true']
times: 10
- action: 123
xpath: //*[contains(name(), "EditText")]
times: 10
pri: 0
- xpath: 我知道了
tagLimit:
- xpath: //*[../*[@selected='true']]
count: 12
- xpath: //*[../../*/*[@selected='true']]
count: 12
gszhou
10
因为如果不加······的话,新用户是发表不了话题,因为内容不能超过两个链接,天马老师建议把链接加上这个