AppCrawler 在 AppCrawler 使用过程中碰到的问题

ChelseaZhang · 2018年02月28日 · 最后由 少年不识月 回复于 2020年11月19日 · 2358 次阅读

APPCrawler 运行过程中碰到几个问题,想请大家帮个忙,有没有好的解决方法或者思路

1. Android 7.0 设备上权限弹窗,如何自动化点掉?

目前我的方案是将 noReset 设置为 true,然后在执行之前通过 adb install -g 先安装;

2. 在运行过程中,出现弹窗后消掉弹窗,再获取 pagesource 就无响应了(更新一下,这个问题目前发现仅存在于 Android7.0 以上设备,换了个 5.X 的设备跑就没问题了)

这个问题折腾了快一下午了,有点抓狂😭 😭 😭 😭

共收到 20 条回复 时间 点赞

看下报错的提示吧,是不是 appium 的 bug?

看 appium 的 log 是没有报错的

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: source
[HTTP] --> GET /wd/hub/session/25dfe5b2-707b-4a1b-a5c8-f1a7f25f3be9/source {}
[MJSONWP] Calling AppiumDriver.getPageSource() with args: ["25dfe5b2-707b-4a1b-a5c8-f1a7f25f3be9"]
[HTTP] --> GET /wd/hub/session/25dfe5b2-707b-4a1b-a5c8-f1a7f25f3be9/source {}
[MJSONWP] Calling AppiumDriver.getPageSource() with args: ["25dfe5b2-707b-4a1b-a5c8-f1a7f25f3be9"]
[HTTP] --> GET /wd/hub/session/25dfe5b2-707b-4a1b-a5c8-f1a7f25f3be9/screenshot {}
[MJSONWP] Calling AppiumDriver.getScreenshot() with args: ["25dfe5b2-707b-4a1b-a5c8-f1a7f25f3be9"]

同时看到 APPcrawler 的 log,超时了,,然后就陷入了一个死循环

2018-03-01 13:20:50 INFO [Crawler.refreshPage.554] refresh page
2018-03-01 13:20:50 INFO [AppiumClient.getPageSource.308] start to get page source from appium
2018-03-01 13:21:10 ERROR [AppiumClient.asyncTask.149] 20 seconds timeout
2018-03-01 13:21:10 WARN [AppiumClient.$anonfun$getPageSource$1.340] get page source error
2018-03-01 13:21:30 ERROR [AppiumClient.asyncTask.149] 20 seconds timeout
2018-03-01 13:21:30 WARN [AppiumClient.$anonfun$getPageSource$1.340] get page source error
2018-03-01 13:21:50 ERROR [AppiumClient.asyncTask.149] 20 seconds timeout
2018-03-01 13:21:50 WARN [AppiumClient.$anonfun$getPageSource$1.340] get page source error
ChelseaZhang 回复

什么版本?

Appium 是 1.7.2 appcrawler 是 2.1.3

碰到了同样的问题,请问楼主后来解决了吗?

提问 appcrawler 可以测试原生和 h5 的混合 app 吗?刚开始研究不太懂

遇到了同样的问题

2018-05-15 12:36:24 INFO [Crawler.start.135] waiting for app load
2018-05-15 12:36:32 INFO [Crawler.start.137] driver=null
2018-05-15 12:36:32 INFO [Crawler.start.138] get screen info
2018-05-15 12:36:33 INFO [AppiumClient.getDeviceInfo.214] screenWidth=1024 screenHeight=768
2018-05-15 12:36:33 INFO [Crawler.refreshPage.537] refresh page
2018-05-15 12:36:53 ERROR [AppiumClient.asyncTask.146] 20 seconds timeout
2018-05-15 12:37:13 ERROR [AppiumClient.asyncTask.146] 20 seconds timeout
2018-05-15 12:37:33 ERROR [AppiumClient.asyncTask.146] 20 seconds timeout
Exception in thread "main" java.lang.NullPointerException
    at scala.collection.immutable.StringOps$.length$extension(StringOps.scala:48)
    at scala.collection.immutable.StringOps.length(StringOps.scala:48)
    at scala.collection.IndexedSeqOptimized$class.isEmpty(IndexedSeqOptimized.scala:27)
    at scala.collection.immutable.StringOps.isEmpty(StringOps.scala:30)
    at scala.collection.TraversableOnce$class.nonEmpty(TraversableOnce.scala:109)
    at scala.collection.immutable.StringOps.nonEmpty(StringOps.scala:30)
    at com.testerhome.appcrawler.Crawler.refreshPage(Crawler.scala:541)
    at com.testerhome.appcrawler.Crawler.start(Crawler.scala:140)
    at com.testerhome.appcrawler.AppCrawler$.startCrawl(AppCrawler.scala:342)
    at com.testerhome.appcrawler.AppCrawler$.parseParams(AppCrawler.scala:310)
    at com.testerhome.appcrawler.AppCrawler$.main(AppCrawler.scala:90)
    at com.testerhome.appcrawler.AppCrawler.main(AppCrawler.scala)

