問題描述
我有一個設置,我的 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模板網!