Permalink
Browse files

Add screenshot tests to all test suites, including remote ones

  • Loading branch information...
1 parent bcef55e commit b2e313fafca806ad603fe8af2a85a4c1f63189d4 @semperos committed Sep 7, 2012
View
@@ -25,11 +25,21 @@ GRID_HOST_DEFAULT=127.0.0.1
GRID_PORT_DEFAULT=3333
DO_testCore() {
+ echo ""
+ echo "##################"
+ echo "## Testing Core ##"
+ echo "##################"
+ echo ""
lein test clj-webdriver.test.firefox
lein test clj-webdriver.test.chrome
}
DO_testRemote() {
+ echo ""
+ echo "####################"
+ echo "## Testing Remote ##"
+ echo "####################"
+ echo ""
echo -n "Do you have an existing Grid running, yes or no? [${GRID_RUNNING_DEFAULT}] > "
read GRID_RUNNING_DEFAULT
shopt -s nocasematch
@@ -51,6 +61,11 @@ DO_testRemote() {
}
DO_testTaxi() {
+ echo ""
+ echo "##################"
+ echo "## Testing Taxi ##"
+ echo "##################"
+ echo ""
lein midje clj-webdriver.test.taxi
}
@@ -5,6 +5,7 @@
[clj-webdriver.test.util :only [thrown?]]
[clj-webdriver.test.config :only [test-base-url]])
(:require [clj-webdriver.cache :as cache]
+ [clojure.java.io :as io]
[clojure.tools.logging :as log])
(:import [clj_webdriver.driver.Driver]
[org.openqa.selenium TimeoutException]))
@@ -538,6 +539,15 @@
(find-element {:tag :a, :text "Moustache"})
flash))
+(defn test-screenshot
+ [driver]
+ (is (string? (get-screenshot driver :base64)))
+ (is (> (count (get-screenshot driver :bytes)) 0))
+ (is (= (class (get-screenshot driver :file)) java.io.File))
+ (is (= (class (get-screenshot driver :file "/tmp/screenshot_test.png")) java.io.File))
+ ;; the following will throw an exception if deletion fails, hence our test
+ (io/delete-file "/tmp/screenshot_test.png"))
+
;;; Fixture fn's ;;;
(defn reset-driver
[driver]
@@ -581,7 +591,8 @@
wait-until-should-throw-on-timeout
wait-until-should-allow-timeout-argument
implicit-wait-should-cause-find-to-wait
- test-flash-helper]]
+ test-flash-helper
+ test-screenshot]]
(reset-driver driver)
(seed-driver-cache driver)
(common-test driver)))
@@ -6,8 +6,7 @@
[clj-webdriver.test.util :only [start-server]]
[clj-webdriver.test.common :only [run-common-tests]]
[clj-webdriver.remote.server :only [new-remote-session stop]])
- (:require
- [clj-webdriver.remote.driver :as rd]))
+ (:require [clj-webdriver.remote.driver :as rd]))
;; Non-standard port to avoid conflicts
(let [[this-server this-driver] (new-remote-session {:port 3003} {:browser :firefox})]
@@ -31,4 +30,4 @@
;; RUN TESTS HERE
(deftest test-common-features-for-firefox-via-remote-server
- (run-common-tests driver))
+ (run-common-tests driver))
@@ -6,8 +6,7 @@
[clj-webdriver.test.util :only [start-server]]
[clj-webdriver.test.common :only [run-common-tests]]
[clj-webdriver.remote.server :only [new-remote-session stop]])
- (:require
- [clj-webdriver.remote.driver :as rd]))
+ (:require [clj-webdriver.remote.driver :as rd]))
;; Utilities
(defn hub-host

0 comments on commit b2e313f

Please sign in to comment.