Appium 启动后模拟器自动断开连接

匿名 · 2018年12月18日 · 1913 次阅读

appium 日志

Checking if an update is available
Update not available
Launching Appium server with command: F:\tools\appium\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --session-override --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
info: Welcome to Appium v1.4.0 (REV 8f63e2f91ef7907aed8bda763f4e5ca08e86970a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {"address":"127.0.0.1","sessionOverride":true,"logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"capabilities":{"firstMatch":[{"platformName":"Android","appium:platformVersion":"4.4.2","appium:deviceName":"MI 6","appium:appPackage":"com.hlww.com.hlww","appium:appActivity":"com.netease.nim.demo.zy.model.WelcomActivity","appium:appWaitActivity":"com.netease.nim.demo.zy.model.WelcomActivity","appium:sessionOverride":true}]},"desiredCapabilities":{"platformName":"Android","platformVersion":"4.4.2","deviceName":"MI 6","appPackage":"com.hlww.com.hlww","appActivity":"com.netease.nim.demo.zy.model.WelcomActivity","appWaitActivity":"com.netease.nim.demo.zy.model.WelcomActivity","sessionOverride":true}}
info: Client User-Agent string: selenium/3.141.0 (python windows)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : sessionOverride
info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session 98ad5844-1ab3-4ed6-bfde-dd33bf48ef25
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_191
info: [debug] Checking whether adb is present
info: [debug] Using adb from F:\android-sdk-windows\platform-tools\adb.exe
warn: No app capability, can't parse package/activity
info: [debug] Set chromedriver binary as: F:\tools\appium\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: F:\android-sdk-windows\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 127.0.0.1:62001
info: [debug] Setting device id to 127.0.0.1:62001
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: F:\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 wait-for-device
info: [debug] Retrying restartAdb
error: Error running wait-for-device
info: [debug] executing cmd: F:\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 kill-server
info: [debug] Getting connected devices...
info: [debug] executing cmd: F:\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 devices

代码:

coding=utf-8

from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.2'
desired_caps['deviceName'] = 'MI 6'
desired_caps['appPackage'] = 'com.hlww.com.hlww'
desired_caps['appActivity'] = 'com.netease.nim.demo.zy.model.WelcomActivity'
desired_caps['appWaitActivity'] = 'com.netease.nim.demo.zy.model.WelcomActivity'
desired_caps['sessionOverride'] = True # 每次启动时覆盖 session,否则第二次后运行会报错不能新建 session

固定的访问 appium 访问的地址

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

adb 连接正常
C:\Users\ASUS>adb devices
List of devices attached
127.0.0.1:62001 device

之前都能运行 现在突然跑不动了,pycharm 一直在运行中

共收到 7 条回复 时间 点赞

The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : sessionOverride

匿名 #5 · 2018年12月18日
edsion 回复

我把 desired_caps['sessionOverride'] = True 这句注释掉 就没报这个错了。提示没有获取到 APP ,可我的 capability 参数没错早两天还跑起来了唉,能帮我看看是什么问题么

能否贴一下运行正常的 log 看一下?
异常 log 中还有 1 处有点意思:
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: F:\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 wait-for-device
info: [debug] Retrying restartAdb
error: Error running wait-for-device

adb 为什么要重启,adb 重启了,那么之前的 wait-for-device 命令肯定就会报错
系统就认为是 adb 环境崩溃,然后执行了 kill-server,就断开了

  1. 看你的配置,没有给 apk 文件,而是直接给了 app 的配置。有确认过设备里是不是真的装了对应的 app ?
  2. info: [debug] Setting device id to 127.0.0.1:62001 info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5) info: [debug] executing cmd: F:\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 wait-for-device info: [debug] Retrying restartAdb error: Error running wait-for-device info: [debug] executing cmd: F:\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 kill-server info: [debug] Getting connected devices... info: [debug] executing cmd: F:\android-sdk-windows\platform-tools\adb.exe -s 127.0.0.1:62001 devices 看起来 appium 想要确认设备会不会响应 adb 的命令,但貌似设备没响应。近期电脑 adb 版本或者模拟器有没有做过什么调整?
匿名 #1 · 2018年12月19日
Stone 回复

谢谢啦 我更新了 adb 版本就好了

匿名 #6 · 2018年12月19日
Stone 回复

感谢,更新 adb 之后就运行起来勒

匿名 #3 · 2018年12月19日
陈恒捷 回复

感谢,问题已经解决勒

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