问题描述:

最近使用vivo X21A进行APP自动化测试过程中,发现程序运行过程中突然中断,查看报错信息 Error: socket hang up。appium 自动化测试,运行平台 vivo X21A真机驱动框架 UiAutomator2现象自动化代码在vivo手机上运行一段时间之后,appium 会报错 Could not proxy command to remote server. Original error: Error: socket hang up

原因分析:

appium日志

  1. [debug] [W3C (9ae907c5)] Encountered internal error running command:UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: socket hang up
  2. [debug] [W3C(9ae907c5)]at JWProxy.command(/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:261:13)
  3. [HTTP] <-- POST /wd/hub/session/9ae907c5-5319-4f0b-92dc-fdaa47cfdcc5/element 500 139ms - 530

解决方案:

尝试下列方法,但是无效:

卸载重装vivo手机上的appium 驱动应用,包括如下几个:

  • io.appium.settings
  • io.appium.uiautomator2.server
  • io.appium.uiautomator2.server.test

Logcat抓手机日志发现问题

02-29 09:43:32.216 28683 28944 I appium : Waiting up to 10000ms for device to be idle
02-29 09:43:32.236 1742 15589 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10271 user=0: stop by com.vivo.abe
02-29 09:43:32.236 701 701 E ANDR-IOP: IOP HAL: Received pkg_name = io.appium.uiautomator2.server pid = 0
02-29 09:43:32.237 1742 15589 I ActivityManager: Killing 28683:io.appium.uiautomator2.server/u0a271 (adj 0): stop by com.vivo.abe
02-29 09:43:32.239 701 701 E ANDR-IOP: IOP HAL: Received pkg_name = io.appium.uiautomator2.server pid = 0
罪魁祸首暴露啦 ~~~~ Force stopping io.appium.uiautomator2.server appid=10271 user=0: stop by com.vivo.abe

原来是这个家伙 com.vivo.abe 杀掉了 io.appium.uiautomator2.server 进程

解决办法

在网上查了一下 com.vivo.abe 是vivo 系统自带的应用 - 智能助手,不能删除也不能强制停止,它会自动扫描系统应用,把认为有问题的应用强制杀掉。如果有应用被它误杀,可以通过添加白名单的方法跳过检查。 配置的位置在 设置 -> 电池 -> 后台高耗电, 把 appium 相关的app都加上,然后再运行appium 自动化测试,妥妥的没有问题啦 😋

配置方法:
在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