【发布时间】:2020-11-24 01:44:12
【问题描述】:
我在 Appium(iMac 上的 Android 模拟器)中运行了大约 90 次测试,一切都很好,直到我突然开始观察到这个错误:
Starting logs capture with command: /Users/username/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 logcat -v threadtime
E selenium.common.exceptions.WebDriverException: Message: An unknown server-side
error occurred while processing the command. Original error: Cannot find any free port in range
8200..8299}. Please set the available port number by providing the systemPort capability or
double check the processes that are locking ports within this range and terminate these which
are not needed anymore
我做了一些事情来解决这个问题,但没有任何效果:
1.
adb kill-server
adb reconnect
-
我确实清理了模拟器并重新启动了。
-
除此之外,我没有找到系统中已经使用的 8200-8299 的任何端口。
-
我也添加了
systemPort功能,但我仍然看到同样的错误。
我不知道如何解决这个问题。
更新:
发现更多日志并发现 UIAutomator 2(或 adb)没有清除端口转发,这就是为什么我在 iOS 上没有问题但仅在 Android 中发布。以下是 appium 服务器末尾的日志:
[debug] [35m[WD Proxy] [39m Proxying [DELETE /] to [DELETE http://127.0.0.1:8200/wd/hub/session/d1f94433-2c44-4dac-a836-461ab7f41130] with no body
[debug] [35m[UiAutomator2] [39m Deleting UiAutomator2 server session
[debug] [35m[WD Proxy] [39m Matched '/' to command name 'deleteSession'
[debug] [35m[WD Proxy] [39m Proxying [DELETE /] to [DELETE http://127.0.0.1:8201/wd/hub/session/37137b29-a9a6-4d83-b2d9-ce510f601a2d] with no body
[debug] [35m[UiAutomator2] [39m Deleting UiAutomator2 server session
127.0.0.1:8201 上升到 127.0.0.1:8299 并删除了 100 个我没想到的活动会话。
另外,在 netstat 输出中,我确实看到 TCP 端口 127.0.0.1:8200 - 127.0.0.1:8299 (LISTEN) 是打开的
【问题讨论】:
-
您最终找到解决方法了吗?
-
是的,通过使用
--session-override命令行参数。 -
非常感谢分享这个。我现在正在尝试。
-
不幸的是,在启动 appium 服务器时添加 --session-override 标志对我的情况没有帮助。除了该标志之外,您还添加了什么?您是否同时拥有具有 systemPort 功能的 --session-override 端口 >
-
我没有使用 systemPort 功能。我只是用了国旗。添加标志后,我在日志中注意到它没有进行端口转发,因此有 100 多个测试正在工作。添加flag后遇到什么问题?
标签: testing automated-tests appium ui-automation appium-android