From 60298302124bb216b89d1f227dacd6b938de133d Mon Sep 17 00:00:00 2001 From: "Alex.Shi" Date: Wed, 5 Aug 2020 14:58:49 +0300 Subject: [PATCH] fix get-inner-html for phantomjs (#266) --- src/etaoin/api.clj | 15 +++++++++++++-- test/etaoin/api_test.clj | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index fe7e651b..092db94f 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -1121,15 +1121,26 @@ ;; ;; element inner HTML ;; - -(defn get-element-inner-html-el +(defmulti get-element-inner-html-el "Returns element's inner text by its identifier." + dispatch-driver) + +(defmethod get-element-inner-html-el + :default [driver el] {:pre [(some? el)]} (:value (execute {:driver driver :method :get :path [:session (:session @driver) :element el :property :innerHTML]}))) +(defmethod get-element-inner-html-el + :phantom + [driver el] + {:pre [(some? el)]} + (:value (execute {:driver driver + :method :get + :path [:session (:session @driver) :element el :attribute :innerHTML]}))) + (defn get-element-inner-html "Returns element's inner HTML. diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 5b8e0a03..7072133c 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -202,6 +202,11 @@ (= [nil nil nil nil]) is)))) +(deftest test-get-inner-html + (let [inner-html "
Inner HTML
" + result (get-element-inner-html *driver* :element-props)] + (is (= inner-html result)))) + (deftest test-title (doto *driver* (-> get-title (= "Webdriver Test Document") is)))