   "https://www.w3.org/TR/webdriver/#dfn-find-element-from-element"
   (-> server
       (client/call :post
-                   [:session (session-id session) :element element :element]
+                   [:session session :element element :element]
                    {:using locator :value term})
       :value
       parse-element))

  "https://www.w3.org/TR/webdriver/#dfn-get-page-source"
  (-> server
      (client/call :get
                   [:session (session-id session) :source])
      :value))

(defn ^{:chrome false}
  execute-script [{:keys [browser] :as server} session script & args]
  "https://www.w3.org/TR/webdriver/#dfn-execute-script"
  (let [method :get
        url [:session session :execute (case (:browser server)
                                         :firefox :sync
                                         :chrome :execute
                                         :phantom :execute
                                         :sync)]
        data {:script script :args args}
        resp (client/call server method url data)]
    (case (:browser server)
      :chrome (-> resp :value)
      (-> resp :value first second)
      )

    ))

(defn execute-async-script [server session script & args]
  "https://www.w3.org/TR/webdriver/#dfn-execute-async-script"
  (-> server
      (client/call :post
                   [:session (session-id session) :execute :async]
                   {:script script :args args})))

(defn get-all-cookies [server session]
  "https://www.w3.org/TR/webdriver/#dfn-get-all-cookies"
  (-> server
      (client/call :get
                   [:session (session-id session) :cookie])
      :value))

(defn get-named-cookie [server session name]
  "https://www.w3.org/TR/webdriver/#dfn-get-named-cookie"
  (-> server
      (client/call :get
                   [:session (session-id session) :cookie name])
      :value
      first))

(defn add-cookie [server session cookie]
  "https://www.w3.org/TR/webdriver/#dfn-add-cookie"
  (-> server
      (client/call :post
                   [:session (session-id session) :cookie]
                   {:cookie cookie})))

(defn delete-cookie [server session name]
  "https://www.w3.org/TR/webdriver/#dfn-delete-cookie"
  (-> server
      (client/call :delete
                   [:session (session-id session) :cookie name])))

(defn delete-all-cookies [server session]
  "https://www.w3.org/TR/webdriver/#dfn-delete-all-cookies"
  (-> server
      (client/call :delete
                   [:session (session-id session) :cookie])))

(defn perform-actions [server session actions]
  "https://www.w3.org/TR/webdriver/#dfn-perform-implementation-specific-action-dispatch-steps"
  (-> server
      (client/call :post
                   [:session (session-id session) :actions]
                   actions)))

(defn release-actions [server session]
  "https://www.w3.org/TR/webdriver/#dfn-release-actions"
  (-> server
      (client/call :delete
                   [:session (session-id session) :actions])))

(defn
  ^{:firefox false}

  Phantom.js (Ghostdriver)
  https://github.com/detro/ghostdriver/tree/873c9d660a80a3faa743e4f352571ce4559fe691/src/request_handlers
  "
  (:require [webdriver.client :as client]
            [clojure.java.io :as io]
            [clojure.data.codec.base64 :as b64]
