测试人社区

初试appcrawler的问题

在极客时间上学习了思寒老师的appcrawler,添加blackList之后,运行appcrawler时会报错,想问下定义blackList的标准格式。
1,yaml配置文件:

urlWhiteList: []
blackList: 
  //*[@resource-id='com.aibs:id/action_bar_root']
beforeRestart: []

报错信息:

2020-11-12 15:30:03 INFO [AppCrawler$.186.parseParams] verbose=true

2020-11-12 15:30:03 INFO [AppCrawler$.187.parseParams] set global log level to TRACE

2020-11-12 15:30:03 INFO [AppCrawler$.203.parseParams] Find Conf /Users/yangyang/Work/Test/appcrawler/demo-ori.yml

Exception in thread "main" com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `scala.collection.mutable.ListBuffer` out of START_OBJECT token

 at [Source: (StringReader); line: 151, column: 3] (through reference chain: com.testerhome.appcrawler.CrawlerConf["blackList"])

at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)

at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1342)

at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1138)

at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1092)

at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:332)

at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:265)

at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)

at com.fasterxml.jackson.module.scala.deser.SeqDeserializer.deserialize(SeqDeserializerModule.scala:78)

at com.fasterxml.jackson.module.scala.deser.SeqDeserializer.deserialize(SeqDeserializerModule.scala:61)

at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)

at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)

at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)

at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001)

at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992)

at com.testerhome.appcrawler.TData$.fromYaml(TData.scala:63)

at com.testerhome.appcrawler.CrawlerConf.load(CrawlerConf.scala:195)

at com.testerhome.appcrawler.AppCrawler$.parseParams(AppCrawler.scala:204)

at com.testerhome.appcrawler.AppCrawler$.main(AppCrawler.scala:91)

at com.testerhome.appcrawler.AppCrawler.main(AppCrawler.scala)

2, 参考appcrawler-1.4.0.pdf 定义blacklist
image

urlWhiteList: []

blackList: ["微信", "客服"]

beforeRestart: []

报错信息:

2020-11-12 15:38:57 INFO [AppCrawler$.186.parseParams] verbose=true

2020-11-12 15:38:57 INFO [AppCrawler$.187.parseParams] set global log level to TRACE

2020-11-12 15:38:57 INFO [AppCrawler$.203.parseParams] Find Conf /Users/yangyang/Work/Test/appcrawler/demo-ori.yml

Exception in thread "main" com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.testerhome.appcrawler.Step` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('微信')

 at [Source: (StringReader); line: 150, column: 13] (through reference chain: com.testerhome.appcrawler.CrawlerConf["blackList"]->com.fasterxml.jackson.module.scala.deser.BuilderWrapper[0])

at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)

at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1342)

at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1031)

at com.fasterxml.jackson.databind.deser.ValueInstantiator._createFromStringFallbacks(ValueInstantiator.java:371)

at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:323)

at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1366)

at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:171)

at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:161)

at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)

at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)

at com.fasterxml.jackson.module.scala.deser.SeqDeserializer.deserialize(SeqDeserializerModule.scala:78)

at com.fasterxml.jackson.module.scala.deser.SeqDeserializer.deserialize(SeqDeserializerModule.scala:61)

at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)

at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)

at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)

at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001)

at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992)

at com.testerhome.appcrawler.TData$.fromYaml(TData.scala:63)

at com.testerhome.appcrawler.CrawlerConf.load(CrawlerConf.scala:195)

at com.testerhome.appcrawler.AppCrawler$.parseParams(AppCrawler.scala:204)

at com.testerhome.appcrawler.AppCrawler$.main(AppCrawler.scala:91)

at com.testerhome.appcrawler.AppCrawler.main(AppCrawler.scala)

你的文件格式不对。不是标准的yaml格式吧

谢谢老师,是的,后来找了yaml线上检查看了一下,格式不对。找到了最新的教程https://blog.csdn.net/weixin_46635091/article/details/105841147,学习了一下。
还有一些疑问:
1,文中提到:“遍历原则:它的遍历原则是,找页面的里层次最深的元素,也就是处于中心位置元素会被优先遍历”,如果有弹窗在主页面的上面,我想先去遍历这个弹窗,如何设置让appcrawler能先遍历前面的页面么?现在看到的现象是appcrawler先遍历了后面的主页。

2,testcase可以支持多个case么?我写成了下面的格式,会报错:
YAML:
testcase:

  • name: “Log in as gust”
    steps:
    • xpath: //[contains(@text, ‘游客’)]
      action: click
      then: ["//
      [contains(@text, ‘测试fail’)]"]
  • name: “Swipe at main page”
    steps:
    • xpath: //*
      action: driver.swipe(0.5, 0.8, 0.5, 0.2)
      then: ["//*[contains(@text, ‘推荐视频’)]"]
      错误信息:
      Exception in thread “main” com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of com.testerhome.appcrawler.ReactTestCase out of START_ARRAY token

at [Source: (StringReader); line: 29, column: 3] (through reference chain: com.testerhome.appcrawler.CrawlerConf[“testcase”])
问题:如何写配置可以支持多个testcase?

  1. 当遇到webview的时候,除了App打开webview的debug开关,配置文件的capibilty打开autoWebview,还需要做什么配置么? 在定位webview的页面时,定位规则和原生App一样么?