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

[Bug] Can't use "type" command within shadow DOM #1

Closed
sangmai350 opened this issue Jun 21, 2019 · 6 comments · Fixed by #8
Closed

[Bug] Can't use "type" command within shadow DOM #1

sangmai350 opened this issue Jun 21, 2019 · 6 comments · Fixed by #8
Assignees
Labels
bug Something isn't working

Comments

@sangmai350
Copy link

Current behavior:

Screenshot 2019-06-21 13 51 28

Desired behavior:

It should work

Steps to reproduce: (app code and test code)

Screenshot 2019-06-21 13 51 11
Screenshot 2019-06-21 13 50 52
Screenshot 2019-06-21 13 50 41

***We have an iframe that contain shadow dom. And we want to get element inside that iframe to handle, but not working at current.

Versions

cypress: 3.3.1

@sangmai350 sangmai350 added the bug Something isn't working label Jun 21, 2019
@abramenal
Copy link
Owner

abramenal commented Jun 21, 2019

HI @sangmai350
Thanks for submitting the first issue!

I believe the code you wrote is not quite correct as you're using regular cypress commands for lookup.
I believe it should look somehow like:

cy.shadowGet('iframe body .input .wrp input').type(''123123);

you can also try like

cy.shadowGet('iframe body .input .wrp input')
  .then($el => cy.wrap($el).type(''123123));

Please keep in mind if you have nested shadow elements, all of their selectors must appear in query for shadowGet – otherwise it'll be unable to get to their shadow roots.

Also, it might happen that cy.type command works with only elements attached to real DOM – in that case we'll need to implement a tiny custom command to support that. I would expect that case, but first need to ensure it's really needed, so please check that code example above and let me know if that works.

UPD: Alternative I thought about just letting cypress base commands to work not only with attached DOM elements, but that either may bring extra set of documentation about that or generally inconsistency (as not all the commands might be switched).

@sangmai350
Copy link
Author

Screenshot 2019-06-21 16 55 12

Curently error that i got when try to replicate your comments. Can you please take a look?

@abramenal
Copy link
Owner

@sangmai350
Right, totally forgot the context piece:
cy.document().shadowGet
so shadowGet works within the document context only (as per docs)

@abramenal
Copy link
Owner

And regarding .type command itself – it may appear that it'll work only with passing force: true option

@abramenal abramenal changed the title [Bug] Can't use shadow [Bug] Can't use type command within shadow DOM Jun 27, 2019
@abramenal abramenal changed the title [Bug] Can't use type command within shadow DOM [Bug] Can't use "type" command within shadow DOM Jun 27, 2019
@abramenal abramenal mentioned this issue Jul 16, 2019
@abramenal
Copy link
Owner

@all-contributors add @sangmai350 for bug

@allcontributors
Copy link
Contributor

@abramenal

I've put up a pull request to add @sangmai350! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants