A simplified (far from fully featured) Clojure wrapper of Selenium Webdriver
lein repl
)...Import the core namespace:
(use 'webdriver.core)
Create a driver object
Chrome:
(def driver (create-driver :chrome []))
Firefox:
(def driver (create-driver :firefox []))
Headless:
(def driver (create-driver :chrome ["--headless"]))
Now you can pass the driver object into the other functions in core to manipulate it.
(to driver "https://google.com")
(set-element driver :name "q" "silly memes")
(click (wait-for-element driver :xpath "//input[@value = 'Google Search'][1]"))
From functional code:
(with-webdriver [driver :driver-type :chrome :driver-args ["--headless"]]
(to driver "https://google.com")
(set-element driver :name "q" "silly memes")
(click (wait-for-element driver :xpath "//input[@value = 'Google Search'][1]")))
etc...
core.clj contains functions to handle common browser tasks. You can either read through that or checkout tests/webdriver/core_test.clj for unit test examples.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close