Appium 在 android 真机上运行测试时频繁连接设备弹出 USB 选项怎么破?

zhangyang · 2014年08月11日 · 最后由 zhangyang 回复于 2014年08月20日 · 1753 次阅读

我在连接设备(MI3)后,用 appium --no-reset 命令启动 appium,然后运行我的 python 测试脚本 设置如下:

def setUp(self):
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '4.1'
        desired_caps['deviceName'] = '00203a3f'  #米3
        #desired_caps['deviceName'] = '9ec94fd2'
        #desired_caps['deviceName'] = 'TA9330EPP6'   #摩托罗拉

        #desired_caps['deviceName'] = 'Android Emulator'
        desired_caps['app'] = PATH(
            'E:\mexxx_apk\xxxxx_3.8.0.apk'
        )
        desired_caps['appPackage'] = 'com.xxx'
        desired_caps['appActivity'] = 'com.xxxxx'

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

运行后首先是频繁的连接设备并弹出 USB 设置选项(就是那个包含 “打开设备以查看文件文件夹 balabala” 的那个弹出框),另外测试根本不能成功,老是报类似
WebDriverException: Message: u'A new session could not be created. (Original error: Command failed: - waiting for device -\r\n)'
或者
WebDriverException: Message: u'A new session could not be created. (Original error: Command failed: - protocol failure -\r\n)'
这样的错误

求大神指点啊!!

共收到 6 条回复 时间 点赞

我觉得可以换一根数据线试试

#1 楼 @daydayup 基本可以排除数据线的问题

#2 楼 @hobbs 看看是不是 xx 助手搞的鬼

desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.1'

如果你是要用 4.1 的系统,请你使用这个参数 desired_caps['platformName'] = 'Selendroid'

@hobbs 请问 这个问题 解决了吗?我这边今天突然出现了这个问题,有时候报错,有时候不报错。

Original error: Command failed: protocol failure\r\n- waiting for device -\r\n

谢谢分享下

#5 楼 @seasoncool2011 http://testerhome.com/topics/153 26 楼我的回复,我就不复制了哈

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