Repository navigation
Raise ObsoleteNode when a node is detached before the click hit test - #360
Open
thomasklemm wants to merge 1 commit into
Open
thomasklemm wants to merge 1 commit into
thomasklemm wants to merge 1 commit into
Conversation
Node#command checks isConnected once, then before_click runs several evaluates. If the page removes the node in between, mouseEventTest called getRootNode() on the detached subtree, which has no elementFromPoint, and the click failed with a JavaScriptError that Capybara does not retry. Fixes rubycdp#359 Amp-Thread-ID: https://ampcode.com/threads/T-ea46fac7-7b01-42f9-a324-72b9afb4985c
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 #359.
Node#commandchecksthis.isConnectedonce, thenbefore_clickruns several evaluates (scrollIntoViewport,find_position,mouseEventTest). If the page removes the node between them, which React/Inertia re-renders do,mouseEventTestcallsnode.getRootNode()on the detached subtree. That root is an element, not a document, so the click fails withFerrum::JavaScriptError: TypeError: node.getRootNode(...).elementFromPoint is not a function. Capybara does not retry that error, so the test errors instead of re-finding the element.Change
mouseEventTestthrows anObsoleteNodeJS error whennode.isConnectedis false.before_clickmaps it toCapybara::Cuprite::ObsoleteNode, the same way it already mapsMouseEventFailed.ObsoleteNodeis inDriver#invalid_element_errors, so Capybara'ssynchronizereloads the element and retries.Spec
spec/node_spec.rb"raises ObsoleteNode for an element removed before the hit test" wraps_cuprite.mouseEventTestso that the node is removed right before the hit test, which makes the race deterministic. It usesnode.native.clickso that Capybara's reload does not hide the error.expected Capybara::Cuprite::ObsoleteNode, got #<Ferrum::JavaScriptError: "TypeError: node.getRootNode(...).elementFromPoint is not a function ...">.spec/node_spec.rbpasses in full (155 examples) and RuboCop is clean.Full suite locally on Chrome for Testing 156: 1809 examples, 1 failure. The failure is Capybara's shared
#obscured? should work in frames, which also fails on unchangedmainwith this Chrome locally while your CI is green, so I take it to be unrelated to this change.