-
Notifications
You must be signed in to change notification settings - Fork 196
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
Proposal: Shadow DOM support in WebDriver #350
Comments
chrisgao:
|
Marc Fisher:
|
chrisgao:
Attachment: https://gist.github.com/andreastt/dcf4be00273f8ea55e37ef7c65d48881 |
Hi, I'm coming from w3c/webcomponents, and this issue seems relevant... From a glance at the spec, the commands seem not at all aware of shadow roots or shadow trees: Is this still any of the interest from webdriver community? The main painpoint is that finding a specific element in the whole document including shadow trees, such as finding elements with class Is there anyone else who is interested in moving this forward? |
Please note that using execute (async) script and returning the shadow root of an element, it will also end-up in a cyclic object. So we need a definition similar to |
switch to shadow dom proposal in #1320 |
@TakayoshiKochi we think we found a nice approach to deal with Shadow DOM in Puppeteer: "JS Path". It's pretty light-weight and had a very positive initial feedback from our clients. |
@aslushnikov That appears to only work for open Shadow DOM. With WebDriver we could just evaluate script and work with the returned element and it would work the same as it does in puppeteer. |
The Browser Testing and Tools Working Group just discussed The full IRC log of that discussion<AutomatedTester> Topic: Shadow DOM<AutomatedTester> Github Topic: https://github.com//issues/350 <AutomatedTester> jimevans: With the rising use of web components the ability to interact with Shadow DOM is getting more important <AutomatedTester> ... right now those components are opaque to webdriver <AutomatedTester> ... there are some work arounds using executeScript <AutomatedTester> ... and some XPATH libraries have been able to pierce Shadow DOM because CSS does not have the ability to pierce the shadowroot <jgraham> q+ <AutomatedTester> ... we need a way to "switch" or "select" into a shadow dom and test the elements in there <AutomatedTester> ... I have a straw man proposals <AutomatedTester> ... THere are some outstanding questions: <AutomatedTester> ... 1) What do we do with closed roots <AutomatedTester> ... 2) and how do we handle this. E.g. could we do element.getShadowRoot() and continue from there <jimevans> https://docs.google.com/document/d/15DYXZyWsahr1peyOWmi2QGgzi3Xb2GlITyywx-2cPXc/edit?usp=sharing <cb> https://github.com//pull/1320/files <AutomatedTester> q? <AutomatedTester> ack jgraham <AutomatedTester> jgraham: I like the shape of the proposal <AutomatedTester> ... and like going element and being able to pierce this makes sense <foolip> q+ <AutomatedTester> ... and I think that the reason why this hasn't happened hasnt been fundamental opposition to this, purely time <jgraham> q+ <AutomatedTester> AutomatedTester: I remember from TPAC last year that the DOM member from Apple said there was opposition to allowing Shadow Roots from being pierced and they said this is the main reason why CSS piercing was not allowed but Jim has told us that XPATH can get around this issue <AutomatedTester> q? <AutomatedTester> ack foolip <AutomatedTester> foolip: if I remember on Monday jgraham said that Shadow Roots would not be interacted the same was as in bidi as http <AutomatedTester> ack jgraham <AutomatedTester> jgraham: in answer to foolip the serialisation is more generic <AutomatedTester> ... we would serialise it and it would just serialise that is has a shadowroot <AutomatedTester> ... since we have generic concept of node and not a web element <foolip> ok that makes sense, if we're talking about merely finding out that something is a shadow host <AutomatedTester> jgraham: It feels like the DOM are not understanding us here and perhaps we need to go speak to them <foolip> q? <AutomatedTester> ... since this is open to Devtools but not us <AutomatedTester> ... and the next item is to I wonder if we can simplify the API to accept a now and reusing webelement. <foolip> q+ <AutomatedTester> q+ <AutomatedTester> ack foolip <jgraham> q+ <AutomatedTester> foolip: Is the frustration that people can not pierce things or are we going to have to do it for every boundary <AutomatedTester> jimevans: the proposal is to minimize the cognitive load to keep it "similar" to find elements <AutomatedTester> ... except the sematics would be that you are specifically looking in the shadow <AutomatedTester> ... no thoughts have been given for chaining <cb> q+ <AutomatedTester> ... this is purely for http and agree that bidi should be different <AutomatedTester> ack AutomatedTester <drousso> q+ <AutomatedTester> AutomatedTester: I can't see the how the people trying to reuse findElement as they seem very different to me, could you elaborate it <mathiasbynens> q+ <AutomatedTester> jgraham: I think that the DOM hierarchy would be on our side so we will be fine <AutomatedTester> ack jgraham <AutomatedTester> jgraham: ffor foolip: re: CSS piercing was seen as bad by other WG <AutomatedTester> ... and for piercing we need to make sure that piercing the Shadow DOM needs to be explicit <AutomatedTester> ... I think we should do the simple case first and see how it goes <AutomatedTester> q? <AutomatedTester> ack cb <jgraham> RRSAgent: make minutes v2 <RRSAgent> I have made the request to generate https://www.w3.org/2020/10/28-webdriver-minutes.html jgraham <AutomatedTester> cb: I have a counter proposal. It would be good to extend element.findElement(withShadow=true) and that would look inside the shadow <AutomatedTester> q? <jgraham> q+ <AutomatedTester> jimevans: I don't have a problem with that approach either <AutomatedTester> ... we just need to something <AutomatedTester> ... the tricky bit we need to think about is that we have a new error code <AutomatedTester> ... if you want inside a shadowRoot and we cant find it its because of the shadow dom and not the DOM <AutomatedTester> q? <AutomatedTester> ack drousso <AutomatedTester> drousso: regarding piercing, I dont think that we want "special paths" for automation <AutomatedTester> ... or these special paths need to be infrequent <AutomatedTester> q? <AutomatedTester> ack mathiasbynens <AutomatedTester> mathiasbynens: in puppeteer we allow people to allow people register querySelectors on their own <AutomatedTester> ... and then people can do what they want from there <AutomatedTester> ... we have one called `pierce` that pierces shadowROot <AutomatedTester> and one called `aria` for accessibility <AutomatedTester> ... I think that playright does something similar <AutomatedTester> q? <AutomatedTester> ack jgraham <AutomatedTester> jgraham: so looking at the PR we had this discussion 2 years ago <AutomatedTester> ... the backwards compatiblity issue is that if we add new parameters then we can have silent failures <mathiasbynens> To clarify, in Puppeteer you opt-in to shadow DOM piercing not through some new parameter, but by adding a prefix to the selector string. This was decided because that way, we can make it work for our 10+ APIs that accept selector strings <AutomatedTester> ... the new end points mean you will get an explicit error here <AutomatedTester> ... and that is better for everyone <mathiasbynens> Puppeteer's built-in pierce handler: https://github.com/puppeteer/puppeteer/pull/6509/files <AutomatedTester> Resolution: Write up spec prose based on jimevans proposal and the for future proposals in this area use the learning from other frameworks to see how we can improve |
I think we can close this issue now we have basic shadow dom support. Any additional feature requests should go in new issues. |
Marc Fisher:
The text was updated successfully, but these errors were encountered: