fix: support Appium 2 W3C-prefixed capabilities in MobilePlatformType - #242
Merged
lizaiv77 merged 2 commits intoMay 22, 2026
Merged
Conversation
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
marked this pull request as ready for review
May 20, 2026 18:42
lizaiv77
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 returnednulland the method always fell back toANDROID_PHONE/IOS_PHONE— tablet profiles never activated, causingNoSuchElementExceptionwhen phone selectors didn't match tablet layouts.Changes
getAppiumCapability(Capabilities, String)inMobilePlatformTypethat tries"appium:" + namefirst and falls back to the unprefixed key, preserving backward compatibility.isIPadandisTabletto use the helper.testFromDriverWithAppiumPrefixedCapabilitiescovering theANDROID_TABLETandIOS_TABLETpaths via prefixed keys.Scoped the helper to
MobilePlatformTyperather than a shared utility: the only production reads ofgetCapabilitythat need the prefix fallback are the three in this enum. Other call sites are tests thatTest plan
mvn -pl utam-core test -Dtest=MobilePlatformTypeTests— 7/7 passmvn -pl utam-core test— 383/383 pass, no regressionsUpdate — 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:deviceNameon Sauce RDC is the device UDID, not a model. The human-readable model lives underappium:testobject_device/appium:testobject_device_name(Sauce); BrowserStack and LambdaTest commonly useappium: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 adeviceMatches()helper, and adds an analogous name-based fallback toisTablet()for Android cloud-farm sessions that don't exposedeviceScreenSize/deviceScreenDensity.New tests cover Sauce RDC iPad (UDID in
deviceName, model intestobject_device_name), Sauce RDC iPhone (negative case), and the Android-tablet name fallback.Refs #241 (follow-up comment).
Demonstration:
