我有一个设置,我的 PC 中的 Web 应用程序正在访问在连接的设备上运行的应用程序信息.(通过 USB 调试).并不断将应用数据发送到Web Application(PC).
I am having a setup where web Application in my PC is accessing the app info running on the connected device.(through USB debugging). and continuously sends the app data to the Web Application(PC).
我正在使用 selenium(web GUI) 和 appium(device) 进行自动化测试.
I am automating this using selenium(web GUI) and appium(device) for my automation testing..
问题:一旦应用程序在设备中启动并与 Web 应用程序(在我的 PC 中)通信,我无法从 uiautomator.bat 工具连接到设备.得到以下错误.是否有解决此问题的方法.
Issue: I am unable to connect to the device from uiautomator.bat tool once the app is getting launched in the device and communicating with the Web app(In my PC). Getting the below error. Is there a workaround for this issue.
--------uiautomator.bat 日志-----------
--------uiautomator.bat log-----------
C:Userssat_yugandroid-sdks ools>uiautomatorviewer.bat03:57:35 E/DeviceMonitor: Adb connection Error: 现有连接被远程主机强行关闭03:57:36 E/DeviceMonitor:连接尝试:103:57:38 E/DeviceMonitor:连接尝试:203:57:40 E/DeviceMonitor:连接尝试:303:57:42 E/DeviceMonitor:连接尝试:403:57:44 E/DeviceMonitor:连接尝试:503:58:04 E/DeviceMonitor: Adb connection Error: 现有连接被远程主机强行关闭
C:Userssat_yugandroid-sdks ools>uiautomatorviewer.bat 03:57:35 E/DeviceMonitor: Adb connection Error:An existing connection was forcibly closed by the remote host 03:57:36 E/DeviceMonitor: Connection attempts: 1 03:57:38 E/DeviceMonitor: Connection attempts: 2 03:57:40 E/DeviceMonitor: Connection attempts: 3 03:57:42 E/DeviceMonitor: Connection attempts: 4 03:57:44 E/DeviceMonitor: Connection attempts: 5 03:58:04 E/DeviceMonitor: Adb connection Error:An existing connection was forcibly closed by the remote host
------------adb 设备日志------------
------------adb devices log---------------------
C:Userssat_yugandroid-sdksplatform-tools>adb 设备附加设备列表adb 服务器已过期.杀...错误:无法安装 smartsocket 监听器:无法绑定到 127.0.0.1:5037:每个套接字地址只能使用一次(协议/n网络地址/端口)通常是允许的.(10048)无法从 ADB 服务器读取 ok* 无法启动守护进程 *错误:无法连接到守护进程
C:Userssat_yugandroid-sdksplatform-tools>adb devices List of devices attached adb server is out of date. killing... error: could not install smartsocket listener: cannot bind to 127.0.0.1:5037: Only one usage of each socket address (protocol/n etwork address/port) is normally permitted. (10048) could not read ok from ADB Server * failed to start daemon * error: cannot connect to daemon
我刚刚为我解决了这个问题,所以我想我会分享,即使这个问题很老了.简单地重新启动 adb 是行不通的.打开具有管理员权限的命令提示符并执行以下命令:
I just solved this for me so i thought i'd share even though the question is old. Simply restarting the adb is not going to work. Open a command prompt with administrator priviledges and execute this:
netstat -o -n -a | findstr 5037
这将产生一个结果列表.这就是我的情况:
This will produce a list of results. This is what came up in my case:
TCP 127.0.0.1:5037 0.0.0.0:0 LISTENING 3408
TCP 127.0.0.1:5037 127.0.0.1:50018 ESTABLISHED 3408
TCP 127.0.0.1:5037 127.0.0.1:54507 ESTABLISHED 3408
TCP 127.0.0.1:5037 127.0.0.1:63330 ESTABLISHED 3408
TCP 127.0.0.1:5037 127.0.0.1:63332 ESTABLISHED 3408
TCP 127.0.0.1:50018 127.0.0.1:5037 ESTABLISHED 1664
TCP 127.0.0.1:54507 127.0.0.1:5037 ESTABLISHED 1664
TCP 127.0.0.1:63330 127.0.0.1:5037 ESTABLISHED 1664
TCP 127.0.0.1:63332 127.0.0.1:5037 ESTABLISHED 1664
最右边的列是进程 ID (PID).正在侦听所需套接字的进程是 3408.所以这个进程必须 DIE
!如果你这样做会发生什么:
At the most right column is the process id (PID). The proccess that is listening to the needed socket is the 3408. So this process must DIE
! Which happends if you do:
taskkill /F /PID 3408
之后就可以了
adb kill-server
adb start-server
重新启动 adb 服务器,您的 adb 很可能会成功启动.
to restart the adb server and most propably your adb will start successfully.
更新:
我制作了这个小 bat 文件以使其更容易,因为这种情况经常发生.确定
I made this little bat file to make it easier since this happens quite often. Make sure
1. to place this bat at the same folder as adb.exe
2. run it as administrator.
它将直接显示正在使用套接字的 PID.键入该 PID 并按 Enter 键,问题就消失了.
It will directly show you the PID that is using the socket. Type that PID and hit enter and the problem goes away.
netstat -o -n -a | findstr 5037 | findstr LISTENING
set /p pid=Enter pid to kill:%=%
@echo %pid%
taskkill /F /PID %pid%
adb kill-server
adb start-server
pause
这篇关于应用在设备上运行时无法获取 uiautomator 工具中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!