自動化測試 appium 會報錯 Could not proxy command to remote server. Original error: Error: socket hang up

問題如標題所示,最近使用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(),千萬要記得!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章