cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Cypress doesn't see shadow-root (user-agent) with pseudo elements

Open przedab opened this issue 1 year ago • 13 comments

Current behavior

Cypress doesn't see a shadow-root (user-agent) and I can't get access to pseudo elements inside a root.

AssertionError: Timed out retrying after 4000ms: Expected the subject to host a shadow root, but never found it.

Cypress: image

Manually: image

Desired behavior

Make access to pseudo-elements inside the shadow-root (user agent).

Test code to reproduce

describe("shadow_root_user_agent", () => {
  it("access_to_pseudo_elements", () => {
    // visit google player site
    cy.visit("https://googleads.github.io/googleads-ima-html5/vsi/");
    // get a pseudo element inside a shadow-root (user-agent)
    cy.get("#h5-player")
      .shadow()
      .find('div[pseudo="-webkit-media-controls"]')
      .should("exist");
  });
});

Repository with simple test

Cypress Version

12.9.0

Node version

18.6.0

Operating System

Win 10

Debug Logs

No response

Other

No response

przedab avatar Mar 31 '23 13:03 przedab

@przedab thanks for the reproduction. I'm not sure why this is happening. Routing to our e2e team

astone123 avatar Apr 05 '23 16:04 astone123

I have the same issue

image

ajdinmust avatar Apr 20 '23 12:04 ajdinmust

I am also hitting the same issue with lit and component testing.

ozee avatar Apr 24 '23 14:04 ozee

Any updates on this error, I am also facing the same issue.

Knack-Mehul avatar May 26 '23 12:05 Knack-Mehul

I am facing the same error, is there any update on this issue, or a workaround?

jcdvera avatar Jun 22 '23 15:06 jcdvera

Any update ?

przedab avatar Aug 07 '23 14:08 przedab

The issue still occurs! Please look into that :)

tymsam avatar Sep 07 '23 19:09 tymsam

Any updates on this?

Jaq112 avatar Sep 15 '23 11:09 Jaq112

Any update on this one?

hansyohan avatar Oct 07 '23 09:10 hansyohan

Any update on this one?

This somehow "solved" it when headed. https://www.youtube.com/watch?v=Si7PBh7cBZI

I'm not sure how it will go when headless...

hansyohan avatar Oct 07 '23 11:10 hansyohan

Hello is there any update on this issue ?

JulienMalcouronne avatar Oct 26 '23 11:10 JulienMalcouronne

So I've personally solved this issue that was happening for myself. I have some guesses as to what was happening.

I was seeing this issue in CircleCI with the latest version of Stencil and Cypress 12.16.x

First thing to note: the issue would go away when running Cypress 13.6, but then the StencilJS hydrate command wouldn't generate a functioning /hydrate/index.js. My best guess here is one of the dependancies of Cypress 13.6 conflicts with a version of the same dependency used by StencilJS. So I couldn't push Cypress higher than 12.16.x to get the hydrate to work correctly.

What I found is when I used the Date API from inside of a Stencil component utilizing the FunctionalComponent style, it would "break" the bundle and cause the timeout error on a completely unrelated Cypress test.

The fix was the move my Date API calls to the class-style component and only pass the formatted date as a string to the functional-style component and now everything is passing Cypress correctly.

My guess here is something in the bundling of functional-style components during the StencilJS build doesn't jive with what Cypress is expecting in the JS distribution and it ends up waiting for a browser API call that will never complete.

zagnut007 avatar Dec 04 '23 16:12 zagnut007

Hello 4all!

I solve the problem, using this article: https://dzone.com/articles/exploring-shadow-dom-with-examples-using-cypress

I use the: Approach 2: Using the includeShadowDom Flag in Config

Version Cypress: v12.14.0

cecchettisilva avatar Dec 20 '23 20:12 cecchettisilva

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot avatar Jul 01 '24 01:07 cypress-app-bot

Same issue here.

fterradev avatar Jul 04 '24 16:07 fterradev