Skip to content

Commit

Permalink
Replace wait with wait-predicate in test-add-script
Browse files Browse the repository at this point in the history
  • Loading branch information
dgr committed Sep 25, 2024
1 parent 3754699 commit 4bf80f0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/etaoin/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,15 @@
(let [js-url (test-server-url "js/inject.js")]
(testing "adding a script"
(e/add-script *driver* js-url)
(e/wait 1)
;; We need to wait for the browser to parse the
;; script. Running "typeof <function_name>" will
;; return "function" if the function is defined (and "undefined"
;; if not).
(e/wait-predicate
(fn [] (= "function" (e/js-execute *driver* "return typeof injected_func;")))
{:timeout 30
:internval 0.1
:message "Timeout waiting for JavaScript to be parsed"})
(let [result (e/js-execute *driver* "return injected_func();")]
(is (= result "I was injected"))))))

Expand Down

0 comments on commit 4bf80f0

Please sign in to comment.