Appium Appium 运行一些 case 后,appium.js 不能运行,异常如下:

dddd · 2015年02月04日 · 最后由 雨雾恨 回复于 2015年07月10日 · 1532 次阅读

场景:
1.有 400 个 case 要运行,每运行完一个 case 就 Appium.Driver.quit();运行完下一个 case 重新创建 session;

问题:
每次大概只运行 10~20 左右的 case,然后 Appium.js 就报异常,异常如下:

info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Requested a new session but one was in progress)","origV
ested a new session but one was in progress"},"sessionId":"054b890c-da26-49db-a906-af84b01443ef"}
info: <-- POST /wd/hub/session 500 1.575 ms - 250
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:/apps/ContactManager/elong_5.3.5.apk","platform":"WINDOWS","platformName":"Android","deviceName":"emulator-5554","browserName
pp-package":"com.dp.android.elong","device":"Android","app-activity":".HomeActivity","version":"4.4"}}
info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
info: [debug] Error: Requested a new session but one was in progress
    at Appium.start (C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\lib\appium.js:127:15)
    at Object.exports.createSession [as handle] (C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\lib\server\controller.js:182:16)
    at next_layer (C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:113:13)
    at Route.dispatch (C:\Users\dd.haongAppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:117:5)
    at C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:222:24
    at Function.proto.process_params (C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:288:12)
    at next (C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:216:19)
    at next (C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:180:38)
    at next (C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:180:38)
    at next (C:\Users\dd.haong\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:180:38)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Requested a new session but one was in progress)","origV
ested a new session but one was in progress"},"sessionId":"054b890c-da26-49db-a906-af84b01443ef"}
info: <-- POST /wd/hub/session 500 1.489 ms - 250


共收到 2 条回复 时间 点赞

根据 log 的描述,无法创建新 session 的原因是旧 session 没有被关闭。
个人建议:

  1. 检查出错的 case 是否真的 quit() 了(如打开的应用是否被关闭了)。
  2. 不同 case 之间加上 10s 左右的等待时间,有时候 quit() 也需要一定时间的。

问题解决了吗?能说下现在进展吗

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