-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathchrome_test.clj
42 lines (36 loc) · 1.44 KB
/
chrome_test.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(ns clj-chrome-devtools.chrome-test
"Some tests with an actual running Chrome"
(:require [clj-chrome-devtools.automation.fixture :refer [create-chrome-fixture]]
[clj-chrome-devtools.automation :refer :all]
[clojure.test :as t :refer [deftest is testing]]
[clojure.java.io :as io]
[clojure.spec.test.alpha :as stest]))
(stest/instrument)
(def test-page
(io/resource "test-page.html"))
(defonce chrome-fixture (create-chrome-fixture {:url-to-open (str test-page)}))
(t/use-fixtures :each chrome-fixture)
(deftest simple-page-load
(to test-page)
(is (= (map text-of (sel "ul#thelist li")) '("foo" "bar" "baz"))))
(deftest selectors
(to test-page)
(testing "Selectors work in place of node-refences"
(is (= "0" (text-of "#counter")))
(click [:div.countertest :button.increment])
(is (= "1" (text-of [:#counter])))
(click (sel1 "button.increment"))
(is (= "2" (text-of "div#counter")))
(double-click "button.reset")
(is (= "0" (text-of [:div#counter])))))
(deftest input
(to test-page)
(testing "Typing into an input field works"
(is (= "NO GREETING YET" (text-of "#greeting")))
(doseq [txt ["old friend"
"foo@bar"
"keys [ that require $ modifiers"]]
(input-text [:#greeter :input] txt)
(click "#greeter button")
(is (= (str "Hello, " txt "!") (text-of [:#greeting])))
(clear-text-input [:#greeter :input]))))