使用的平台是 WSL2 + docker-android
,运行的指令是java -jar appcrawler-2.7.4-hogwarts.jar --capability "appPackage=com.One.WoodenLetter,appActivity=.LetterActivity,automationName=adb"
然后虚拟机加载进入软件主界面之后,Appcrawler一直有输出,但是并没有爬取任何内容,输出文件夹里也什么都没有。
具体输出如下
2022-03-24 20:15:38 INFO [Crawler.126.start] set xpath attribute with List(name(), name, label, value, resource-id, content-desc, text, id, name, innerText, tag, class)
2022-03-24 20:15:38 INFO [Crawler.130.start] set tag attribute with List(name(), name, label, resource-id, content-desc, id, name, tag, class)
2022-03-24 20:15:38 INFO [Crawler.100.$anonfun$loadPlugins$3] com.ceshiren.appcrawler.plugin.TagLimitPlugin@6d6cb754
2022-03-24 20:15:38 INFO [Crawler.100.$anonfun$loadPlugins$3] com.ceshiren.appcrawler.plugin.ReportPlugin@6b7d1df8
2022-03-24 20:15:38 INFO [Crawler.100.$anonfun$loadPlugins$3] com.ceshiren.appcrawler.plugin.FreeMind@3044e9c7
2022-03-24 20:15:38 INFO [Plugin.22.init] com.ceshiren.appcrawler.plugin.TagLimitPlugin init
2022-03-24 20:15:38 INFO [Plugin.22.init] com.ceshiren.appcrawler.plugin.ReportPlugin init
2022-03-24 20:15:38 INFO [Plugin.22.init] com.ceshiren.appcrawler.plugin.FreeMind init
2022-03-24 20:15:38 INFO [ReportFactory$.33.initReportPath] reportPath=/mnt/d/Codes/GUI/20220324201536_com.One.WoodenLetter
2022-03-24 20:15:38 INFO [ReportFactory$.35.initReportPath] testcaseDir=/mnt/d/Codes/GUI/20220324201536_com.One.WoodenLetter/tmp/
2022-03-24 20:15:38 INFO [ReportFactory$.38.initReportPath] create /mnt/d/Codes/GUI/20220324201536_com.One.WoodenLetter/tmp directory
2022-03-24 20:15:38 INFO [Crawler.137.start] prepare setup Appium
2022-03-24 20:15:38 INFO [Crawler.299.setupCrawler] afterAllMax=2
2022-03-24 20:15:40 INFO [Crawler.308.setupDriver] adb
2022-03-24 20:15:40 INFO [Crawler.318.setupDriver] user adb
2022-03-24 20:15:40 INFO [AdbDriver.35.<init>] need need to reset app
2022-03-24 20:15:40 INFO [AdbDriver.171.shell] /opt/sdk/platform-tools/adb shell am start -W -n com.One.WoodenLetter/.LetterActivity
2022-03-24 20:15:43 INFO [AdbDriver.175.shell] Starting: Intent { cmp=com.One.WoodenLetter/.LetterActivity }
Warning: Activity not started, its current task has been brought to the front
Status: ok
LaunchState: HOT
Activity: com.One.WoodenLetter/.LetterActivity
TotalTime: 1142
WaitTime: 1149
Complete
2022-03-24 20:15:43 INFO [Crawler.349.setupDriver] com.ceshiren.appcrawler.driver.AdbDriver@40d23c82
2022-03-24 20:15:44 DEBUG [DynamicEval$.113.load] first import
import sys.process._
val driver: com.ceshiren.appcrawler.driver.ReactWebDriver = com.ceshiren.appcrawler.driver.AdbDriver@40d23c82
def crawl(depth: Int): Unit
2022-03-24 20:15:47 INFO [Crawler.148.start] platformName= driver=com.ceshiren.appcrawler.driver.AdbDriver@40d23c82
2022-03-24 20:15:47 INFO [Crawler.149.start]
-------------------------------------------------
appcrawler v2.7.4 全平台自动遍历测试工具
Q&A: https://ceshiren.com/c/opensource/appcrawler
author: 思寒_seveniruby 天马 霍格沃兹测试开发学社
-------------------------------------------------
2022-03-24 20:15:47 INFO [Crawler.179.waitAppLoaded] start wait app loaded timeout = 10000
2022-03-24 20:15:48 INFO [Crawler.185.$anonfun$waitAppLoaded$1] wait for app loaded
2022-03-24 20:15:48 INFO [Crawler.693.refreshPage] refresh page
2022-03-24 20:15:48 INFO [ReactWebDriver.88.getPageSourceWithRetry] start to get page source from appium
2022-03-24 20:15:48 INFO [AdbDriver.171.shell] /opt/sdk/platform-tools/adb shell eval "[ -f /data/local/tmp/source.xml ] && rm /data/local/tmp/source.xml >/dev/null 2>&1 ;
uiautomator dump /data/local/tmp/source.xml > /dev/null;
cat /data/local/tmp/source.xml || echo ERROR "
Killed
cat: /data/local/tmp/source.xml: No such file or directory
2022-03-24 20:15:48 INFO [AdbDriver.175.shell] ERROR
2022-03-24 20:15:48 TRACE [ReactWebDriver.95.$anonfun$getPageSourceWithRetry$1] get raw page source success
2022-03-24 20:15:48 DEBUG [ReactWebDriver.98.$anonfun$getPageSourceWithRetry$1] ERROR
2022-03-24 20:15:48 ERROR [ReactWebDriver.102.$anonfun$getPageSourceWithRetry$1] may be page source is not enought
2022-03-24 20:15:48 ERROR [ReactWebDriver.103.$anonfun$getPageSourceWithRetry$1] ERROR
2022-03-24 20:15:48 ERROR [PageSource.31.getPagefromXML] Cannot invoke "String.replaceAll(String, String)" because "raw" is null
java.lang.NullPointerException: Cannot invoke "String.replaceAll(String, String)" because "raw" is null
at com.ceshiren.appcrawler.utils.XPathUtil$.toDocument(XPathUtil.scala:30)
at com.ceshiren.appcrawler.utils.XPathUtil.toDocument(XPathUtil.scala)
at com.ceshiren.appcrawler.model.PageSource.fromXML(PageSource.java:44)
at com.ceshiren.appcrawler.model.PageSource.getPagefromXML(PageSource.java:29)
at com.ceshiren.appcrawler.driver.ReactWebDriver.$anonfun$getPageSourceWithRetry$1(ReactWebDriver.scala:121)
at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:190)
at com.ceshiren.appcrawler.driver.ReactWebDriver.getPageSourceWithRetry(ReactWebDriver.scala:92)
at com.ceshiren.appcrawler.core.Crawler.refreshPage(Crawler.scala:694)
at com.ceshiren.appcrawler.core.Crawler.$anonfun$waitAppLoaded$1(Crawler.scala:186)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at com.ceshiren.appcrawler.utils.LogicUtils$$anon$1.call(LogicUtils.scala:69)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
2022-03-24 20:15:48 INFO [AdbDriver.171.shell] /opt/sdk/platform-tools/adb shell "dumpsys window windows | grep 'Focus.* .*/.*}' | grep -o '[^ /]*/[^ }]*' | head -1 "
2022-03-24 20:15:48 INFO [AdbDriver.175.shell]
2022-03-24 20:15:48 INFO [Crawler.711.parsePageContext] appName =
2022-03-24 20:15:48 TRACE [XPathUtil$.336.getNodeListByXPath] filted node list length 1
2022-03-24 20:15:48 INFO [Crawler.373.getUri] defineUrl=
2022-03-24 20:15:48 INFO [AdbDriver.171.shell] /opt/sdk/platform-tools/adb shell "dumpsys window windows | grep 'Focus.* .*/.*}' | grep -o '[^ /]*/[^ }]*' | head -1 "
2022-03-24 20:15:48 INFO [AdbDriver.175.shell]
2022-03-24 20:15:48 INFO [Crawler.715.parsePageContext] url=
2022-03-24 20:15:48 TRACE [Crawler.731.parsePageContext] urlStack=Stack()
2022-03-24 20:15:48 INFO [Crawler.742.parsePageContext] currentContentHash= lastContentHash=
2022-03-24 20:15:48 INFO [DataRecord.25.isDiff] just only record return false
2022-03-24 20:15:48 INFO [Crawler.746.parsePageContext] ui not change
2022-03-24 20:15:48 TRACE [XPathUtil$.233.getNodeListByXPath] nodeList length 0 with //*[contains(@text, 'App')]
2022-03-24 20:15:48 TRACE [XPathUtil$.336.getNodeListByXPath] filted node list length 0
2022-03-24 20:15:49 INFO [Crawler.185.$anonfun$waitAppLoaded$1] wait for app loaded
2022-03-24 20:15:49 INFO [Crawler.693.refreshPage] refresh page
2022-03-24 20:15:49 INFO [ReactWebDriver.88.getPageSourceWithRetry] start to get page source from appium
2022-03-24 20:15:49 INFO [AdbDriver.171.shell] /opt/sdk/platform-tools/adb shell eval "[ -f /data/local/tmp/source.xml ] && rm /data/local/tmp/source.xml >/dev/null 2>&1 ;
uiautomator dump /data/local/tmp/source.xml > /dev/null;
cat /data/local/tmp/source.xml || echo ERROR "
Killed
cat: /data/local/tmp/source.xml: No such file or directory
2022-03-24 20:15:50 INFO [AdbDriver.175.shell] ERROR
(之后陷入死循环)
后来还有一段红色字体的报错
2022-03-24 20:16:00 INFO [Crawler.160.start] append current app name to appWhiteList
2022-03-24 20:16:00 INFO [Crawler.164.start] run steps
2022-03-24 20:16:00 INFO [Crawler.286.runSteps] run testcases
AutomationSuite:
2022-03-24 20:16:00 INFO [AutomationSuite.16.beforeAll] beforeAll
2022-03-24 20:16:00 INFO [AutomationSuite.24.$anonfun$new$1] testcase start
2022-03-24 20:16:00 INFO [AutomationSuite.31.$anonfun$new$2] ---
given: []
when: null
then: []
xpath: "/*/*"
action: "Thread.sleep(1000)"
actions: []
times: -1
2022-03-24 20:16:00 TRACE [XPathUtil$.233.getNodeListByXPath] nodeList length 0 with /*/*
2022-03-24 20:16:00 TRACE [XPathUtil$.336.getNodeListByXPath] filted node list length 0
2022-03-24 20:16:00 INFO [Crawler.756.beforeElementAction] Steps.tag=.name=NOT_FOUND
2022-03-24 20:16:00 TRACE [Crawler.762.beforeElementAction] beforeElementAction
2022-03-24 20:16:00 INFO [Crawler.1043.doElementAction] current index = 1
2022-03-24 20:16:00 INFO [Crawler.1044.doElementAction] current xpath =
2022-03-24 20:16:00 INFO [Crawler.1045.doElementAction] current action = _Log
2022-03-24 20:16:00 INFO [Crawler.1046.doElementAction] current element = Steps.tag=.name=NOT_FOUND
2022-03-24 20:16:00 INFO [Crawler.1047.doElementAction] current url = Steps
2022-03-24 20:16:00 INFO [Crawler.1048.doElementAction] current tag path =
2022-03-24 20:16:00 INFO [Crawler.1049.doElementAction] current file name = Steps.tag=.name=NOT_FOUND
2022-03-24 20:16:00 INFO [URIElementStore.67.saveReqHash] save reqHash to 1
2022-03-24 20:16:00 INFO [URIElementStore.83.saveReqDom] save reqDom to 1
2022-03-24 20:16:00 INFO [URIElementStore.97.saveReqImg] save reqImg 20220324201536_com.One.WoodenLetter/1_Steps.tag=.name=NOT_FOUND.click.png to 1
2022-03-24 20:16:00 ERROR [AdbDriver.150.getRect] rect height < 0
2022-03-24 20:16:00 INFO [Crawler.1174.saveElementScreenshot] draw element in 20220324201536_com.One.WoodenLetter/1_Steps.tag=.name=NOT_FOUND.click.png
- run steps *** FAILED ***
java.lang.NullPointerException: Cannot read field "x" because "rect" is null
at com.ceshiren.appcrawler.core.Crawler.saveElementScreenshot(Crawler.scala:1177)
at com.ceshiren.appcrawler.core.Crawler.doElementAction(Crawler.scala:1053)
at com.ceshiren.appcrawler.core.AutomationSuite.$anonfun$new$2(AutomationSuite.scala:53)
at com.ceshiren.appcrawler.core.AutomationSuite.$anonfun$new$2$adapted(AutomationSuite.scala:30)
at scala.collection.immutable.List.foreach(List.scala:333)
at com.ceshiren.appcrawler.core.AutomationSuite.$anonfun$new$1(AutomationSuite.scala:30)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
...
2022-03-24 20:16:00 INFO [Crawler.693.refreshPage] refresh page
2022-03-24 20:16:00 INFO [ReactWebDriver.88.getPageSourceWithRetry] start to get page source from appium
2022-03-24 20:16:00 INFO [AdbDriver.171.shell] /opt/sdk/platform-tools/adb shell eval "[ -f /data/local/tmp/source.xml ] && rm /data/local/tmp/source.xml >/dev/null 2>&1 ;
uiautomator dump /data/local/tmp/source.xml > /dev/null;
cat /data/local/tmp/source.xml || echo ERROR "
2022-03-24 20:16:00 INFO [Crawler.185.$anonfun$waitAppLoaded$1] wait for app loaded
2022-03-24 20:16:00 INFO [Crawler.693.refreshPage] refresh page
2022-03-24 20:16:00 INFO [ReactWebDriver.88.getPageSourceWithRetry] start to get page source from appium
2022-03-24 20:16:00 INFO [AdbDriver.171.shell] /opt/sdk/platform-tools/adb shell eval "[ -f /data/local/tmp/source.xml ] && rm /data/local/tmp/source.xml >/dev/null 2>&1 ;
uiautomator dump /data/local/tmp/source.xml > /dev/null;
cat /data/local/tmp/source.xml || echo ERROR "
Killed
cat: /data/local/tmp/source.xml: No such file or directory
Killed
cat: /data/local/tmp/source.xml: No such file or directory
2022-03-24 20:16:03 INFO [AdbDriver.175.shell] ERROR
2022-03-24 20:16:03 INFO [AdbDriver.175.shell] ERROR
小白第一次使用这个工具,经验不足 ,还望见谅