Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (32 sloc) 1.425 kb
(ns clj-webdriver.driver
(:require [clojure.core.cache :as cache])
(:import org.openqa.selenium.interactions.Actions))
(defrecord Driver [webdriver cache-spec actions])
(defn- init-cache
"Initialize cache based on given strategy"
([cache-spec]
(when (and (map? cache-spec)
(not (empty? cache-spec)))
(let [strategy-legend {:basic cache/basic-cache-factory,
:fifo cache/fifo-cache-factory,
:lru cache/lru-cache-factory,
:lirs cache/lirs-cache-factory,
:ttl cache/ttl-cache-factory,
:lu cache/lu-cache-factory}]
(atom (apply
(get strategy-legend (:strategy cache-spec))
(:args cache-spec)))))))
(defn init-driver
"Constructor for Driver records. Accepts a `driver-spec` map with the following keys:
webdriver - WebDriver instance
cache-spec - map with keys :strategy, :args, :include and :exclude, used to setup caching rules"
([] (Driver. nil nil nil))
([driver-spec]
(let [{:keys [webdriver cache-spec]} driver-spec]
(Driver. webdriver
(assoc cache-spec :cache (init-cache cache-spec))
(Actions. webdriver)))))
(defn driver?
"Function to check class of a Driver, to prevent needing to import it"
[driver]
(= (class driver) Driver))
Jump to Line
Something went wrong with that request. Please try again.