 ;; locators
 ;;
 
+
+(defn by [driver locator]
+  (swap! driver assoc :locator locator)
+  driver)
+
 (defmacro with-locator [driver locator & body]
   `(let [old# (-> ~driver deref :locator)]
      (swap! ~driver assoc :locator ~locator)

;; find element(s)
;;

(defn by [driver locator]
  (swap! driver assoc :locator locator)
  driver)

(defmulti find dispatch-driver)

(defmethod find :firefox [driver q]
  (with-resp driver :post
    [:session (:session @driver) :element]
    {:using (:locator @driver) :value q}
    resp
    (-> resp :value first second)))

(defmethod find :default [driver q]
  (with-resp driver :post
    [:session (:session @driver) :element]
    {:using (:locator @driver) :value q}
    resp
    (-> resp :value :ELEMENT)))

;;
;; mouse

  (mouse-move-to driver q-from)
  (with-mouse-btn driver
    (mouse-move-to driver q-to)))

;;
;; click
