     (:value resp)))
 
 ;;
-;; find element(s)
-;;
-
-(defn q-expand
+;; Finding element(s)
+;;
+
+(defmulti find-element* dispatch-driver)
+
+(defmethod find-element* :firefox
+  [driver locator term]
+  (with-resp driver :post
+    [:session (:session @driver) :element]
+    {:using locator :value term}
+    resp
+    (-> resp :value first second)))
+
+(defmethod find-element* :default
+  [driver locator term]
+  (with-resp driver :post
+    [:session (:session @driver) :element]
+    {:using locator :value term}
+    resp
+    (-> resp :value :ELEMENT)))
+
+(defmulti find-elements* dispatch-driver)
+
+(defmethod find-elements* :default
+  [driver locator term]
+  (with-resp driver :post
+    [:session (:session @driver) :elements]
+    {:using locator :value term}
+    resp
+    (->> resp :value (mapv (comp second first)))))
+
+(defmulti find-element-from* dispatch-driver)
+
+(defmethod find-element-from* :firefox
+  [driver el locator term]
+  (with-resp driver :post
+    [:session (:session @driver) :element el :element]
+    {:using locator :value term}
+    resp
+    (-> resp :value first second)))
+
+(defmethod find-element-from* :default
+  [driver el locator term]
+  (with-resp driver :post
+    [:session (:session @driver) :element el :element]
+    {:using locator :value term}
+    resp
+    (-> resp :value :ELEMENT)))
+
+(defmulti find-elements-from* dispatch-driver)
+
+(defmethod find-elements-from* :default
+  [driver el locator term]
+  (with-resp driver :post
+    [:session (:session @driver) :element el :elements]
+    {:using locator :value term}
+    resp
+    (->> resp :value (mapv (comp second first)))))
+
+;;
+;; Querying elements (high-level API)
+;;
+
+(defmulti q-expand
   "Expands a query expression into a pair of `[locator, term]` values
   to pass them into low-level HTTP API. Throws a Slingshot exception
   in case of unsupported clause."
-  [driver q]
+  type)
+
+(defmethod q-expand clojure.lang.Keyword
+  [q]
+  (q-expand {:id q}))
+
+(defmethod q-expand java.lang.String
+  [q]
+  (q-expand {:xpath q}))
+
+(defmethod q-expand clojure.lang.IPersistentMap
+  [{:keys [xpath css] :as q}]
   (cond
-    (keyword? q)
-    [locator-xpath (xpath/expand {:id q})]
-
-    (string? q)
-    [(:locator @driver) q]
-
-    (and (map? q) (:xpath q))
-    [locator-xpath (:xpath q)]
-
-    (and (map? q) (:css q))
-    [locator-css (:css q)]
-
-    (map? q)
-    [locator-xpath (xpath/expand q)]
-
-    :else
-    (throw+ {:type :etaoin/query
-             :q q
-             :driver @driver
-             :message "Unsupported query clause"})))
-
-(defmulti find-element* dispatch-driver)
-
-(defmethod find-element* :firefox
-  [driver locator term]
-  (with-resp driver :post
-    [:session (:session @driver) :element]
-    {:using locator :value term}
-    resp
-    (-> resp :value first second)))
-
-(defmethod find-element* :default
-  [driver locator term]
-  (with-resp driver :post
-    [:session (:session @driver) :element]
-    {:using locator :value term}
-    resp
-    (-> resp :value :ELEMENT)))
-
-(defmulti find-elements* dispatch-driver)
-
-(defmethod find-elements* :default
-  [driver locator term]
-  (with-resp driver :post
-    [:session (:session @driver) :elements]
-    {:using locator :value term}
-    resp
-    (->> resp :value (mapv (comp second first)))))
-
-(defmulti find-element-from* dispatch-driver)
-
-(defmethod find-element-from* :firefox
-  [driver el locator term]
-  (with-resp driver :post
-    [:session (:session @driver) :element el :element]
-    {:using locator :value term}
-    resp
-    (-> resp :value first second)))
-
-(defmethod find-element-from* :default
-  [driver el locator term]
-  (with-resp driver :post
-    [:session (:session @driver) :element el :element]
-    {:using locator :value term}
-    resp
-    (-> resp :value :ELEMENT)))
-
-(defmulti find-elements-from* dispatch-driver)
-
-(defmethod find-elements-from* :default
-  [driver el locator term]
-  (with-resp driver :post
-    [:session (:session @driver) :element el :elements]
-    {:using locator :value term}
-    resp
-    (->> resp :value (mapv (comp second first)))))
+    xpath [locator-xpath xpath]
+    css [locator-css css]
+    :else [locator-xpath (xpath/expand q)]))
+
+#_(defmethod q-expand :default
+  [q] ;; todo
+  (throw+ {:type :etaoin/query
+           :q q
+           :driver @driver
+           :message "Unsupported query clause"}))
 
 (defn query
   "Finds an element on a page.

      (if (empty? q-rest)
        el
        (let [q (first q-rest)
              [loc term] (q-expand driver q)]
          (recur (find-element-from* driver el loc term)
                 (rest q-rest)))))

    :else
    (let [[loc term] (q-expand driver q)]
      (find-element* driver loc term))))

(defn query-all

  ([driver text]
   (has-text? driver {:tag :*} text))
  ([driver q text]
   (let [[locator term] (q-expand q)
         term1 (format "%s[contains(text(), \"%s\")]" term text)
         term2 (format "%s//*[contains(text(), \"%s\")]" term text)]
     (when-not (= locator locator-xpath)
