I've been gradually trying to push support of shadow DOM v1 into selenium (see #4230, #5762).
However, we are still missing one major piece: traversal.
There needs to be some ability to traverse shadow DOM when calling FindElement and what not.
So maybe we can discuss some possible implementations here?
What we can't/shouldn't do:
- Alter how existing selectors work (CSS, XPath, etc. they should all behave as they do now)
- Implement deprecated things like
/deep/
- Implement our own selector syntax/mechanism
The way I see this working is that we should treat the DOM as we would in the browser, meaning there will not be a way to select a deep element in one call:
element
.FindElement(By.CssSelector("foo"))
.ShadowRoot?
.FindElement(By.CssSelector("bar"));
Which, in the browser, would be structured the same (no shortcuts):
element
.querySelector('foo')
.shadowRoot
.querySelector('bar');
So maybe we just need to implement ShadowRoot on WebElement? Which can be null (just like in the browser).
I've been gradually trying to push support of shadow DOM v1 into selenium (see #4230, #5762).
However, we are still missing one major piece: traversal.
There needs to be some ability to traverse shadow DOM when calling
FindElementand what not.So maybe we can discuss some possible implementations here?
What we can't/shouldn't do:
/deep/The way I see this working is that we should treat the DOM as we would in the browser, meaning there will not be a way to select a deep element in one call:
Which, in the browser, would be structured the same (no shortcuts):
So maybe we just need to implement
ShadowRootonWebElement? Which can benull(just like in the browser).