- From: David Burns <notifications@github.com>
- Date: Wed, 14 Nov 2018 02:26:16 -0800
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/771@github.com>
When web authors are creating their web applications they are going to need to be able to test and interact with elements that may be in a shadow DOM. There have been [requests](https://github.com/w3c/webdriver/issues?utf8=%E2%9C%93&q=is%3Apr+is%3Aissue+is%3Aopen+shadow+dom+) and a [proposal](https://github.com/w3c/webdriver/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+shadow) for how to interact with the Shadow DOM as well to this [issue](https://github.com/w3c/webcomponents/issues/354) [tracker](https://github.com/w3c/webcomponents/issues/505). The main concerns from WebDriver are about finding elements and then interacting with them. ## Finding Elements. People using testing frameworks need a meaningful way to find elements on the page. Currently if a Selenium WebDriver user wants to find an element within the DOM they would do ```python driver.find_element(By.CSS, "<insert selector>") ``` Which is the equivalent of doing ```javascript document.querySelector("<insert selector>"); ``` This obviously only searches the document and never goes into the shadow DOM. If we wanted to search in the shadow DOM via JavaScript we would just switch out `document` and can mimic that in WebDriver client bindings. This will only work though for `open` shadow DOMs. I know there have been proposals that suggest testing frameworks could do their own thing to circumvent the `closed` shadow DOM. Unfortunately this will lead to a situation where we are hoping that browsers do the right thing leading to interop issues if it is not defined properly. There are also issues about injecting JavaScript onto the page as this could lead to race conditions and also doesn't preserve the page as a user would see it if people wanted to test it "as is". It would be good if we can have a mechanism to look into shadow DOMs ## Interaction with elements WebDriver allows users to interact, where possible, as the user would. If an element is (obscured)[https://w3c.github.io/webdriver/index.html#dfn-obscuring] we notify the user the element they are trying to click will have the click intercepted by another element. We do this by getting the paint order from `document.elementsFromPoint(...)`[spec link](https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint). Currently there is https://github.com/w3c/csswg-drafts/issues/556 that discusses this but, for encapsulation reasons, it doesn't want to return elements in the shadow DOM. We can work around this by recursively going down until we can't go any further and then error. If the Shadow DOM work give a mechanism that can be interoperable that make life easier. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/webcomponents/issues/771
Received on Wednesday, 14 November 2018 10:26:38 UTC