feat: add mapTestTagToResourceId setting for Compose testTag support - #791
Merged
Conversation
Adds an opt-in mapTestTagToResourceId setting that maps Jetpack Compose's testTag semantics property onto the resource-id attribute, mirroring the behavior of Compose's own testTagsAsResourceId (which can only be set from within the app's own composable tree and cannot be toggled externally). Wired consistently into getAttribute, page source/XPath, and id-based find_element/find_elements so all locator paths agree once enabled. Addresses appium/appium#19560. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
eglitise
reviewed
Aug 12, 2026
eglitise
reviewed
Aug 12, 2026
Simplify the redundant empty-string check in BySelectorHelper (getResourceId already returns null for an empty value), and throw ElementNotFoundException instead of returning null when the testTag-backed id lookup finds nothing, matching the ByXPath branch's behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
rewriteIdLocator() unconditionally prepends the app package to a bare id locator, which is only correct for real Android resource ids. Compose testTags are never package-qualified, so with mapTestTagToResourceId enabled, a bare testTag search (e.g. "loginButton") was being rewritten into "com.example.app:id/loginButton" and would never match. Now the id-based XPath lookup matches against both the raw and the rewritten locator, so real resource-id autocompletion keeps working while testTag lookups match the raw value.
The four By.ById branches across findElement/findElements (both context and no-context overloads) had drifted into near-identical copies of the mapTestTagToResourceId lookup logic. Extract findElementById/findElementsById helpers, parameterized by the optional context, so there's a single place that implements this behavior.
eglitise
approved these changes
Aug 12, 2026
Move private/package-private helpers below the public API methods for consistent method ordering, precalculate the raw XPath literal once in resourceIdXPath instead of recomputing it per branch, and collapse the duplicated argument in rewriteIdLocator's error message via positional format specifiers.
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 12, 2026
## [10.6.0](v10.5.0...v10.6.0) (2026-08-12) ### Features * add mapTestTagToResourceId setting for Compose testTag support ([#791](#791)) ([1d2d583](1d2d583))
|
🎉 This PR is included in version 10.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Member
|
Should be updated as well? |
Contributor
Author
|
Good catch — |
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.
Adds an opt-in
mapTestTagToResourceIdsetting that maps Jetpack Compose's testTag semantics property onto the resource-id attribute, mirroring the behavior of Compose's own testTagsAsResourceId (which can only be set from within the app's own composable tree and cannot be toggled externally). Wired consistently into getAttribute, page source/XPath, and id-based find_element/find_elements so all locator paths agree once enabled.Addresses appium/appium#19560.