问题如标题所示,最近使用vivoZ1进行APP自动化测试过程中,发现程序运行过程中突然中断,查看报错信息 Error: socket hang up。查看了所有的参数没有问题,然后换成小米手机进行测试一切正常,通过查找日志以及结合网上前任的帖子,进行如下操作(直接复制过来:princeqjzh (网球王子)):

  • appium 自动化测试
  • 运行平台 vivo v191真机
  • 驱动框架 UiAutomator2
  • 现象 自动化代码在vivo手机上运行一段时间之后,appium 会报错 Could not proxy command to remote server. Original error: Error: socket hang up
  • 同样的代码运行在其他手机上是不报错的,所以排除自动化代码的问题

appium日志

[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
[debug] [W3C (9ae907c5)]     at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:261:13)
[HTTP] <-- POST /wd/hub/session/9ae907c5-5319-4f0b-92dc-fdaa47cfdcc5/element 500 139 ms - 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 自动化测试,妥妥的没有问题啦 😋

配置方法:

  • appium 自动化测试
  • 运行平台 vivo v191真机
  • 驱动框架 UiAutomator2
  • 现象 自动化代码在vivo手机上运行一段时间之后,appium 会报错 Could not proxy command to remote server. Original error: Error: socket hang up
  • 同样的代码运行在其他手机上是不报错的,所以排除自动化代码的问题

appium日志

[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
[debug] [W3C (9ae907c5)]     at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:261:13)
[HTTP] <-- POST /wd/hub/session/9ae907c5-5319-4f0b-92dc-fdaa47cfdcc5/element 500 139 ms - 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 自动化测试,妥妥的没有问题啦 😋

配置方法:

 

最后运行成功啦:

 

提醒:在测试结束时,一定要使用driver.quit(),千万要记得!

Logo

一站式 AI 云服务平台

更多推荐