-
Notifications
You must be signed in to change notification settings - Fork 882
fix: incorrect nested iframe xpaths #891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 7b5d562 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR fixes a critical bug in the XPath generation system for nested iframes. The core issue was that when multiple sibling iframes existed on a page, the XPath mapping would incorrectly overwrite previous siblings' paths, causing act()
operations to fail. This was due to using the parent frame as the key in the internal seg
map.
The fix changes the seg
map to be keyed by the frame itself rather than its parent frame, ensuring each iframe's XPath information is preserved independently. This is a robust solution that maintains the integrity of the XPath hierarchy while fixing the sibling iframe issue.
The changes include:
- Modified
lib/a11y/utils.ts
to use frame instead of parentFrame as map key - Added a new required
frame
field to FrameSnapshot interface - Added a new eval test case 'nested_iframes_2' to validate the fix
Confidence score: 5/5
- This PR is very safe to merge as it fixes a clear bug without introducing new complexity
- The score is 5 because the change is well-isolated, includes tests, and fixes a clear logical error in the original implementation
- While all changes look good, pay special attention to
lib/a11y/utils.ts
as it contains the core fix
4 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
@seanmcguire12 = 🐐 |
why
act
often failed on websites where the HTML follows this patterngetAccessibilityTreeWithFrames()
populates an internal map:seg: Map<Frame | null, string>
frameXpath
the XPath segment (/html/body/iframe[2], …
) pointing from that iframe’s parent document to the iframe element itselfseg.set(snapshot.parentFrame, snapshot.frameXpath);
frameXpath
would get overwritten/lostwhat changed
seg
map by the frame itself so that siblings are no longer overwrittentest plan