BenedictWilkins / ui-capture-chrome-extension

0 stars 0 forks source link

Dealing with shadow DOM #1

Open BenedictWilkins opened 1 month ago

BenedictWilkins commented 1 month ago

Some websites use shady dom or shadow doms to hide or declutter the dom, this means that the usual traversal doesn't work. Is there a workaround for this for extracting the element layout?

Sites like youtube do this, it results in null being returned from extractLayoutTree (webuicapture\extension\chrome\content.js). See if this can be fixed, or if we will have to discard these sites (its a shame because popular sites like youtube use it!)

EDIT - actually, the problem with youtube was not due to shadow dom (it was an issue with computing visibility, which is not fixed by using checkVisibility from the Element API. However, we may still face this issue in the future so I will leave this open.

BenedictWilkins commented 1 month ago

https://cosmocode.io/how-to-interact-with-shadow-dom-in-selenium

this is probably useful. It looks like accessing elements is possible via shadowRoot is possible as long as it is "open".

If it is "closed" then we might try to circumvent it.