Skip to content

A clojure wrapper for jBrowserDriver, which is a Selenium-compatible wrapper around JFX embedded WebKit.

License

Notifications You must be signed in to change notification settings

jackrusher/sparkledriver

Repository files navigation

Sparkledriver

Because of changes to the underlying JavaFX libraries, this library currently works with Java 1.8! It will fail immediately on more modern JVMs.

Sparkledriver glitter tractor

A mostly idiomatic wrapper around jBrowserDriver, which is a pure-Java Selenium-compatible interface to the WebKit browser library included in recent JVM versions (>=1.8) as part of JavaFX.

This library is useful when you need a full-featured browser with support for cookies, Javascript, and so on, with no native dependencies. I've found it to be a nice basis for testing web applications, scraping content from Javascript-heavy websites, automating interactions with services, and so on.

N.B. While Oracle's JVM bundles JavaFX, the OpenJDK JVM does not come with it. If you're using OpenJDK (which is the default on ubuntu, for example), you must also install the OpenJFX package on your chosen platform in order to use this library.

Quick Start

[sparkledriver "0.2.4"]

This example fetches the Clojure homepage, extracts some elements and retrieves the text of one:

(require '[sparkledriver.browser :refer [with-browser make-browser fetch!]])
(require '[sparkledriver.element :refer [find-by-xpath* text]])

(with-browser [browser (make-browser)]
  (-> (fetch! browser "http://clojure.org")
      (find-by-xpath* "//div[@class='clj-intro-message']/p")
      (nth 2)
      text))
;;=> "I hope you find Clojure's combination of facilities elegant, powerful, practical and fun to use."

There are many more specific examples in the test suite. In additon, the automatically generated codox documentation is here.

A Note on Dependencies

A case has been reported where an old version of common-codec, as a library dependency, was causing the tests to fail. If you experience this issue, please add the following dependency:

[commons-codec "1.9"]

to your project.

Completeness/Robustness

While there are still a few areas where the underlying APIs could be more completely wrapped, the core functionality has been enrobed in delicious parentheses. Some bits are better tested than others, but I am currently using this library in production.

License

Copyright © 2016-2019 Jack Rusher

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

A clojure wrapper for jBrowserDriver, which is a Selenium-compatible wrapper around JFX embedded WebKit.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published