appium问题整理

在刚进入appium的世界时,遇到无数的坑,趟过无数的浑水,现在整理一些常用的报错讯息,供大家参考

1.org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

错误可能原因:
  1).appium服务未启动
  2).appium服务地址写错

解决方法:
  1).启动appium服务端
  2).查看代码中服务端地址是否正确,若未修改,默认的地址为:http://127.0.0.1:4723/wd/hub

 

2. org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: deviceName)

错误可能原因:
  1).DesiredCapabilities 对象参数中缺少deviceName参数
  2).参数deviceName 写错了,比如写成了  devicesName、devicename

解决方法:
  查看代码中deviceName参数是否缺少或者是否写错,修正,重新运行

 

3. org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Bad app: C:\Users\Nick\Desktop\weixin.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'C:\Users\Nick\Desktop\weixin.apk')

错误可能原因:
  1).apk路径写错了,导致程序未找到该apk
  2).设置访问的是远程appium服务端,而apk路径却写成了本地地址

解决方法:
  1).仔细检查apk路径
  2).如果是远程appium服务端,app地址及app要写appium服务端上apk所在的路径

 

4. org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: No app set; either start appium with --app or pass in an 'app' value in desired capabilities, or set androidPackage to launch pre-existing app on device)

错误可能原因:
  参数中即没有app参数,也没有appPackage参数

解决方法:
  1).设置app参数,进行安装app然后测试
  2).设置appPackage及appActivity参数,启动已安装的应用进行测试

 

5. org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity)

错误可能原因:
  1).appActivity参数写错或者appPackage写错
  2).设备上没安装这个app

解决方法:
  1).检查appActivity参数值
  2).检查设备是否安装了app

 

6. org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not find a connected Android device.)

错误可能原因:
  当前没有设备在线,可进入cmd,输入adb devices查看是否有设备在线

解决方法:
  插上设备或者检查设备连接是否有问题(可重启adb、重插设备、杀掉各种手机助手进程),若使用模拟器,可重启模拟器查看

 

7.org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress)

错误可能原因:
  上次执行脚本没有正常关闭session

解决方法:
  1).重启服务端后再执行脚本
  2).等待session自动断开后再执行脚本
  3).利用try catch finally块执行driver.quit()

  4).勾选服务端的Override Existing Session参数,再下次执行脚本时会自动覆盖前面的session

posted @ 2018-01-17 13:50  Nick1994  阅读(708)  评论(0编辑  收藏  举报