Repository navigation
fix(node): drop cached node id when the document is updated - #653
Merged
Merged
Conversation
Chrome invalidates node ids on DOM.documentUpdated and hands the same ids out again for the new document, so a node found before a navigation or reload acted on a different element. Page now tracks a document version and Node re-requests its id from its remote object after it changes, which raises NodeNotFoundError for a stale node. Fixes #86
…trackable" is its message
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.
Fixes #86
A
Ferrum::Nodecaches its CDP node id. Chrome invalidates node ids onDOM.documentUpdatedand reuses them for the new document, so a node found before a navigation or reload silently acted on another element:focus,click,scroll_into_view,evaluateon the node, or passing it as a script argument.This also affected Cuprite: its
this.isConnectedguard resolves the node through the same cached id, so it passed for the wrong element and the command went ahead.Changes
Page#document_versionis bumped on everyDOM.documentUpdated.Node#node_idre-requests its id from its remote object once the version changed. For a node from a previous document this raisesNodeNotFoundError, which Cuprite turns intoObsoleteNode, so Capybara reloads and retries.NodeNotFoundErrorraised byNode#node_idnow carries its message ("node is not trackable") instead of the class name.Testing
NodeNotFoundErroronfocus(twice) instead of focusing the new document's element. It fails without the fix.spec/features/driver_spec.rb:113, which also fails on main. It callsProcess#default_user_agent, removed in ref(browser): read browser details over CDP and ask /json/version only for url: #651.