This is a Clojure library for driving a web browser using Selenium-WebDriver as the backend. For more comprehensive documentation on all of clj-webdriver's features, read the Github wiki. You can generate documentation locally with lein doc
(API docs) or lein marg
(annotated source).
Release Type | Date | Leiningen/Maven |
---|---|---|
Stable | Feb 15 2012 | [clj-webdriver "0.5.1"] |
Pre-Release | May 2 2012 | [clj-webdriver "0.6.0-alpha8"] |
clj-webdriver Resources
External Resources
Please join the Google group if you use this library. I regularly post announcements about upcoming releases, and although I ensure all tests are passing and try to maintain good test coverage before releases, user testing is invaluable. Thank you!
This library is compatible with Clojure 1.3.0.
Here's a complete example of how to log into Github, using the high-level Taxi API:
(use 'clj-webdriver.taxi)
;; Start up a browser
(set-driver! {:browser :firefox} "https://github.com")
(click "a[href*='login']")
(input-text "#login_field" "your-username")
(input-text "#password" "your-password")
(submit "#password")
(quit)
Forms can be filled out en masse using the quick-fill-submit
function:
(quick-fill-submit {"#login_field" "your-username"}
{"#password" "your-password"}
{"#password" submit})
For API documentation on the high-level Taxi API (shown above), please see its wiki page.
For reference documentation, run lein doc
at the root of this repo. For annotated source documentation, run lein marg
.
The master
branch of clj-webdriver houses code intended for the next minor-version release. If you want to propose new features for the next release, you're welcome to fork, make a topic branch and issue a pull request against the master
branch.
If you want to fix a bug in the current release, please pull against the appropriate branch for the current minor version, 0.5.x.
The namespace clj-webdriver.test.example-app.core
contains a Ring app (routing by Moustache) that acts as the "control application" for this project's test suite.
Use lein test
to run this library's test suite. Ensure port 5744 is free, or edit test/clj_webdriver/test/core.clj
before running the tests. To run tests for the Taxi API, make sure you have the lein-midje
plugin installed and run:
lein midje clj-webdriver.test.taxi
It is highly recommended that you run the test suite for each browser separately, as otherwise you will see strange errors. Each supported browser has its own namespace, for example:
lein test clj-webdriver.test.firefox
Note: If you just want to run the example app that clj-webdriver uses for its testing purposes, do the following:
- Open a terminal and run
lein repl
orlein swank
at the root of this project - Evaluate
(use 'clj-webdriver.test.example-app.core 'ring.adapter.jetty)
- Evaluate
(defonce my-server (run-jetty #'routes {:port 5744, :join? false}))
, making sure to adjust thetest-port
intest/clj_webdriver/test/core.clj
to whatever you use here.
Credits to mikitebeka/webdriver-clj for the initial code for this project and many of the low-level wrappers around the Selenium-WebDriver API.
Many thanks to those who have contributed so far (in nick-alphabetical order):
See Github for an up-to-date list of contributors
Distributed under the Eclipse Public License, the same as Clojure.