Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .clj-kondo/imports/taoensso/encore/config.edn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{:hooks
{:analyze-call
{taoensso.encore/defalias taoensso.encore/defalias
taoensso.encore/defn-cached taoensso.encore/defn-cached
taoensso.encore/defonce taoensso.encore/defonce}}}
{taoensso.encore/defalias taoensso.encore-hooks/defalias
taoensso.encore/defaliases taoensso.encore-hooks/defaliases
taoensso.encore/defn-cached taoensso.encore-hooks/defn-cached
taoensso.encore/defonce taoensso.encore-hooks/defonce}}}
82 changes: 82 additions & 0 deletions .clj-kondo/imports/taoensso/encore/taoensso/encore_hooks.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
(ns taoensso.encore-hooks
"I don't personally use clj-kondo, so these hooks are
kindly authored and maintained by contributors.
PRs very welcome! - Peter Taoussanis"
(:refer-clojure :exclude [defonce])
(:require
[clj-kondo.hooks-api :as hooks]))

(defn defalias
[{:keys [node]}]
(let [[alias src-raw _attrs body] (rest (:children node))
src (or src-raw alias)
sym (if src-raw (hooks/sexpr alias) (symbol (name (hooks/sexpr src))))]
{:node
(with-meta
(hooks/list-node
[(hooks/token-node 'def)
(hooks/token-node sym)
(if body
(hooks/list-node
;; use :body in the def to avoid unused import/private var warnings
[(hooks/token-node 'or) body src])
src)])
(meta src))}))

(defn defaliases
[{:keys [node]}]
(let [alias-nodes (rest (:children node))]
{:node
(hooks/list-node
(into
[(hooks/token-node 'do)]
(map
(fn alias->defalias [alias-node]
(cond
(hooks/token-node? alias-node)
(hooks/list-node
[(hooks/token-node 'taoensso.encore/defalias)
alias-node])

(hooks/map-node? alias-node)
(let [{:keys [src alias attrs body]} (hooks/sexpr alias-node)
;; workaround as can't seem to (get) using a token-node
;; and there's no update-keys (yet) in sci apparently
[& {:as node-as-map}] (:children alias-node)
{:keys [attrs body]} (zipmap (map hooks/sexpr (keys node-as-map))
(vals node-as-map))]
(hooks/list-node
[(hooks/token-node 'taoensso.encore/defalias)
(or alias src) (hooks/token-node src) attrs body])))))
alias-nodes))}))

(defn defn-cached
[{:keys [node]}]
(let [[sym _opts binding-vec & body] (rest (:children node))]
{:node
(hooks/list-node
(list
(hooks/token-node 'def)
sym
(hooks/list-node
(list*
(hooks/token-node 'fn)
binding-vec
body))))}))

(defn defonce
[{:keys [node]}]
;; args = [sym doc-string? attr-map? init-expr]
(let [[sym & args] (rest (:children node))
[doc-string args] (if (and (hooks/string-node? (first args)) (next args)) [(hooks/sexpr (first args)) (next args)] [nil args])
[attr-map init-expr] (if (and (hooks/map-node? (first args)) (next args)) [(hooks/sexpr (first args)) (fnext args)] [nil (first args)])

attr-map (if doc-string (assoc attr-map :doc doc-string) attr-map)
sym+meta (if attr-map (with-meta sym attr-map) sym)
rewritten
(hooks/list-node
[(hooks/token-node 'clojure.core/defonce)
sym+meta
init-expr])]

{:node rewritten}))
14 changes: 5 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,14 @@ jobs:
brew install --cask microsoft-edge
EDGE_VERSION=$(defaults read /Applications/Microsoft\ Edge.app/Contents/Info CFBundleShortVersionString)
MAJOR_VERSION=$(echo $EDGE_VERSION | cut -d'.' -f1)
DRIVER_VERSION=$(curl -s "https://msedgedriver.azureedge.net/LATEST_RELEASE_${MAJOR_VERSION}_MACOS" | iconv -f UTF-16LE -t UTF-8 | sed 's/^\xEF\xBB\xBF//' | tr -d '\r\n')
DRIVER_VERSION=$(curl -s "https://msedgedriver.microsoft.com/LATEST_RELEASE_${MAJOR_VERSION}_MACOS" | iconv -f UTF-16LE -t UTF-8 | sed 's/^\xEF\xBB\xBF//' | tr -d '\r\n')
echo "Installing msedgedriver version ${DRIVER_VERSION} for Edge version ${EDGE_VERSION}"
DRIVER_URL="https://msedgedriver.azureedge.net/${DRIVER_VERSION}/edgedriver_mac64_m1.zip"
DRIVER_URL="https://msedgedriver.microsoft.com/${DRIVER_VERSION}/edgedriver_mac64_m1.zip"
wget $DRIVER_URL
mkdir $RUNNER_TEMP/edgedriver
unzip edgedriver_mac64_m1.zip -d $RUNNER_TEMP/edgedriver
echo "$RUNNER_TEMP/edgedriver" >> $GITHUB_PATH

# No longer pre-installed on macOS github action runners
- name: Install Firefox on macOS
if: ${{ matrix.os == 'macos' && contains(matrix.needs, 'firefox') }}
run: |
brew install --cask firefox
brew install geckodriver

- uses: actions/checkout@v4

- name: Restore Clojure deps from cache
Expand Down Expand Up @@ -160,6 +153,9 @@ jobs:
run: bb tools-versions

- name: Run Tests
env:
# default is 1min, try 4min to see if that helps with Windows http timeouts
ETAOIN_TIMEOUT: ${{ (matrix.os == 'windows' && '240') || '60' }}
run: ${{ matrix.cmd }}

- name: Upload test debug output
Expand Down
2 changes: 1 addition & 1 deletion bb.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:min-bb-version "0.8.2"
:paths ["script" "build"]
:deps {doric/doric {:mvn/version "0.9.0"}
org.clj-commons/pretty {:mvn/version "3.3.2"}
org.clj-commons/pretty {:mvn/version "3.6.2"}
lread/status-line {:git/url "https://github.com/lread/status-line.git"
:sha "cf44c15f30ea3867227fa61ceb823e5e942c707f"}
dev.nubank/docopt {:mvn/version "0.6.1-fix7"}
Expand Down
12 changes: 6 additions & 6 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"} ;; min clojure version
babashka/fs {:mvn/version "0.5.25"}
babashka/fs {:mvn/version "0.5.26"}
babashka/process {:mvn/version "0.6.23"}
org.babashka/http-client {:mvn/version "0.4.23"}
slingshot/slingshot {:mvn/version "0.12.2"}
Expand All @@ -21,7 +21,7 @@
:debug {:extra-paths ["env/dev/resources"]}
:test {:extra-paths ["test" "env/test/resources" "build"]
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}
org.babashka/cli {:mvn/version "0.8.65"}
org.babashka/cli {:mvn/version "0.8.66"}
ch.qos.logback/logback-classic {:mvn/version "1.5.18"}
;; for http-client which uses apache http client 4.x which uses commons logging
org.slf4j/jcl-over-slf4j {:mvn/version "2.0.17"}
Expand Down Expand Up @@ -54,7 +54,7 @@

:clofidence {:classpath-overrides {org.clojure/clojure nil}
:extra-deps {com.github.flow-storm/clojure {:mvn/version "1.12.1"}
com.github.flow-storm/clofidence {:mvn/version "0.4.1"}}
com.github.flow-storm/clofidence {:mvn/version "0.4.2"}}
:exec-fn clofidence.main/run
:exec-args {:report-name "Etaoin Test Coverage"
:output-folder "target/clofidence"
Expand All @@ -63,7 +63,7 @@
:jvm-opts ["-Dclojure.storm.instrumentOnlyPrefixes=etaoin"]}

;; for consistent linting we use a specific version of clj-kondo through the jvm
:clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version "2025.06.05"}}
:clj-kondo {:extra-deps {clj-kondo/clj-kondo {:mvn/version "2025.07.28"}}
:main-opts ["-m" "clj-kondo.main"]}

:eastwood {:extra-deps {jonase/eastwood {:mvn/version "1.4.3"}}
Expand All @@ -74,7 +74,7 @@
:exclude-linters [:local-shadows-var]
:ignored-faults {:deprecations {etaoin.api-test true}}}]}

:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.9"}}
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.10"}}
:extra-paths ["build"]
:ns-default build}

Expand All @@ -91,7 +91,7 @@
:repl/cider
{:extra-deps {org.clojure/clojure {:mvn/version "1.12.1"}
nrepl/nrepl {:mvn/version "1.3.1"}
cider/cider-nrepl {:mvn/version "0.56.0"}
cider/cider-nrepl {:mvn/version "0.57.0"}
refactor-nrepl/refactor-nrepl {:mvn/version "3.11.0"}}
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
:main-opts ["-m" "nrepl.cmdline"
Expand Down
10 changes: 5 additions & 5 deletions doc/01-user-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ endif::[]
;; search for something interesting
(e/fill driver {:tag :input :name :search} "Clojure programming language")
(e/wait driver 1)

;; select first match presented in drop down
(e/fill driver {:tag :input :name :search} k/arrow-down)
(e/fill driver {:tag :input :name :search} k/enter)
(e/wait-visible driver {:class :mw-search-results})

;; click on first match
(e/click driver [{:class :mw-search-results} {:class :mw-search-result-heading} {:tag :a}])
(e/wait-visible driver {:id :firstHeading})

;; check our new url location
Expand All @@ -286,8 +286,8 @@ endif::[]
;; => "Clojure - Wikipedia"

;; let's explore the info box
;; What's its caption? Let's select it with a css query:
(e/get-element-text driver {:css "table.infobox caption"})
;; What's header? Let's select it with a css query:
(e/get-element-text driver {:css "table.infobox tr th"})
;; => "Clojure"

;; Ok, now let's try something trickier
Expand Down
2 changes: 1 addition & 1 deletion script/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@

(defn test-jvm [& args]
(when-let [{:keys [shell-opts test-runner-args]} (prep args)]
(apply shell/clojure shell-opts "-M:test" test-runner-args)))
(apply shell/clojure shell-opts "-J-Dclojure.main.report=stderr" "-M:test" test-runner-args)))
53 changes: 35 additions & 18 deletions test/etaoin/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[clojure.edn :as edn]
[clojure.java.io :as io]
[clojure.java.shell :as shell]
[clojure.set :as cset]
[clojure.string :as str]
[clojure.test :refer [deftest is testing use-fixtures]]
[etaoin.api :as e]
Expand Down Expand Up @@ -686,24 +687,40 @@
(deftest test-switch-window-next
(let [init-handle (e/get-window-handle *driver*)]
(dotimes [n 3]
;; press enter on link instead of clicking (safaridriver is not great with click)
(e/fill *driver* :switch-window k/return)
;; Wait for new window to show up
(e/wait-predicate
(fn [] (= (+ 1 (inc n)) (count (e/get-window-handles *driver*))))
{:timeout 30
:interval 0.1
:message (format "Timeout waiting for window #%d to be created"
(+ n 2))})
;; compensate: safari navigates to target window, others stay at source
(e/when-safari *driver*
(e/switch-window *driver* init-handle)
;; Wait for window switch to "settle" before clicking again
(e/wait-predicate
(fn [] (= init-handle (e/get-window-handle *driver*)))
{:timeout 30
:interval 0.1
:message (format "Timeout waiting for window switch")})))
(let [old-handles (e/get-window-handles *driver*)]
;; press enter on link instead of clicking (safaridriver is not great with click)
(println "clicking switch-window link on h" (e/get-window-handle *driver*))
(e/fill *driver* :switch-window k/return)
;; Wait for new window to show up
(println "waiting for new handle to be created")
(e/wait-predicate
(fn [] (= (+ 1 (inc n)) (count (e/get-window-handles *driver*))))
{:timeout 30
:interval 0.1
:message (format "Timeout waiting for window #%d to be created"
(+ n 2))})
(e/when-safari *driver*
;; anomaly last checked: 2025-08-09
;; other drivers stay on source window and return handle for source window
;; safari, navigates to target window but returns handle for source window, which confuses it
(let [new-handles (e/get-window-handles *driver*)
new-handle (first (cset/difference (set new-handles) (set old-handles)))]
;; tell safari to switch to the window it is displaying
(e/switch-window *driver* new-handle)
;; give it some time
(e/wait-predicate
(fn [] (= new-handle (e/get-window-handle *driver*)))
{:timeout 30
:interval 0.1
:message (format "Timeout waiting for window switch to new-handle")})
;; tell safari to switch to the inital window
(e/switch-window *driver* init-handle)
;; give it some time
(e/wait-predicate
(fn [] (= init-handle (e/get-window-handle *driver*)))
{:timeout 30
:interval 0.1
:message (format "Timeout waiting for window switch to init-handle")})))))
(is (= 4 (count (e/get-window-handles *driver*))) "4 windows now exist")
(is (= init-handle (e/get-window-handle *driver*)) "on first window")
(dotimes [_ 3]
Expand Down
Loading