diff --git a/doc/01-user-guide.adoc b/doc/01-user-guide.adoc index f448f4d..58bf205 100644 --- a/doc/01-user-guide.adoc +++ b/doc/01-user-guide.adoc @@ -927,28 +927,28 @@ You can test whether an element is a shadow root host using `has-shadow-root?` a ;; => false ---- -Now that you know how to retrieve the shadow root, you can query elements in the shadow DOM using `query-shadow-root`, `query-all-shadow-root`, `query-shadow-root-el`, and `query-all-shadow-root-el`. +Now that you know how to retrieve the shadow root, you can query elements in the shadow DOM using `query-from-shadow-root`, `query-all-from-shadow-root`, `query-from-shadow-root-el`, and `query-all-from-shadow-root-el`. -For `query-shadow-root` and `query-all-shadow-root`, the `q` parameter specifies a query of the _normal_ DOM to find the shadow root host. +For `query-from-shadow-root` and `query-all-from-shadow-root`, the `q` parameter specifies a query of the _normal_ DOM to find the shadow root host. If the host is identified, the `shadow-q` parameter is a query that is executed within the shadow DOM rooted at the shadow root host. -The `query-shadow-root-el` and `query-all-shadow-root-el` allow you to specify the shadow root host element directly, rather than querying for it. +The `query-from-shadow-root-el` and `query-all-from-shadow-root-el` allow you to specify the shadow root host element directly, rather than querying for it. [source,clojure] ---- -(def in-shadow (e/query-shadow-root driver {:id "shadow-root-host"} {:css "#in-shadow"})) +(def in-shadow (e/query-from-shadow-root driver {:id "shadow-root-host"} {:css "#in-shadow"})) (e/get-element-text-el driver in-shadow) ;; => "I'm in the shadow DOM" -(->> (e/query-all-shadow-root driver {:id "shadow-root-host"} {:css "span"}) +(->> (e/query-all-from-shadow-root driver {:id "shadow-root-host"} {:css "span"}) (map #(e/get-element-text-el driver %))) ;; => ("I'm in the shadow DOM" "I'm also in the shadow DOM") (def shadow-root (e/get-element-shadow-root-el driver host)) -(e/get-element-text-el driver (e/query-shadow-root-el driver shadow-root {:css "#in-shadow"})) +(e/get-element-text-el driver (e/query-from-shadow-root-el driver shadow-root {:css "#in-shadow"})) ;; => "I'm in the shadow DOM" -(->> (e/query-all-shadow-root-el driver shadow-root {:css "span"}) +(->> (e/query-all-from-shadow-root-el driver shadow-root {:css "span"}) (map #(e/get-element-text-el driver %))) ;; > ("I'm in the shadow DOM" "I'm also in the shadow DOM") ---- diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index 102bd4a..0f933cf 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -25,7 +25,7 @@ **Querying/Selecting DOM Elements** - [[query]] [[query-all]] [[query-tree]] - - [[query-shadow-root]] [[query-shadow-root-el]] [[query-all-shadow-root]] [[query-all-shadow-root-el]] + - [[query-from-shadow-root]] [[query-from-shadow-root-el]] [[query-all-from-shadow-root]] [[query-all-from-shadow-root-el]] - [[has-shadow-root?]] [[has-shadow-root-el?]] - [[exists?]] [[absent?]] - [[displayed?]] [[displayed-el?]] [[enabled?]] [[enabled-el?]] [[disabled?]] [[invisible?]] [[visible?]] @@ -1670,7 +1670,7 @@ :value (mapv (comp second first)))) -(defn query-shadow-root-el +(defn query-from-shadow-root-el "Queries the shadow DOM rooted at `shadow-root-el`, looking for the first element specified by `shadow-q`. @@ -1681,7 +1681,7 @@ (let [[loc term] (query/expand driver shadow-q)] (find-element-from-shadow-root* driver shadow-root-el loc term))) -(defn query-all-shadow-root-el +(defn query-all-from-shadow-root-el "Queries the shadow DOM rooted at `shadow-root-el`, looking for all elements specified by `shadow-q`. @@ -1692,7 +1692,7 @@ (let [[loc term] (query/expand driver shadow-q)] (find-elements-from-shadow-root* driver shadow-root-el loc term))) -(defn query-shadow-root +(defn query-from-shadow-root "First, conducts a standard search (as if by [[query]]) for an element with a shadow root. Then, from that shadow root element, conducts a search of the shadow DOM for the first element matching `shadow-q`. @@ -1703,9 +1703,9 @@ the [[query]] function, but some drivers may limit it to specific formats (e.g., CSS). See [this note](/doc/01-user-guide.adoc#shadow-root-browser-limitations) for more information." [driver q shadow-q] - (query-shadow-root-el driver (get-element-shadow-root driver q) shadow-q)) + (query-from-shadow-root-el driver (get-element-shadow-root driver q) shadow-q)) -(defn query-all-shadow-root +(defn query-all-from-shadow-root "First, conducts a standard search (as if by [[query]]) for an element with a shadow root. Then, from that shadow root element, conducts a search of the shadow DOM for all elements matching `shadow-q`. @@ -1716,7 +1716,7 @@ the [[query]] function, but some drivers may limit it to specific formats (e.g., CSS). See [this note](/doc/01-user-guide.adoc#shadow-root-browser-limitations) for more information." [driver q shadow-q] - (query-all-shadow-root-el driver (get-element-shadow-root driver q) shadow-q)) + (query-all-from-shadow-root-el driver (get-element-shadow-root driver q) shadow-q)) ;; ;; cookies diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 1847f93..4767c1b 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -821,28 +821,28 @@ (let [shadow-root (e/get-element-shadow-root *driver* {:id "shadow-root-host"})] (testing "querying the shadow root element for a single element" (is (= "I'm in the shadow DOM" - (->> (e/query-shadow-root-el *driver* - shadow-root - {:css "#in-shadow"}) + (->> (e/query-from-shadow-root-el *driver* + shadow-root + {:css "#in-shadow"}) (e/get-element-text-el *driver*)))) (is (= "I'm also in the shadow DOM" - (->> (e/query-shadow-root-el *driver* - shadow-root - {:css "#also-in-shadow"}) + (->> (e/query-from-shadow-root-el *driver* + shadow-root + {:css "#also-in-shadow"}) (e/get-element-text-el *driver*))))) (testing "querying the shadow root element for multiple elements" (is (= ["I'm in the shadow DOM" "I'm also in the shadow DOM"] - (->> (e/query-all-shadow-root-el *driver* - shadow-root - {:css "span"}) + (->> (e/query-all-from-shadow-root-el *driver* + shadow-root + {:css "span"}) (mapv #(e/get-element-text-el *driver* %))))))) (testing "querying the shadow root element" (is (= "I'm in the shadow DOM" - (->> (e/query-shadow-root *driver* {:id "shadow-root-host"} {:css "#in-shadow"}) + (->> (e/query-from-shadow-root *driver* {:id "shadow-root-host"} {:css "#in-shadow"}) (e/get-element-text-el *driver*))))) (testing "querying the shadow root element for multiple elements" (is (= ["I'm in the shadow DOM" "I'm also in the shadow DOM"] - (->> (e/query-all-shadow-root *driver* {:id "shadow-root-host"} {:css "span"}) + (->> (e/query-all-from-shadow-root *driver* {:id "shadow-root-host"} {:css "span"}) (mapv #(e/get-element-text-el *driver* %))))))) (comment