From 96e18c62badd1633564b6814fb8d63d75ce0046c Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Thu, 31 Oct 2019 11:05:44 -0400 Subject: [PATCH] Fix API tests for geckodriver 0.23 & ChromeDriver 2.41 (#176) * Allow delete-session call when session already deleted * Revise driver 'get' functions to match geckodriver API changes * Firefox no longer allows setting a cookie on file:/// protocol window; remove test * Fix waiting tests to match altered default intervals * Revise drag and drop test URL to match new location * Cookie test: match changed geckodriver expiry field behaviour * Drag and drop test now allows for log support in chromedriver --- src/etaoin/api.clj | 7 +++++-- test/etaoin/api_test.clj | 26 +++----------------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index 5517ee96..c695be86 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -267,7 +267,8 @@ [driver] (-> (execute {:driver driver :method :get - :path [:session (:session @driver) :window :size]}) + :path [:session (:session @driver) :window :rect]}) + :value (select-keys [:width :height]))) (defmethod get-window-size :default @@ -289,7 +290,8 @@ [driver] (-> (execute {:driver driver :method :get - :path [:session (:session @driver) :window :position]}) + :path [:session (:session @driver) :window :rect]}) + :value (select-keys [:x :y]))) (defmethod get-window-position :default @@ -813,6 +815,7 @@ (-> (execute {:driver driver :method :get :path [:session (:session @driver) :element el :rect]}) + :value (select-keys [:x :y]))) (defn get-element-location diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 2be80d21..53b61f93 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -398,14 +398,12 @@ :value "test1", :path "/", :domain "", - :expiry nil, :secure false, :httpOnly false} {:name "cookie2", :value "test2", :path "/", :domain "", - :expiry nil, :secure false, :httpOnly false}]))) (when-phantom *driver* @@ -440,7 +438,6 @@ :value "test2" :path "/" :domain "" - :expiry nil :secure false :httpOnly false}))) (when-phantom *driver* @@ -451,24 +448,6 @@ :path "/" :secure false :value "test2"}))))) - (testing "setting a cookie" - (when-not (or (phantom? *driver*) - (safari? *driver*)) - (set-cookie *driver* {:httponly false - :name "cookie3" - :domain "" - :secure false - :value "test3"}) - (when-firefox *driver* - (let [cookie (get-cookie *driver* :cookie3)] - (is (= cookie) - {:name "cookie3" - :value "test3" - :path "" - :domain "" - :expiry nil - :secure false - :httpOnly false}))))) (testing "deleting a cookie" (when-not-phantom *driver* @@ -601,9 +580,10 @@ (is false "should be caught") (catch Exception e (is true "caught") - (let [files (file-seq (io/file dir-tmp))] + (let [files (file-seq (io/file dir-tmp)) + expected-file-count (if (supports-logs? *driver*) 3 2)] (is (= (-> files rest count) - 2)))))))) + expected-file-count)))))))) (deftest test-find-quotes-in-text (doto *driver*