Appium [已解决] 运行测试代码报 A new session could not be created. (Original error: Could not find a connected Android device.)

tom_ma · 2014年05月09日 · 最后由 tom_ma 回复于 2014年05月09日 · 1328 次阅读

junit test 报错输出是 org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not find a connected Android device.) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 27.54 seconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'SH-xxx', ip: '10.xx.xx.xx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: com.incito.appiumdemo.ContactManagerTest$SwipeableWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at com.incito.appiumdemo.ContactManagerTest$SwipeableWebDriver.(ContactManagerTest.java:63)
at com.incito.appiumdemo.ContactManagerTest.setUp(ContactManagerTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

命令行里使用 adb devices -l 是可以看到连接设备的,但是 appium 却发现不了该设备。

共收到 8 条回复 时间 点赞


Appuim 日志输出截图见附件。

之前曾经有一次是能运行成功的,现在就这样了,机器重启也解决不了问题。有大牛能帮忙定位下吗?

菜鸟上路,我也遇到了同样的问题,求解

@seveniruby,有时间帮忙看下吗

#4 楼 @tom_ma adb devices 找不到设备的话, 可以看下最近有同学刚发的一个精华帖, 里面有相关的总结

@seveniruby ,谢谢你的回复,你说的帖子是指http://testerhome.com/topics/496 这个吗? 我之前看了下,貌似对解决这个问题没什么帮助。

命令行里敲 adb devices -l,是能返回连接设备信息的, 只是在 junit test 运行时,appium 报错无法找到设备。所以实在想不出来可能是什么原因造成这个问题的。

问题跟 appium 无关, 你先解决自己的连接问题吧, 你搜索下进程里面 看看有没有 adb tadb 之类的进程吧, 全部 kill, 然后自己执行 adb kill-server adb devices 来检查下

@seveniruby,问题已解决,但是什么原因引起的我还是不知道。 我只是起了一个虚拟机,又执行了一遍,就运行成功了。然后把虚拟机关掉,再连上真机,也不报找不到设备这个错误了,现在是因为小米的手机系统是 4.1.1 的,然后 appuim 要求设备的 api level 不小于 17 才行,估计得换个 4.2 的真机试试才知道怎么样。 不管怎么说,还是十分感谢你的回复,让咱倍感微暖,哈哈。

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