Appium 日志:

[MJSONWP] Calling AppiumDriver.getPageSource() with args: ["270dfaf3-4a1f-4f94-8528-187851c6e818"]
[XCUITest] Executing command 'getPageSource'
[JSONWP Proxy] Proxying [GET /source] to [GET http://localhost:8100/session/C2D926F9-396F-43E5-9819-AFC5FBAE63DA/source] with no body
[HTTP] --> GET /wd/hub/session/270dfaf3-4a1f-4f94-8528-187851c6e818/source
[HTTP] {}
[MJSONWP] Calling AppiumDriver.getPageSource() with args: ["270dfaf3-4a1f-4f94-8528-187851c6e818"]
[XCUITest] Executing command 'getPageSource'
[HTTP] --> GET /wd/hub/session/270dfaf3-4a1f-4f94-8528-187851c6e818/source
[HTTP] {}
[MJSONWP] Calling AppiumDriver.getPageSource() with args: ["270dfaf3-4a1f-4f94-8528-187851c6e818"]
[XCUITest] Executing command 'getPageSource'
[JSONWP Proxy] Got response with status 200: "{\n  \"value\" : \"\\n\\n  \\n    \\n      \\n        \\n          
[JSONWP Proxy] Proxying [GET /source] to [GET http://localhost:8100/session/C2D926F9-396F-43E5-9819-AFC5FBAE63DA/source] with no body
[MJSONWP] Responding to client with driver.getPageSource() result: "\n  \n    \n      \n        \n          \n  
木头 回复

发现跟页面元素多少有关,尤其是 iOS 的页面,尤其慢,但是用 appium inspector 时间虽长还是能最终获取页面的,读了下源码,超时日志是在 WebDriver.scala 输出的:

def asyncTask[T](timeout: Int = 30, restart: Boolean = false)(callback: => T): Option[T] = {
    Try({
      val task = Executors.newSingleThreadExecutor().submit(new Callable[T]() {
        def call(): T = {
          callback
        }
      })
      if(timeout<0){
        task.get()
      }else {
        task.get(timeout, TimeUnit.SECONDS)
      }

    })  match {
      case Success(v) => {
        appiumExecResults.append("success")
        Some(v)
      }
      case Failure(e) => {
        e match {
          case e: TimeoutException => {
            log.error(s"${timeout} seconds timeout") //----这里!这里!
            appiumExecResults.append("timeout")
          }
          case _ => {
ChelseaZhang 回复

这个问题解决了吗?我现在也在调这个问题,有啥好的解决方案?

我输入 java -jar appcrawler-2.1.3.jar -a XXXX.apk 跑,后面就出现如上图,这是什么原因,在哪个地方修改。

我也遇到了 appcrawler 不超时 不结束,commad+c 也不能结束的,也未输出日志文件;
楼主解决了吗

我这也出现这个问题,后面在 yml 配置文件中,capability 节点下面加个 automationName: "UiAutomator2" 就可以了

有没有解决这个问题呀?我也遇到了不知怎么解决,楼上的说 yml 文件修改,不知怎么操作。

Caroline 回复

此法有效,多谢

拂晓 回复

问题解决了吗

我也遇到了这个问题,但是我加了 automationName: "UiAutomator2"之后,get page source 这一步可以成功,但是接下来定位元素定位不到了

MLL 回复

把 appium 从 14 升级到 15 后 问题就消失了。。。

拂晓 回复

大佬 我的日子跟你一样一样的 不知道您解决了没啊

木头 回复

可以加我微信聊聊我也遇到这个问题了 601113614,有点蛋疼

iOS 基本找不到元素呀,求问为啥?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册