feat(locator): getByRole { visible } filter#89
Merged
Conversation
Adds a { visible: true|false } option to by.role/getByRole, mirroring the
checked/disabled filters: keep only elements the toolkit reports on screen
(iOS visible="true", Android displayed="true"). Native trees frequently
carry offscreen or shadow duplicates of the same role — a hidden SwiftUI
text field behind the focused one returns first in document order, so
fill() types nowhere. { visible: true } picks the live instance.
Closes the gap that forced consumer suites to fall back to raw
'-ios predicate string:... AND visible == 1' selectors.
Merged
6 tasks
BenSheridanEdwards
added a commit
that referenced
this pull request
Jul 3, 2026
getByRole { visible } filter (#89) — pick the on-screen instance among
offscreen/shadow role duplicates, closing the last raw-predicate fallback
in consumer suites.
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
{ visible: true | false }option toby.role/getByRole, exactly mirroring the{ checked }/{ disabled }filters from feat(locator): toHaveValue matcher and getByRole checked/disabled filters #76. It keeps only elements the toolkit reports on screen — iOSvisible="true", Androiddisplayed="true".getByRole("textfield").fill(...)types nowhere.getByRole("textfield", { visible: true })picks the live instance. This closes the framework gap that forced consumer suites (WordlyMobileAutomatedTests'ios/language-selector.spec.ts) to fall back to raw-ios predicate string:type == "XCUIElementTypeTextField" AND visible == 1.name/checked/disabled; a node lacking the visibility attribute is treated as not-visible under{ visible: true }(conservative). The option is echoed indescribeSelectorfailure messages.Proof
npm run checkfeat/visible-filter:Checked 48 files in 23ms. No fixes applied.npm testvisible=picks the on-screen field among shadow duplicates and reads its value; Androiddisplayed=, absent-attribute conservatism, filter composition, and thevisible:failure-message text).ios/language-selectorspec drops its raw predicate on the next release bump.Risk
Notes
PR Proof Law
.agents/DEFINITION_OF_DONE.mdand.agents/skills/pr-inline-screenshot-proof/SKILL.md., or the proof section saysNot applicablewith the technical reason.