Report tag_name as ShadowRoot for shadow roots#318
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aligns Cuprite’s Node#tag_name behavior for ShadowRoot nodes with Capybara/Selenium expectations by reporting tag_name as "ShadowRoot" (instead of #document-fragment), which improves Capybara failure messages and allows previously skipped shadow-root shared specs to run.
Changes:
- Update
Capybara::Cuprite::Node#tag_nameto return"ShadowRoot"when the CDP node description includesshadowRootType. - Unskip the Capybara shared spec related to shadow-root failure messages.
- Update Cuprite’s own shadow-root error message expectation to match the new tag value.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| spec/spec_helper.rb | Removes the skip entry so the shadow-root shared spec now runs. |
| spec/features/session_spec.rb | Updates the expected failure message to match tag="ShadowRoot". |
| lib/capybara/cuprite/node.rb | Special-cases tag_name for shadow-root nodes using shadowRootType. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
Perfect! Thx |
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.
What
Reports
tag_nameas"ShadowRoot"for shadow-root nodes, un-skipping the Capybara#shadow_root should produce error messages when failingshared spec.Why
Node#tag_namederived fromdescription["nodeName"], which for a shadow root is#document-fragment. So failure messages scoped to a shadow root readtag="#document-fragment", whereas Capybara (and Selenium) expecttag="ShadowRoot".How
tag_namenow returns"ShadowRoot"when the node's CDP description carriesshadowRootType(present only on shadow roots); everything else is unchanged. Othertag_namecomparisons in the driver are against lowercased HTML tags, which a shadow root never matched anyway.The repo's own
Node#shadow_rootspec previously asserted the oldtag="#document-fragment"output; it's updated to the correctedtag="ShadowRoot".Testing
#tag_name,#[],#value,#path).bundle exec rubocopclean.Part of #307.
🤖 Authored with agent assistance.