Appium 「求助」Appium 通过命令行起两个服务,连两个 android,但有一个终端会连接失败,请问应该怎么解决?

季文洪 · 2021年10月19日 · 最后由 季文洪 回复于 2021年10月19日 · 1845 次阅读

设备是 Mac Mini,小米/三星手机
当两个手机单独执行任务,都是正常的;
当两个手机同时执行任务就会出现问题。

命令行起的服务,查看进程号 40087, 39919
node /Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js -a 0.0.0.0 -p 4623 --bootstrap-port 4624
[ start_appium ]: start appium ok ,appium_id = 40087

node /Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js -a 0.0.0.0 -p 4633 --bootstrap-port 4634
[ start_appium ]: start appium ok ,appium_id = 39919

窗口查看起的服务是正常的:
sh-3.2# ps aux | grep node
root 40087 0.8 1.1 409505040 94304 s005 S+ 10:46 上午 0:03.45 node /Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js -a 0.0.0.0 -p 4623 --bootstrap-port 4624
root 39919 0.0 0.0 0 0 s000 Z+ 10:39 上午 0:00.00 (node)

两个终端出现的报错信息:
终端 1 的报错,连接操作是正常:
error: more than one device/emulator

终端 2 的报错,连接失败:
HTTPConnectionPool(host='127.0.0.1', port=4633): Max retries exceeded with url: /wd/hub/session/c3d6d10e-9873-4f13-aa97-5731a2073c58/timeouts (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused'))

共收到 6 条回复 时间 点赞

error: more than one device/emulator

这个报错一般出现在连接了多于一台 android 设备上,运行 adb 命令时未明确设定设备的 udid 时。你看下你自动化脚本是不是没有指定 udid 给 appium ?

陈恒捷 回复

正解,功能项添加一个 ("udid",你设备 udid)

@ 陈恒捷 @Eason 这个是出现问题的时候信息,就是在操作过程中,会突然出错

Try :find element and then click accessibility_id : MI170
SUCCESS :find element and then click accessibility_id : MI170

Try :find element and then click id : com.immomo.momo:id/message_btn_selectpic
[ ERROR ] find element and then click failed! id : com.immomo.momo:id/message_btn_selectpic
HTTPConnectionPool(host='127.0.0.1', port=4633): Max retries exceeded with url: /wd/hub/session/5680072f-55b5-43b6-971b-f3698a212d0f/timeouts (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused'))

@ 陈恒捷 @Eason

试着在起 appium 的时候加了 --uuid
终端 1
node /Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js -a 0.0.0.0 -p 4623 --bootstrap-port 4624 -U 127.0.0.1:62001 --udid RFCN30WZCZB
[ start_appium ]: start appium ok ,appium_id = 45145
! ! ! appium_id : 45145
error: more than one device/emulator
[ check_app_installed ]: check start
[ check_app_installed ]: appPackage = com.sankuai.meituan appactivity= com.meituan.android.pt.homepage.activity.MainActivity
[ connect_android_app ]: start remote appiumurl = http://localhost:4623/wd/hub
[ connect_android_app ]: connect success
[ check_app_installed ]: check end!
adb: more than one device/emulator

终端 2 Failed
node /Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js -a 0.0.0.0 -p 4633 --bootstrap-port 4634 --uuid e6386478
[ start_appium ]: start appium ok ,appium_id = 44976
[ check_app_installed ]: check start
[ check_app_installed ]: appPackage = com.tencent.mm appactivity= com.tencent.mm.ui.LauncherUI
[ connect_android_app ]: start remote appiumurl = http://localhost:4633/wd/hub
[ connect_android_app ] connect exception
HTTPConnectionPool(host='localhost', port=4633): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 61] Connection refused'))

季文洪 回复

指定 udid,不是 uuid

Eason 回复

😓 谢谢!改了,明天看结果。

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