fix: filter hidden elements to prevent strict mode violations#841
Merged
Conversation
When locators match both visible and hidden elements (e.g. a visible <label> and a cdk-visually-hidden <input> sharing the same accessible name), strict mode throws. Now filters to visible elements before acting, consistent with chainAction and actionByRole which already had this logic. Functions fixed: actionByText, checkByText, uncheckByText, pressKey, pressKeyByRole, dragDrop. Discovered while testing Rogers MyRogers bill download — their design system uses visually-hidden native checkboxes alongside visible label elements with matching aria-labelledby. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
<label>and acdk-visually-hidden<input>sharing the samearia-labelledby), strict mode throwschainActionandactionByRolewhich already had this logicactionByText,checkByText,uncheckByText,pressKey,pressKeyByRole,dragDropContext
Discovered while testing Rogers MyRogers bill download — their design system uses visually-hidden native checkboxes alongside visible label elements with matching
aria-labelledby.check "January 24, 2026"failed with strict mode violation (2 elements matched).Test plan
check "January 24, 2026"on Rogers Save PDF modal — no strict violationcheck "February 24, 2026"— no strict violationclick,press,dragstill work on single-element locators (no regression)🤖 Generated with Claude Code