fix(browser): inject data-fgp-ref attributes during ARIA snapshot#3
Merged
wolfiesch merged 2 commits intofast-gateway-protocol:masterfrom Feb 15, 2026
Merged
Conversation
…raction The @en element refs returned by browser.snapshot were not usable by interaction methods (click, fill, etc.) because nothing injected the corresponding data-fgp-ref attributes onto DOM elements. This adds attribute injection on both extraction paths: - CDP path: resolves BackendNodeId -> NodeId via DOM.describeNode, then sets data-fgp-ref via DOM.setAttributeValue - DOM fallback path: injects setAttribute('data-fgp-ref', 'eN') in the same JS loop that discovers interactive elements Old data-fgp-ref attributes are cleared at the start of each snapshot to prevent stale refs.
Adds two Chrome-dependent tests (run with `cargo test -- --ignored`): - snapshot_refs_are_findable: verifies that @en refs from a snapshot resolve to actual DOM elements via data-fgp-ref attributes - snapshot_refs_refresh_on_second_call: verifies that a second snapshot re-injects valid refs that still resolve correctly
2ceae32 to
c29999c
Compare
wolfiesch
added a commit
that referenced
this pull request
Feb 16, 2026
Co-Authored-By: Claude Opus 4.6 <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.
Description
Fix
@eNelement refs frombrowser.snapshotso they work with interaction methods (browser.click,browser.fill, etc.). Previously, snapshot extraction assigned@eNlabels but never injected the correspondingdata-fgp-refattributes onto DOM elements, soresolve_selector("@e5")could never find them.Type of Change
Related Issues
Element ref resolution (
@eNselectors) was non-functional.What Changed
Adds
data-fgp-refattribute injection during ARIA tree extraction on both paths:BackendNodeId→NodeIdviaDOM.describeNode, then setsdata-fgp-refviaDOM.setAttributeValuesetAttribute("data-fgp-ref", "eN")in the same JS loop that discovers interactive elementsOld
data-fgp-refattributes are cleared at the start of each snapshot to prevent stale refs from previous extractions.Testing
Checklist