Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for shadow_root #234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

til
Copy link

@til til commented Apr 29, 2023

Capybara added support to access an element's shadow DOM with Element#shadow_root in teamcapybara/capybara#2546 – it would be nice if Cuprite supported it too.

Here is an attempt at that. Not sure if it does everything as it should, but the specs are passing locally and I've used it successfully in a project's test suite where

# this
expect(
  evaluate_script('arguments[0].shadowRoot', page.find('.a-shadow-host'))
).to have_selector('.inside-shadow-dom')

# could be replaced with this
expect(
  page.find('.a-shadow-host').shadow_root
).to have_selector('.inside-shadow-dom')

The spec "produces error messages when failing" provided by Capybara needed to be adapted because the generated error message includes the value of tagName which is different between Selenium and Cuprite.

The added spec "extends visibility check across shadow host boundary" covers a behaviour that Selenium implements this way: the visibility of the shadow propagates down to its children.

@til til force-pushed the initial-shadow-root-support branch from bff3d8f to ceb4f86 Compare December 9, 2023 12:35
@tomdracz
Copy link

FWIW I've been playing around fixing some Shadow DOM issue using https://github.com/yuki24/capybara-shadowdom It still didn't play ball with likes of clicks not working because of some overlapping element issues.

let element = node.getRootNode().elementFromPoint(x, y); in this PR seems to be the magic sauce so having this available would be neat

@til til force-pushed the initial-shadow-root-support branch from ceb4f86 to 1578943 Compare March 23, 2024 14:36
@boardfish
Copy link

Hey! This fork has worked well for my use case – what else needs to be done to get it merged?

@til til force-pushed the initial-shadow-root-support branch from 1578943 to 9756aa7 Compare September 19, 2024 13:36
@til
Copy link
Author

til commented Sep 23, 2024

Unfortunately I don't know – I can only say that it's still working fine for me as well. Rebased, the spec failures are unrelated (and about to be fixed with #273).

@boardfish
Copy link

Maybe it's worth rebasing this onto that branch and requesting a review from @/route once it's all green? Really like what you've done here, it'd be great to get it into Cuprite stable so that we can depend on it with confidence 🎉

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