From 97c4c8024852cb214f1b6fed76c38fb94def7b56 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Thu, 22 Aug 2024 13:55:21 -0500 Subject: [PATCH 1/5] Add driver-type Adds a function named `driver-type` that returns the keyword appropriate for the specified `driver`. --- src/etaoin/api.clj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index d2311f3..305c269 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -2178,10 +2178,15 @@ ;; (defn driver? - "Return true if `driver` is of `type` (e.g. on of: `:chrome`, `:edge`, `:firefox`, `:safari`)" + "Return true if `driver` is of `type` (e.g. one of: `:chrome`, `:edge`, `:firefox`, `:safari`)" [driver type] (= (dispatch-driver driver) type)) +(defn driver-type + "Returns the type of driver (e.g., `:chrome`, `:firefox`, `:safari`, or `:edge`)." + [driver] + (dispatch-driver driver)) + (defn chrome? "Returns true if a `driver` is Chrome." [driver] From d0036bd707d3d44e2c23f027842ca6ca39ccab9a Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Thu, 22 Aug 2024 14:28:05 -0500 Subject: [PATCH 2/5] Add test for driver-type --- test/etaoin/api_test.clj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 7d54f4d..19c1f99 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -1078,6 +1078,9 @@ (->> (e/query-all-from-shadow-root *driver* {:id "shadow-root-host"} {:css "span"}) (mapv #(e/get-element-text-el *driver* %))))))) +(deftest test-driver-type + (is (#{:chrome :firefox :safari :edge} (e/driver-type *driver*)))) + (deftest test-timeouts (let [timeouts {:implicit 32134 :script 78921 From 466f5ed377a7a1eb55c2c2aa340a726ab57300a8 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Thu, 22 Aug 2024 14:28:22 -0500 Subject: [PATCH 3/5] Use driver-type in User Guide, with test --- doc/01-user-guide.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/01-user-guide.adoc b/doc/01-user-guide.adoc index f8d74bb..d489cd5 100644 --- a/doc/01-user-guide.adoc +++ b/doc/01-user-guide.adoc @@ -241,6 +241,8 @@ endif::[] ;; Start WebDriver for Firefox (def driver (e/firefox)) ;; a Firefox window should appear +(e/driver-type driver) +;; => :firefox ;; let's perform a quick Wiki session From 8d9e1350e18aaa7f8397f552e74dac9cc2a8d42b Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Thu, 22 Aug 2024 14:28:40 -0500 Subject: [PATCH 4/5] Update CHANGELOG with driver-test --- CHANGELOG.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index afc6acc..9a540d0 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -26,6 +26,7 @@ A release with an intentional breaking changes is marked with: ** {issue}620[#620]: Get stricter when unwrapping elements. ({person}dgr[@dgr]) * Docs ** {issue}559[#559]: Deprecate use of `:active` with `query` and other APIs that use `query` under the hood. ({person}dgr[@dgr]) +** {issue}642[#642]: Add `driver-type` to retrieve driver type keyword. ({person}dgr[@dgr]) == v1.1.41 [minor breaking] - 2024-08-14 [[v1.1.41]] From e30a6727d24da25580edb8bd55b2ae7a1b4afd82 Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Thu, 22 Aug 2024 15:51:09 -0500 Subject: [PATCH 5/5] Add driver-type to API namespace TOC for docs --- src/etaoin/api.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index 305c269..908571f 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -13,7 +13,8 @@ - [[with-edge]] [[with-edge-headless]] [[edge]] [[edge-headless]] [[when-edge]] [[when-not-edge]] - [[with-firefox]] [[with-firefox-headless]] [[firefox]] [[firefox-headless]] [[firefox?]] [[when-firefox]] [[when-not-firefox]] - [[with-safari]] [[safari]] [[safari?]] [[when-safari]] [[when-not-safari]] - - [[driver?]] [[running?]] [[headless?]] [[when-headless]] [[when-not-headless]] + - [[driver?]] [[driver-type]] [[running?]] + - [[headless?]] [[when-headless]] [[when-not-headless]] - [[disconnect-driver]] [[stop-driver]] [[quit]] **WebDriver Lower Level Comms**