This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-07-10
Channels
- # announcements (1)
- # babashka (17)
- # biff (7)
- # calva (6)
- # clerk (5)
- # clj-on-windows (1)
- # clojure (59)
- # clojure-austin (17)
- # clojure-brasil (1)
- # clojure-europe (40)
- # clojure-nl (2)
- # clojure-norway (103)
- # clojure-sweden (9)
- # clojure-uk (8)
- # clojurescript (8)
- # cursive (25)
- # data-science (5)
- # datalevin (7)
- # datomic (4)
- # emacs (8)
- # etaoin (13)
- # hyperfiddle (26)
- # lsp (8)
- # malli (7)
- # off-topic (9)
- # polylith (13)
- # releases (2)
- # sql (7)
Is there a way to use Etaoin functions to delve inside shadow DOM? I keep trying to do it using, e.g., query
and I’m getting “no such element” exceptions. I can see the elements in the browser inspector, but I can’t figure out how to get at them. My shadow DOM fu is pretty minimal, however, so perhaps I’m just not understanding it and there’s a selector of some sort that I should be using for shadow elements. Feel free to point me at something if this is completely unrelated to Etaoin.
Hi @U7BEY9U10! Apparently, the WebDriver spec https://www.w3.org/TR/webdriver2/#dfn-find-element-from-shadow-root. But Etaoin does not explicitly expose this yet. And we'd have to check the various WebDriver implementation support for it. Issue welcome. If you feel like you want to experiment, you can send custom requests to the web driver via https://cljdoc.org/d/etaoin/etaoin/1.0.40/api/etaoin.api#execute.
Thank you! I’ll take a look and see if I can use execute
to get at things. Much appreciated.
@UE21H2HHD, I’ve been fiddling around a bit. I can use standard Etaoin functions to find the element and retrieve the shadowRoot property, but I don’t seem to be able to query for anything below that using execute
according to the W3 doc you referenced. Firefox driver tells me that the xpath expression is invalid (it isn’t). Safari driver tells me that it had a “timeout” error, but it returns so quickly (instantaneously), I’m not sure that anything is actually timing out. Is there a way to know whether a given driver supports querying the shadow DOM, per the W3 docs? I can’t tell if these are real errors or whether the drivers are just giving up and throwing random errors because they don’t implement that functionality. I’m modeling my execute
query on find-element*
.
@U7BEY9U10, thanks for reporting back. It can be difficult to know what supports what. One important thing is to always use the latest versions of everything. Probably worth giving chromedriver a try too, just for comparison. I've found safaridriver to have the most oddities While trying to help you, I just stumbled upon https://wpt.fyi/results/webdriver/tests/classic?label=master&label=experimental&aligned perhaps it gives some insights? Not sure I'm making much sense of it after a first glance. One place to check is https://github.com/SeleniumHQ/selenium to try to figure out if it supports a feature. If it does, usually Etaoin can.
@UE21H2HHD, OK, those links were very helpful. Looks like all the browsers support it to a certain extent, with Firefox being the best. That said, there are some things that are not yet supported, including using xpath to specify the element. I have a feeling that I was using xpath since I was passing my Clojure map with my element info to query/expand
just like was done in find-element*
. I’ll need to dig in further. But it looks like it can be made to work if I use CSS selectors. I’ll report back once I give that a try. Again, thanks for the links.
@UE21H2HHD, I’m poking at things using CSS selectors and that seems to be getting farther along. So, thanks.
OK, I think I’ve figured it out after lots of play time in the REPL. I’ll try to code up some new API functions for Etaoin that encapsulate this and submit a PR. Will probably be sometime next week. I need to read through the Etaoin sources a bit to figure out how to make it fit in.
Awesome @U7BEY9U10! Could you raise an https://github.com/clj-commons/etaoin/issues first, so we can track/discuss?