This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-28
Channels
- # announcements (34)
- # babashka (46)
- # beginners (187)
- # biff (2)
- # calva (5)
- # cider (10)
- # clj-http (2)
- # clj-kondo (14)
- # cljs-dev (31)
- # clojars (3)
- # clojure (43)
- # clojure-europe (25)
- # clojure-nl (1)
- # clojure-uk (3)
- # clojurescript (4)
- # clr (1)
- # cursive (1)
- # datalevin (50)
- # datomic (1)
- # emacs (12)
- # etaoin (6)
- # fulcro (7)
- # helix (21)
- # hyperfiddle (20)
- # kaocha (5)
- # lsp (14)
- # malli (10)
- # off-topic (58)
- # polylith (7)
- # portal (5)
- # reagent (39)
- # reitit (10)
- # releases (11)
- # reveal (14)
- # scittle (7)
- # shadow-cljs (58)
- # sql (8)
- # tools-deps (7)
Hi, @U0YJJPFRA thanks for reaching out with a question.
I created a fiddle
directory to experiment.
In this directory I put searchtext.html
:
<html>
<body>
A sample from Slack:
<span>
GMT(+00:00)
Universal
</span>
</body>
</html>
WebDriver XPath is kinda limited, but let's explore something that might work for you instead.
The setup:
(require '[etaoin.api :as e]
'[babashka.fs :as fs])
;; open a sessions
(def driver (e/chrome))
;; navigate to your test page
(e/go driver (->> "fiddle/searchtext.html" fs/absolutize (str "file://")))
And now let's try using contains
:
(e/get-element-text driver ".//span[contains(text(),'Universal')]")
;; => "GMT(+00:00) Universal"
And the cleanup:
(e/quit driver)
Using contains
might not be as specific as you would have liked, but might be sufficient for your use case?@UE21H2HHD it's failing if you have something before like this options Etc/GMT and GMT. I had to read the parent element to get it work, not directly to that element. The code was something like this:
(defn select-element-from-options [option]
(->>
(eapi/query-tree *driver* {:data-ci "timezone-id-autocomplete-input"} {:tag :ul} {:tag :li} {:tag :a})
(filter #(= option (eapi/get-element-text-el *driver* %)))
first
(eapi/click-el *driver*)))
@U0YJJPFRA do you still need help or are you all good now?