Appium [新手求助]windows8.1 + python3.4 跑范例 contact 的 apk 死活连不上真机

terrylj · 2014年09月09日 · 最后由 fsdf 回复于 2016年10月13日 · 2793 次阅读

adb 连接情况如图示

连接代码

def setUp(self):
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '4.4.2'
        desired_caps['deviceName'] = '13b7ef9d'
        desired_caps['app'] = PATH(
            'C:\pythonex\ContactManager.apk'
        )
        desired_caps['appPackage'] = 'com.example.android.contactmanager'
        desired_caps['appActivity'] = '.ContactManager'

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

python 显示报错信息
Traceback (most recent call last):
File "C:\Python34\android_contacts.py", line 24, in setUp
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
File "C:\Python34\lib\site-packages\appium\webdriver\webdriver.py", line 35, in init
super(WebDriver, self).init(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 73, in init
self.start_session(desired_capabilities, browser_profile)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 121, in start_session
'desiredCapabilities': desired_capabilities,
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 164, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: 'A new session could not be created. (Original error: Could not find a connected Android device.)'

appium 报错信息

ERROR: debug: executing: "C:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe" kill-server
warn: code=ENOENT, errno=ENOENT, syscall=spawn
ERROR: error: Error killing ADB server, going to see if it's online anyway
warn: code=ENOENT, errno=ENOENT, syscall=spawn
ERROR: debug: executing: "C:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\adb.exe" devices
info: Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
ERROR: error: Failed to start an Appium session, err was: Error: Could not find a connected Android device.
info: Cleaning up android objects
info: Cleaning up appium session
info: Error: Could not find a connected Android device.
at ADB.getDevicesWithRetry (C:\appium\node_modules\appium\lib\devices\android\adb.js:599:15)
at androidCommon.prepareActiveDevice (C:\appium\node_modules\appium\lib\devices\android\android-common.js:338:12)
at null. (C:\appium\node_modules\appium\lib\devices\android\android-common.js:279:26)
at C:\appium\node_modules\appium\node_modules\async\lib\async.js:610:21
at C:\appium\node_modules\appium\node_modules\async\lib\async.js:249:17
at iterate (C:\appium\node_modules\appium\node_modules\async\lib\async.js:149:13)
at C:\appium\node_modules\appium\node_modules\async\lib\async.js:160:25
at C:\appium\node_modules\appium\node_modules\async\lib\async.js:251:21
at C:\appium\node_modules\appium\node_modules\async\lib\async.js:615:34
at androidCommon.prepareEmulator (C:\appium\node_modules\appium\lib\devices\android\android-common.js:329:5)
info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find a connected Android device.)","origValue":"Could not find a connected Android device."},"sessionId":null}
POST /wd/hub/session 500 27428ms - 234b
Killed Node Server.
Node Server Process Ended

求助,怎么才能连上真机启动调试,在线等,万分感谢

共收到 14 条回复 时间 点赞

ERROR: error: Failed to start an Appium session, err was: Error: Could not find a connected Android device. 说明 appium 认不出你的手机。

我手动添加过 vid 的也不行

也装过米 3 的驱动

#3 楼 @terrylj 你试试看 用 adb install 可以安装应用么

可以安装

匿名 #6 · 2014年09月09日

这么高大上的测试环境。。。是不是端口被占用了?

不应该啊,我换个端口试试

换端口还是悲剧

你装个豌豆荚,看看能用不么?要么你把开发者选项打开啊

能用的,开发者选项也是开的

ADB.prototype.restartAdb = function (cb) {
  this.exec("kill-server", function (err) {
    if (err) {
      logger.error("Error killing ADB server, going to see if it's online " +
                   "anyway");
    }
    cb();
  });
};

这里就报错了。 按道理 adb kill-server 是不会报错的。

对呀,我也是非常的不解

我也是新手,刚刚搭建完 appium 环境,遇到同样的问题,请问最后解决了吗

我也是遇到同样的问题了

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