Skip to content

Report tag_name as ShadowRoot for shadow roots#318

Merged
route merged 1 commit into
rubycdp:mainfrom
myabc:feature/shadow-root-tag-name
Jul 9, 2026
Merged

Report tag_name as ShadowRoot for shadow roots#318
route merged 1 commit into
rubycdp:mainfrom
myabc:feature/shadow-root-tag-name

Conversation

@myabc

@myabc myabc commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

Reports tag_name as "ShadowRoot" for shadow-root nodes, un-skipping the Capybara #shadow_root should produce error messages when failing shared spec.

Why

Node#tag_name derived from description["nodeName"], which for a shadow root is #document-fragment. So failure messages scoped to a shadow root read tag="#document-fragment", whereas Capybara (and Selenium) expect tag="ShadowRoot".

How

tag_name now returns "ShadowRoot" when the node's CDP description carries shadowRootType (present only on shadow roots); everything else is unchanged. Other tag_name comparisons in the driver are against lowercased HTML tags, which a shadow root never matched anyway.

The repo's own Node#shadow_root spec previously asserted the old tag="#document-fragment" output; it's updated to the corrected tag="ShadowRoot".

Testing

  • The previously-skipped shared spec now passes.
  • All shadow-DOM specs green (11 examples: shared + Cuprite's own), plus a node regression pass (#tag_name, #[], #value, #path).
  • bundle exec rubocop clean.

Part of #307.

🤖 Authored with agent assistance.

Copilot AI review requested due to automatic review settings July 9, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_name to return "ShadowRoot" when the CDP node description includes shadowRootType.
  • 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.

@route route merged commit 8d37d1f into rubycdp:main Jul 9, 2026
6 of 7 checks passed
@route

route commented Jul 9, 2026

Copy link
Copy Markdown
Member

Perfect! Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants