You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行Appium测试用例时遇SessionNotCreatedException异常求助

Troubleshooting SessionNotCreatedException for Your First Appium Test

Hey there! Let's work through this SessionNotCreatedException you're hitting with your first Appium test. I’ve dealt with similar issues when starting out, so here are actionable steps to fix this:

1. Fix Version Compatibility Gaps

The versions you’re using might have subtle compatibility issues:

  • Appium 1.6.3 is a bit dated, and the Java Client 5.0.0-BETA7 (a pre-release version) might not play nicely with it alongside Selenium 3.4.0.
    • Try switching to the stable Java Client 4.1.2 — it’s proven to work well with Appium 1.6.3 and Selenium 3.4.0.
    • Alternatively, upgrade Appium to a more recent stable release (like 1.7.x or later) that has better support for Selenium 3.x and the Java Client 5.x series.

2. Double-Check Your Desired Capabilities

Incorrect or missing desired capabilities are the #1 cause of this error. Let’s verify:

  • For Android, make sure you include these mandatory capabilities:
    • deviceName: Match the name of your connected device/emulator (run adb devices to check)
    • platformName: Set to "Android" (case-sensitive!)
    • Either app (path to your APK) OR appPackage + appActivity (find these with aapt dump badging your-app.apk)
  • For iOS, confirm you have:
    • deviceName, platformName, platformVersion, and the app path to your IPA
  • Watch out for typos — even a capitalization mistake (like PlatformName instead of platformName) will break session creation.

3. Verify Appium Server & Device Connection

  • Ensure your Appium Server is running properly: You should see a log line like [Appium] Welcome to Appium v1.6.3 when it starts, and it should be listening on port 4723 (the default).
  • Check your device/emulator connection:
    • For Android: Run adb devices — your device should show up as device (not offline or unauthorized). If it’s unauthorized, unlock your device and accept the debug prompt.
    • For iOS: Make sure Xcode is installed, the simulator is running, and Appium has permission to access it.
  • Try restarting both the Appium Server and your device/emulator — sometimes a fresh start clears up connection glitches.

4. Ditch the Standalone Selenium Server (If You’re Using It)

Appium 1.6 and later has built-in Selenium support, so you don’t need to run a separate Selenium Server alongside it. If you’re running both, they might be conflicting on ports. Stop the standalone Selenium Server and run your test directly against the Appium Server.

5. Enable Debug Logs for More Clues

If the above steps don’t work, turn on debug logging in Appium to get the full picture:

  • Start Appium with this command: appium --log-level debug
  • Look at the log lines right before the SessionNotCreatedException is thrown — they’ll usually point to the exact issue (like a missing app file, unrecognized device, or invalid capability value).

If you’re still stuck, share your desired capabilities code snippet and the full Appium debug log, and I can help dig deeper!

内容的提问来源于stack exchange,提问作者Aviral Srivastava

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:37:28