Skip to content

fix: add appium: prefix fallback and null safety for capability access#349

Draft
rishigupta1599 wants to merge 1 commit intomasterfrom
feat/appium-compat-improvements
Draft

fix: add appium: prefix fallback and null safety for capability access#349
rishigupta1599 wants to merge 1 commit intomasterfrom
feat/appium-compat-improvements

Conversation

@rishigupta1599
Copy link
Copy Markdown

Summary

  • Add getCapabilityValue() helper in Metadata.java that tries bare key first, then appium:-prefixed key for Appium 2.x W3C protocol compatibility
  • Fix NPE risks on .toString() calls when capabilities are null (e.g. iOS BrowserStack sessions where desired/platformVersion/deviceName may be missing)
  • Use getCapabilityValue() consistently across AndroidMetadata and IosMetadata instead of direct driver.getCapabilities().getCapability() calls

What was broken

On iOS BrowserStack real device sessions:

  • desired capability is undefined → getCapability("desired") returns null
  • platformVersion bare key is missing → only accessible via appium:platformVersion
  • deviceName may not resolve without appium: prefix

On Appium 2.x W3C protocol:

  • Non-standard capabilities require appium: prefix which BrowserStack may or may not return

Changes

File Change
Metadata.java Added getCapabilityValue() with W3C standard caps awareness and appium: prefix fallback. Fixed osName() NPE.
AndroidMetadata.java Migrated all capability access to getCapabilityValue(). Added null safety on device.toString().
IosMetadata.java Migrated to getCapabilityValue() with device fallback. Null-safe osName() and deviceName().

Test plan

  • Run existing test suite to verify no regressions
  • Test with Appium 1.x session (JSONWP protocol) — verify bare keys still work
  • Test with Appium 2.x session (W3C protocol) — verify appium: prefix fallback works
  • Test with iOS BrowserStack session — verify no NPE when desired is undefined

🤖 Generated with Claude Code

Add getCapabilityValue() helper that tries bare key then appium:-prefixed
key for Appium 2.x W3C protocol compatibility. Fix NPE risks on .toString()
calls when capabilities are null (e.g. iOS BrowserStack sessions where
desired/platformVersion/deviceName may be missing).

Changes:
- Metadata: add getCapabilityValue() with W3C standard caps awareness
- AndroidMetadata: use getCapabilityValue() for all capability access,
  add null safety on device.toString()
- IosMetadata: use getCapabilityValue() with device fallback, null-safe
  osName() and deviceName()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant