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

Selector playground does not support Shadow DOM #20989

Open
simenbrekken-visma opened this issue Apr 8, 2022 · 3 comments
Open

Selector playground does not support Shadow DOM #20989

simenbrekken-visma opened this issue Apr 8, 2022 · 3 comments
Labels
topic: selector playground 🚸 type: feature New feature that does not currently exist

Comments

@simenbrekken-visma
Copy link

Current behavior

When attempting to locate selectors using the highlight feature of the selector playground it does not locate elements within ShadowRoots even when includeShadowDom is enabled.

fixtures/shadow-dom.html

Resulting selector playground:

Screenshot 2022-04-08 at 09 59 55

Desired behavior

When includeShadowDom is enabled selector should search all available ShadowRoots. This will most likely require https://github.com/cypress-io/cypress/blob/develop/packages/runner-shared/src/iframe/aut-iframe.js#L294 to be modified as it only searches the current contentDocument.

Test code to reproduce

I wasn't able to find a test that would let me reproduce this but any test visiting the following HTML fixture should make it apparent.

<my-custom-element></my-custom-element>

<script type="module">
  window.customElements.define(
    'my-custom-element',
    class extends HTMLElement {
      constructor() {
        super();
        this.attachShadow({ mode: 'open' });
      }

      connectedCallback() {
        this.shadowRoot.innerHTML = `
        <button data-testid="first-button">First Button (data-testid="first-button")</button>
        <button data-testid="second-button">Second Button (data-testid="second-button")</button>
        <button class="third-button">Third Button (class="third-button")</button>
        <div data-testid="more-buttons">
          <button class="fourth-button">Fourth nested button (data-testid="fourth-button")</button>
        </div>
        `;
      }
    }
  );
</script>

Cypress Version

8.7.0 and 9.5.1

Other

No response

@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Apr 9, 2022
@simenbrekken-visma
Copy link
Author

I was able to fix the issue in Cypress but it appears https://github.com/ericclemmons/unique-selector does not handle Shadow DOM either so it appears that will also need a fix.

@AdrianRRo
Copy link

Any update on this? I have the same issue

@needfulthing
Copy link

Same issue here. It'll be nice to add the get() options in the playground.

@nagash77 nagash77 added type: feature New feature that does not currently exist experiment: studio Issues when using experimentalStudio labels Jul 6, 2023
@jennifer-shehane jennifer-shehane added topic: selector playground 🚸 and removed experiment: studio Issues when using experimentalStudio labels Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: selector playground 🚸 type: feature New feature that does not currently exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants