Add wait-for-el polling to test runner for element readiness
wait-for-el polls the iframe doc for a CSS selector up to max-tries times with 200ms intervals. Used before running test actions to ensure the target elements exist in the iframe after page load. Also restores reload-frame timing and keeps cek-try error handling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
"true"))
|
||||
true
|
||||
(do (hs-wait 200) (wait-boot))))))
|
||||
(begin
|
||||
(reload-frame
|
||||
(fn
|
||||
()
|
||||
@@ -33,6 +34,19 @@
|
||||
(hs-wait 1000)
|
||||
(wait-boot)
|
||||
(hs-wait 500))))
|
||||
(wait-for-el
|
||||
(fn
|
||||
(sel max-tries)
|
||||
(let
|
||||
((doc (get-doc))
|
||||
(el (when doc (host-call doc "querySelector" sel))))
|
||||
(if
|
||||
el
|
||||
el
|
||||
(if
|
||||
(<= max-tries 0)
|
||||
nil
|
||||
(do (hs-wait 200) (wait-for-el sel (- max-tries 1)))))))))
|
||||
(run-action
|
||||
(fn
|
||||
(action)
|
||||
@@ -106,7 +120,7 @@
|
||||
(reset! results (assoc (deref results) name "running"))
|
||||
(reload-frame)
|
||||
(let
|
||||
((test-ok (cek-try (fn () (for-each run-action (get test :actions)) true) (fn (e) (do (reset! results (assoc (deref results) name "fail")) (console-log (str "FAIL " name ": " e)) false)))))
|
||||
((test-ok (cek-try (fn () (let ((actions (get test :actions))) (when (not (empty? actions)) (let ((first-sel (nth (first actions) 1))) (when (string? first-sel) (let ((found (wait-for-el first-sel 15))) (when (nil? found) (error (str "Timeout waiting for: " first-sel))))))) (for-each run-action actions)) true) (fn (e) (do (reset! results (assoc (deref results) name "fail")) (console-log (str "FAIL " name ": " e)) false)))))
|
||||
(when
|
||||
test-ok
|
||||
(reset! results (assoc (deref results) name "pass"))))))
|
||||
|
||||
Reference in New Issue
Block a user