From 1e517267e0f976edbd55d06f35625c15d4159607 Mon Sep 17 00:00:00 2001 From: Uunnamed Date: Wed, 22 Jul 2020 17:59:26 +0300 Subject: [PATCH 1/2] add select fn --- resources/html/test.html | 6 ++++++ src/etaoin/api.clj | 14 ++++++++++++++ test/etaoin/api_test.clj | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/resources/html/test.html b/resources/html/test.html index 4a3f86d4..2c1fbcc7 100644 --- a/resources/html/test.html +++ b/resources/html/test.html @@ -36,6 +36,12 @@

Input section


+
diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index 800abd50..a939f30f 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -2438,6 +2438,20 @@ [driver q text] (fill-human-el driver (query driver q) text)) +(defn select + "Select element in select-box by visible text on click. + + Arguments: + + - `driver`: a driver instance, + + - `q`: a query term, see `query` function for more info, + + - `text`: a string to input." + [driver q text] + (let [el (query driver q {:fn/has-text text})] + (click-el driver el))) + (defn clear-el "Clears an element by its identifier." [driver el] diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 34f8f33a..956629fc 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -73,6 +73,14 @@ (-> (invisible? {:id :div-hidden}) is) (-> (invisible? {:id :dunno-foo-bar}) is))) +(deftest test-select + (testing "test `select` on select-box" + (let [default-val (get-element-value *driver* :simple-country) + _ (select *driver* :simple-country "France") + selected-val (get-element-value *driver* :simple-country)] + (is (= "rf" default-val)) + (is (= "fr" selected-val))))) + (deftest test-input (testing "fill multiple imputs" (doto *driver* From 47021b04b8d4851fd5e4026618375fac9b9461ac Mon Sep 17 00:00:00 2001 From: Uunnamed Date: Wed, 22 Jul 2020 18:42:53 +0300 Subject: [PATCH 2/2] update --- src/etaoin/api.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index a939f30f..3219c878 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -2449,7 +2449,7 @@ - `text`: a string to input." [driver q text] - (let [el (query driver q {:fn/has-text text})] + (let [el (query driver q {:tag :option :fn/has-text text})] (click-el driver el))) (defn clear-el