kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
430 stars 52 forks source link

add support for: css /deep/ combinator == css >>> combinator #163

Closed milahu closed 5 months ago

milahu commented 5 months ago

the css /deep/ combinator is useful to reduce boilerplate code when dealing with shadow DOM

the /deep/ combinator is no longer supported by document.querySelector

DOMException: Failed to execute 'querySelector' on 'Document': '... /deep/ ...' is not a valid selector.

implementing this would require

see also

similar #144

kaliiiiiiiiii commented 5 months ago

Hmm tbh that sounds like a lot of work to me. Why not just ust JavaScript at that point? Returning elements with javascript should work with serialisation as expected & return a WebElement

kaliiiiiiiiii commented 5 months ago

Also, I suppose adding an awaitable property shaddow to WebElement is worth a consideration

milahu commented 5 months ago

Why not just ust JavaScript at that point?

yeah, less back-and-forth between py and js

await elem.shadow? as a generic interface for iframe.content_document and others?

kaliiiiiiiiii commented 5 months ago

Why not just JavaScript at that point?

yeah, less back-and-forth between py and js

let's close that issue then:)

await elem.shadow? as a generic interface for iframe.content_document and others?

Exactly. Especially for closed shaddow dom, where JS doesn't have access to my knowledge. Shall we open a feature request issue for that?

milahu commented 5 months ago

let's close that issue then

no, this would be a nice feature

this only breaks because chromium removed it using more javascript is just an implementation detail

div = await driver.find_element(By.CSS_SELECTOR, "iframe /deep/ div")

await elem.shadow

for my taste, this should be even simpler

-  (await iframe.shadow).find_element
+  iframe.find_element
iframe = await driver.find_element(By.CSS_SELECTOR, "iframe")
div = await iframe.find_element(By.CSS_SELECTOR, "div")

or call it "document", because thats what it is

-  (await iframe.shadow).find_element
+  (await iframe.document).find_element
iframe = await driver.find_element(By.CSS_SELECTOR, "iframe")
iframe_doc = await iframe.document
div = await iframe_doc.find_element(By.CSS_SELECTOR, "div")
kaliiiiiiiiii commented 5 months ago

let's close that issue then

no, this would be a nice feature

this only breaks because chromium removed it using more javascript is just an implementation detail


div = await driver.find_element(By.CSS_SELECTOR, "iframe /deep/ div")
``

well you can open a PR on that if you want:) Don't really have the time to implement that tbh.

await elem.shadow

for my taste, this should be even simpler

-  (await iframe.shadow).find_element
+  iframe.find_element

mhh yeah simpler, but also leads to unclear behaviour, right? For example the order of the child elemets, etc.

or call it "document", because thats what it is

-  (await iframe.shadow).find_element
+  (await iframe.document).find_element

mhh I'd prefer shaddow thb. I'd say It's more clear what's meant with it. So similar to elem.shadowRoot in JS