From 6a28edd784a51f6a2f4469499779c30b8f1d88f2 Mon Sep 17 00:00:00 2001 From: "Alex.Shi" Date: Tue, 25 Aug 2020 11:59:47 +0300 Subject: [PATCH] add :fn/has-string && return old version has-text (#315) --- src/etaoin/xpath.clj | 4 ++++ test/etaoin/api_test.clj | 4 ++-- test/etaoin/xpath_test.clj | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/etaoin/xpath.clj b/src/etaoin/xpath.clj index 630353e6..9f144108 100644 --- a/src/etaoin/xpath.clj +++ b/src/etaoin/xpath.clj @@ -54,6 +54,10 @@ (node-equals "text()" text)) (defmethod clause :fn/has-text + [[_ text]] + (node-contains "text()" text)) + +(defmethod clause :fn/has-string [[_ text]] (node-contains "string()" text)) diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 59f1750d..02e4ea9a 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -690,8 +690,8 @@ (-> (has-text? "'quote") is))) (deftest test-has-text - (testing "test :fn/has-text" - (is (boolean (query *driver* {:fn/has-text "From the depth"})))) + (testing "test :fn/has-string" + (is (boolean (query *driver* {:fn/has-string "From the depth"})))) (testing "gloval" (is (has-text? *driver* "From the depths I've come!")) (is (has-text? *driver* "I've come from the dark"))) diff --git a/test/etaoin/xpath_test.clj b/test/etaoin/xpath_test.clj index f4f293a4..3b422ada 100644 --- a/test/etaoin/xpath_test.clj +++ b/test/etaoin/xpath_test.clj @@ -10,7 +10,9 @@ [{:tag :button :fn/text "Press Me"} ".//button[text()=\"Press Me\"]"] - [{:fn/has-text "download"} ".//*[contains(string(), \"download\")]"] + [{:fn/has-text "download"} ".//*[contains(text(), \"download\")]"] + + [{:fn/has-string "download"} ".//*[contains(string(), \"download\")]"] [{:tag :div :fn/has-class "overlay"} ".//div[contains(@class, \"overlay\")]"]