Appium appium 移动自动化测试提示 error: Could not find a connected Android device 求解决方案,在线等在线等~

ymxz375441262 · 2018年05月14日 · 最后由 xiangxiao 回复于 2018年09月25日 · 3008 次阅读

本人新手入坑appium,好不容易装好黄静,昨天测试成功就睡觉了。今天一开机,就连不上了。但是cmd devices是可以看到设备的,有大神知道什么原因吗?谢谢!

以下是appium运行代码。求大神。呜呜~

[Appium] Welcome to Appium v1.8.0
[Appium] Non-default server args:
[Appium] address: 127.0.0.1
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"platformName":"Android"}},"desiredCapabilities":{"platformName":"Android","platformVersion":"5.1.1","deviceName":"127.0.0.1:5555","appPackage":"com.baidu.tieba","appActivity":"com.baidu.tieba.LogoActivity"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","platformVersion":"5.1.1","deviceName":"127.0.0.1:5555","appPackage":"com.baidu.tieba","appActivity":"com.baidu.tieba.LogoActivity"},null,{"firstMatch":[{}],"alwaysMatch":{"platformName":"Android"}}]
[BaseDriver] Event 'newSessionRequested' logged at 1526153469305 (03:31:09 GMT+0800 (中国标准时间))
[Appium] Could not parse W3C capabilities: 'deviceName' can't be blank. Falling back to JSONWP protocol.
[Appium] The following capabilities were provided in the JSONWP desired capabilities that are missing in W3C capabilities: ["platformName","platformVersion","deviceName","appPackage","appActivity"]. Falling back to JSONWP protocol.
[Appium] Creating new AndroidDriver (v2.6.0) session
[Appium] Capabilities:
[Appium] platformName: Android
[Appium] platformVersion: 5.1.1
[Appium] deviceName: 127.0.0.1:5555
[Appium] appPackage: com.baidu.tieba
[Appium] appActivity: com.baidu.tieba.LogoActivity
[BaseDriver] Creating session with MJSONWP desired capabilities: {"platformName":"Android","...
[BaseDriver] Session created with session id: 650fa53c-151b-433b-9d44-3199cdd61a4c
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 10.0.1
[ADB] Checking whether adb is present
[ADB] Using adb.exe from F:\ruanjian\android\android-sdk-windows\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] Could not find devices, restarting adb server...
[ADB] Restarting adb
[ADB] Killing adb server on port 5037
[ADB] Getting connected devices...
[ADB] Could not find devices, restarting adb server...
[ADB] Restarting adb
[ADB] Killing adb server on port 5037
[ADB] Getting connected devices...
[ADB] Could not find devices, restarting adb server...
[ADB] Restarting adb
[ADB] Killing adb server on port 5037
[ADB] Getting connected devices...
[ADB] Could not find devices, restarting adb server...
[ADB] Restarting adb
[ADB] Killing adb server on port 5037
[ADB] Getting connected devices...
[ADB] Could not find devices, restarting adb server...
[ADB] Restarting adb
[ADB] Killing adb server on port 5037
[ADB] Getting connected devices...
[ADB] Could not find devices, restarting adb server...
[ADB] Restarting adb
[ADB] Killing adb server on port 5037
[AndroidDriver] Shutting down Android driver
[AndroidDriver] Called deleteSession but bootstrap wasn't active
[BaseDriver] Event 'newSessionStarted' logged at 1526153492737 (03:31:32 GMT+0800 (中国标准时间))
[W3C] Encountered internal error running command: Error: Could not find a connected Android device.
[W3C] at ADB.getDevices$ (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\lib\tools\system-calls.js:188:13)
[W3C] at tryCatch (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[W3C] at invoke (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[W3C] at enqueueResult (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:185:17)
[W3C] at new Promise ()
[W3C] at new F (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\core-js\library\modules\$.export.js:30:36)
[W3C] at AsyncIterator.enqueue (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:184:12)
[W3C] at AsyncIterator.prototype.(anonymous function) [as next] (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[W3C] at Object.runtime.async (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:209:12)
[W3C] at getDevices (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\build\lib\tools\system-calls.js:402:38)
[W3C] at ADB.getDevices$ (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\lib\tools\system-calls.js:205:20)
[W3C] at tryCatch (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[W3C] at GeneratorFunctionPrototype.invoke (C:\Users\ymxz375417299\AppData\Local\Programs\Appium\resources\app\node_modules\appium-adb\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[W3C] at
[HTTP] <-- POST /wd/hub/session 500 23435 ms - 1570
[HTTP]

我写的测试代码是

最佳回复
ymxz375441262 回复

你这样吧,用appium 的桌面版 ,它是有个录制跟调试功能的,先把你的必要参数放进去,如:安卓版本号、设备号、包名跟主activity,用来调试看看。

ymxz375441262 回复

检查每个参数对应是不是正确,是命令行启动还是桌面版?每次启动 你的appium有没有设置$appium --session-override --no-reset

共收到 26 条回复 时间 点赞

你这是用tcpip连接的设备吧?

你服务器地址和设备地址都是127.0.0.1

你appium服务的端口号和代码的端口号不一致吧

kukaka 回复

那我APPIUM 应该怎么设置地址呢

heming 回复

我Appium 的地址是设置 127.0.0.1:4723的哦

simple 回复

不是的。就是模拟器的

你用的是什么模拟器啊,建议你重启下Appium服务和模拟器看看。

adb devices看看

shuqing2017 回复

我连真机和换了雷电。也夜神都连不上呢

kukaka 回复

devices 是可见的 就是连不上。。。。

最好用genymotion

samfu 回复

刚试了 ,genymotion 也连不上。崩溃中。。。

ymxz375441262 回复

检查每个参数对应是不是正确,是命令行启动还是桌面版?每次启动 你的appium有没有设置$appium --session-override --no-reset

试一下不要用 devicename 这个参数,用 udid 这个参数,devicename 随便输入

DC_ing 回复


还是不行呢

deviceName怎么是127.0.0.1:5555这么奇葩
Could not parse W3C capabilities: 'deviceName' can't be blank. Falling back to JSONWP protocol.这个提示

AlanFightting 回复

我也不知道为什么。CMD adb devices 就是搜索这个deviceName

建议你弄个真机试一下

samfu 回复

我现在加了也一样连不上呢

ymxz375441262 回复

你这样吧,用appium 的桌面版 ,它是有个录制跟调试功能的,先把你的必要参数放进去,如:安卓版本号、设备号、包名跟主activity,用来调试看看。

samfu 回复

谢谢你的热心回答!问题已经解决了。按照你说的调试后发现好像是我的 APPIUM有问题,就用命令行npm install -g appium重装,然后重启电脑就好了。!谢谢你们的回答。让我感到温暖~

samfu 回复

我也遇到同样的问题,我是用appium desktop在 start session的时候报这个错的,求帮忙解决


我的一直弹出这个,然后出现这个提示:
Encountered internal error running command: Error: Could not find a connected Android device.

楼主,你如果有解决方法了,一定给我回复!

littlefive 回复

这是adb有问题吧,更新下Android SDK试试

我也是这样,楼主怎么解决的?一直找不到android设备

同样的问题,求指教交流,邮箱地址 rainbowxiamm@163.com

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