Skip to content

fix: support Appium 2 W3C-prefixed capabilities in MobilePlatformType - #242

Merged
lizaiv77 merged 2 commits into
salesforce:devfrom
rjap-salesforce:fix-appium2-getcapabilities
May 22, 2026
Merged

fix: support Appium 2 W3C-prefixed capabilities in MobilePlatformType#242
lizaiv77 merged 2 commits into
salesforce:devfrom
rjap-salesforce:fix-appium2-getcapabilities

Conversation

@rjap-salesforce

@rjap-salesforce rjap-salesforce commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #241.

MobilePlatformType.fromDriver() was reading capabilities with unprefixed keys (deviceName, deviceScreenSize, deviceScreenDensity). Under Appium 2 / Selenium 4, these capabilities live under the W3C namespace prefix (appium:deviceName, etc.), so the lookups returned null and the method always fell back to ANDROID_PHONE / IOS_PHONE — tablet profiles never activated, causing NoSuchElementException when phone selectors didn't match tablet layouts.

Changes

  • Added private helper getAppiumCapability(Capabilities, String) in MobilePlatformType that tries "appium:" + name first and falls back to the unprefixed key, preserving backward compatibility.
  • Updated isIPad and isTablet to use the helper.
  • Added testFromDriverWithAppiumPrefixedCapabilities covering the ANDROID_TABLET and IOS_TABLET paths via prefixed keys.

Scoped the helper to MobilePlatformType rather than a shared utility: the only production reads of getCapability that need the prefix fallback are the three in this enum. Other call sites are tests that

Test plan

  • mvn -pl utam-core test -Dtest=MobilePlatformTypeTests — 7/7 pass
  • mvn -pl utam-core test — 383/383 pass, no regressions
  • Reviewer to confirm against an actual Appium 2 setup if available

Update — broaden device-name capability search

End-to-end validation on Sauce Labs Real Device Cloud surfaced a second issue: even with W3C-prefix support, appium:deviceName on Sauce RDC is the device UDID, not a model. The human-readable model lives under appium:testobject_device / appium:testobject_device_name (Sauce); BrowserStack and LambdaTest commonly use appium:device.

Caps from a real Sauce RDC iPad Air session:

appium:deviceName =
appium:testobject_device = iPad_Air_2022_
appium:testobject_device_name = iPad Air 2022 5th Gen

This commit generalizes isIPad() to consult an ordered list of device-name caps via a deviceMatches() helper, and adds an analogous name-based fallback to isTablet() for Android cloud-farm sessions that don't expose deviceScreenSize / deviceScreenDensity.

New tests cover Sauce RDC iPad (UDID in deviceName, model in testobject_device_name), Sauce RDC iPhone (negative case), and the Android-tablet name fallback.

Refs #241 (follow-up comment).

Demonstration:
Screenshot 2026-05-20 at 11 35 42

Screenshot 2026-05-20 at 11 27 48

@rjap-salesforce
rjap-salesforce marked this pull request as draft May 20, 2026 18:00
  On Sauce Labs RDC, appium:deviceName is set to the device UDID rather than a model name, so a contains("ipad") check against it always fails even with W3C-prefix support. The model is exposed via Sauce-specific caps (testobject_device, testobject_device_name); BrowserStack and LambdaTest commonly use appium:device.

  Generalize isIPad() to consult an ordered list of device-name caps (deviceName, testobject_device_name, testobject_device, device) via a small deviceMatches() helper. Keep isTablet()'s screen-size/density math as the primary Android-tablet signal and fall back to deviceMatches(caps, "tablet") for cloud farms that don't expose those caps on RDC.

  Adds tests covering Sauce RDC iPad (UDID in deviceName, model in testobject_device_name), Sauce RDC iPhone (negative case), and the Android-tablet name fallback.
@rjap-salesforce
rjap-salesforce marked this pull request as ready for review May 20, 2026 18:42
@lizaiv77
lizaiv77 merged commit 3857e5e into salesforce:dev May 22, 2026
4 checks passed
@rjap-salesforce
rjap-salesforce deleted the fix-appium2-getcapabilities branch May 22, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MobilePlatformType.fromDriver() always returns ANDROID_PHONE / IOS_PHONE on Appium 2 (W3C appium: prefix)

2 participants