Skip to content

Commit 7c9c5cb

Browse files
authored
Make set-<xyz>-timeout more resilient to non-integer timeout values (#658)
* Make set-<xzy>-timeout routines more robust to non-integer values * Add tests for non-integer timeouts to set-<xzy>-timeout * Update CHANGELOG for issue 657
1 parent 0ad57e0 commit 7c9c5cb

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

CHANGELOG.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ A release with an intentional breaking changes is marked with:
2929
** {issue}644[#644]: Deprecate `when-predicate` and `when-not-predicate` macros. See docstrings for guidance on alternatives. These will may be removed from the API at the next release that contains breaking changes. ({person}dgr[@dgr])
3030
** {issue}647[#647]: Fix logic bug in `intersects?`. Added tests to test suite. ({person}dgr[@dgr])
3131
** {issue}649[#649]: When supplied a vector argument for `q-text`, `fill-multi` and `fill-human-multi` now fill fields in the order that fields appear in the vector. Previously, the order was not guaranteed. ({person}dgr[@dgr])
32+
** {issue}657[#657]: Make `set-<xyz>-timeout` functions resilient to reasonable non-integer timeouts (e.g., rationals, doubles, etc.). ({person}dgr[@dgr])
3233

3334
== v1.1.41 [minor breaking] - 2024-08-14 [[v1.1.41]]
3435

src/etaoin/impl/util.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
(defmethod ~multifn dispatch-val# ~@fn-tail)))
2727

2828
(defn sec->ms [sec]
29-
(* sec 1000))
29+
(long (* sec 1000)))
3030

3131
(defn ms->sec [ms]
3232
(/ ms 1000))

test/etaoin/api_test.clj

+21-13
Original file line numberDiff line numberDiff line change
@@ -1094,19 +1094,27 @@
10941094
{:class :inside} {:tag :span}])))))
10951095

10961096
(deftest test-timeouts
1097-
(let [timeouts {:implicit 32134
1098-
:script 78921
1099-
:pageLoad 98765}]
1100-
(e/set-timeouts *driver* timeouts)
1101-
(is (= timeouts (e/get-timeouts *driver*)))
1102-
(e/set-page-load-timeout *driver* 987)
1103-
(e/set-implicit-timeout *driver* 876)
1104-
(e/set-script-timeout *driver* 765)
1105-
(is (= 987 (e/get-page-load-timeout *driver*)))
1106-
(is (= 876 (e/get-implicit-timeout *driver*)))
1107-
(is (= 765 (e/get-script-timeout *driver*)))
1108-
(is (= {:pageLoad 987000 :implicit 876000 :script 765000}
1109-
(e/get-timeouts *driver*)))))
1097+
(testing "basic timeout tests"
1098+
(let [timeouts {:implicit 32134
1099+
:script 78921
1100+
:pageLoad 98765}]
1101+
(e/set-timeouts *driver* timeouts)
1102+
(is (= timeouts (e/get-timeouts *driver*)))
1103+
(e/set-page-load-timeout *driver* 987)
1104+
(e/set-implicit-timeout *driver* 876)
1105+
(e/set-script-timeout *driver* 765)
1106+
(is (= 987 (e/get-page-load-timeout *driver*)))
1107+
(is (= 876 (e/get-implicit-timeout *driver*)))
1108+
(is (= 765 (e/get-script-timeout *driver*)))
1109+
(is (= {:pageLoad 987000 :implicit 876000 :script 765000}
1110+
(e/get-timeouts *driver*)))))
1111+
(testing "non-integer timeout values"
1112+
;; These should not throw. If they do, the test runner will record
1113+
;; a test failure.
1114+
(is (do (e/set-page-load-timeout *driver* 1.33333)
1115+
true))
1116+
(is (do (e/set-page-load-timeout *driver* 100/3)
1117+
true))))
11101118

11111119
(comment
11121120
;; start test server

0 commit comments

Comments
 (0)