appium移动自动化测试提示error: Could not find a connected Android device

测试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] 

解决办法:

注意手机连接有没有问题!!!重连一下手机试试。

————————————————————————————————————————————
微信关注号:python爬虫机器学习深度学习
在这里插入图片描述

Traceback (most recent call last): File "D:\Desktop\app_test\app_test.py", line 37, in <module> driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) # 连接appium server(需先启动appium server) File "D:\Desktop\app_test\venv\lib\site-packages\appium\webdriver\webdriver.py", line 234, in __init__ super().__init__( File "D:\Desktop\app_test\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 286, in __init__ self.start_session(capabilities, browser_profile) File "D:\Desktop\app_test\venv\lib\site-packages\appium\webdriver\webdriver.py", line 324, in start_session response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps) File "D:\Desktop\app_test\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "D:\Desktop\app_test\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not find a connected Android device. Stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not find a connected Android device. at getResponseForW3CError (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9) at asyncHandler (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:388:37) at process._tickCallback (internal/process/next_tick.js:68:7)
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值