Permalink
Browse files

Initial commit of webdriver-logic

  • Loading branch information...
0 parents commit ef1943cca16c079c94f64393ff95701338595ebc @semperos semperos committed Nov 10, 2011
Showing with 80 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +9 −0 README.md
  3. +5 −0 project.clj
  4. +54 −0 src/webdriver_logic/core.clj
  5. +6 −0 test/webdriver_logic/test/core.clj
@@ -0,0 +1,6 @@
+pom.xml
+*jar
+/lib/
+/classes/
+.lein-failures
+.lein-deps-sum
@@ -0,0 +1,9 @@
+# WebDriver Logic
+
+The WebDriver Logic library provides a "mirror" of the [clj-webdriver](https://github.com/semperos/clj-webdriver) API, replacing its functions with ones that return goals, as understood by Clojure's [core.logic](https://github.com/clojure/core.logic) library.
+
+## License
+
+Copyright (C) 2011 Daniel L. Gregoire (semperos)
+
+Distributed under the [Eclipse Public License](http://opensource.org/licenses/eclipse-1.0.php), the same as Clojure.
@@ -0,0 +1,5 @@
+(defproject webdriver-logic "0.0.1-SNAPSHOT"
+ :description "Library for composing clj-webdriver tests using logic programming"
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [org.clojure/core.logic "0.6.5"]
+ [clj-webdriver "0.4.4"]])
@@ -0,0 +1,54 @@
+(ns webdriver-logic.core
+ (:refer-clojure :exclude [==])
+ (:use clojure.core.logic)
+ (:require [clj-webdriver.core :as wd]))
+
+(defn attributeo
+ [element attr value]
+ (== (wd/attribute element attr) value))
+
+(defn valueo
+ [element value]
+ (attributeo element :value value))
+
+(defn clearo
+ [element]
+ (attributeo element :value ""))
+
+(defn selectedo
+ [element]
+ (== (wd/selected? element) true))
+
+(defn visibleo
+ [element]
+ (== (wd/visible? element) true))
+
+(defn tag-nameo
+ [element tag-name]
+ (== (wd/tag-name element) tag-name))
+
+(defn enabledo
+ [element]
+ (== (wd/enabled? element) true))
+
+;; existso will be implemented post clj-webdriver 0.5.x
+
+(defn texto
+ [element text]
+ (== (wd/text element) text))
+
+(defn htmlo
+ [element html]
+ (== (wd/html element) html))
+
+(defn xpatho
+ [element xpath]
+ (== (wd/xpath element) xpath))
+
+(defn locationo
+ [element loc-map]
+ (== (wd/location element) loc-map))
+
+(defn location-once-visibleo
+ [element loc-map]
+ (== (wd/location-once-visible element) loc-map))
@@ -0,0 +1,6 @@
+(ns webdriver-logic.test.core
+ (:use [webdriver-logic.core])
+ (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+ (is false "No tests have been written."))

0 comments on commit ef1943c

Please sign in to comment.