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]] 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 diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index d2311f3..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** @@ -2178,10 +2179,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] 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