Git Product home page Git Product logo

sparkledriver's Introduction

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.

sparkledriver's People

Contributors

abhi18av avatar daveliepmann avatar dotemacs avatar edporras avatar jackrusher avatar m9dfukc avatar plexus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkledriver's Issues

close-browser! hangs with multiple windows

If you try to close the browser when the current browser is not 0, then close-browser! stalls.

For example, this code stalls
(def browser (make-browser))
(fetch! browser "https://www.google.com")
(execute-script browser "window.open('https://www.amazon.com');")
(switch-to-window browser "1")
;; do stuff in new browser window
(close-browser! browser)

but this code works and closes the browser
(def browser (make-browser))
(fetch! browser "https://www.google.com")
(execute-script browser "window.open('https://www.amazon.com');")
(switch-to-window browser "1")
;; do stuff in new browser window
(switch-to-window browser "0") ;; this is required otherwise close-browser! hangs
(close-browser! browser)

perhaps close-browser! should always switch to 0 before closing?

performance

Hi, i found your work and probably i have stupid question. Why your solution with WebKit is so slow?

(fetch! browser "https://www.otodom.pl/oferta/zielone-tarasy-ID2QLph.html") takes 15 sec. while in safari it takes 1 sec.

PS http://clojure.org load fast.
PS2 I am looking library for crawler.

Using sparkledriver with certain dependencies, causes the tests to fail

This might be a fault of my own, but I'm not sure how to use sparkledriver within a project.

I added it to a real project and started to experience issues. So to reproduce the issue, I created a sample repo to show you what I mean.

Adding it to :dependencies, like here:

https://github.com/dotemacs/glitter-truck/blob/master/project.clj#L7

the simple tests pass just fine:

https://github.com/dotemacs/glitter-truck/blob/master/test/glitter_truck/core_test.clj

But including any of the dependencies which I have in the real project, such as these (that are commented out, in with-loads-of-deps branch):

https://github.com/dotemacs/glitter-truck/blob/with-loads-of-deps/project.clj#L7-L9

the tests fail with:

Click to expand stacktrace $ lein test

lein test glitter-truck.core-test
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[2017-07-18T23:47:41.846][Instance 1][Port 49990] Jul 19, 2017 12:47:41 AM com.sun.webkit.network.URLLoader doRun
[2017-07-18T23:47:41.846][Instance 1][Port 49990] WARNING: Unexpected error
[2017-07-18T23:47:41.846][Instance 1][Port 49990] java.io.IOException: org.apache.commons.codec.digest.DigestUtils.sha1Hex(Ljava/lang/String;)Ljava/lang/String;: http://clojure.org/
[2017-07-18T23:47:41.846][Instance 1][Port 49990] at com.machinepublishers.jbrowserdriver.StreamConnection.exec(StreamConnection.java:367)
[2017-07-18T23:47:41.846][Instance 1][Port 49990] at com.machinepublishers.jbrowserdriver.StreamConnection.getResponseCode(StreamConnection.java:447)
[2017-07-18T23:47:41.846][Instance 1][Port 49990] at com.sun.webkit.network.URLLoader.receiveResponse(URLLoader.java:420)
[2017-07-18T23:47:41.846][Instance 1][Port 49990] at com.sun.webkit.network.URLLoader.doRun(URLLoader.java:164)
[2017-07-18T23:47:41.846][Instance 1][Port 49990] at com.sun.webkit.network.URLLoader.lambda$run$94(URLLoader.java:129)
[2017-07-18T23:47:41.846][Instance 1][Port 49990] at java.security.AccessController.doPrivileged(Native Method)
[2017-07-18T23:47:41.846][Instance 1][Port 49990] at com.sun.webkit.network.URLLoader.run(URLLoader.java:128)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at java.lang.Thread.run(Thread.java:745)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] Caused by: java.lang.NoSuchMethodError: org.apache.commons.codec.digest.DigestUtils.sha1Hex(Ljava/lang/String;)Ljava/lang/String;
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at com.machinepublishers.jbrowserdriver.HttpCache.getEntry(HttpCache.java:87)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at org.apache.http.impl.client.cache.CacheInvalidator.getEntry(CacheInvalidator.java:137)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at org.apache.http.impl.client.cache.CacheInvalidator.flushInvalidatedCacheEntries(CacheInvalidator.java:86)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at org.apache.http.impl.client.cache.BasicHttpCache.flushInvalidatedCacheEntriesFor(BasicHttpCache.java:361)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at org.apache.http.impl.client.cache.CachingExec.flushEntriesInvalidatedByRequest(CachingExec.java:420)
[2017-07-18T23:47:41.847][Instance 1][Port 49990] at org.apache.http.impl.client.cache.CachingExec.execute(CachingExec.java:265)
[2017-07-18T23:47:41.848][Instance 1][Port 49990] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
[2017-07-18T23:47:41.848][Instance 1][Port 49990] at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
[2017-07-18T23:47:41.848][Instance 1][Port 49990] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
[2017-07-18T23:47:41.848][Instance 1][Port 49990] at com.machinepublishers.jbrowserdriver.StreamConnectionClient.execute(StreamConnectionClient.java:175)
[2017-07-18T23:47:41.848][Instance 1][Port 49990] at com.machinepublishers.jbrowserdriver.StreamConnection.exec(StreamConnection.java:333)
[2017-07-18T23:47:41.848][Instance 1][Port 49990] ... 11 more
[2017-07-18T23:47:41.848][Instance 1][Port 49990]

lein test :only glitter-truck.core-test/simplest-test

FAIL in (simplest-test) (core_test.clj:8)
status code
expected: (= 200 (-> (make-browser) (fetch! "http://clojure.org") status-code))
actual: (not (= 200 499))
[2017-07-18T23:47:43.013][Instance 2][Port 50001] Jul 19, 2017 12:47:43 AM com.sun.webkit.network.URLLoader doRun
[2017-07-18T23:47:43.013][Instance 2][Port 50001] WARNING: Unexpected error
[2017-07-18T23:47:43.013][Instance 2][Port 50001] java.io.IOException: org.apache.commons.codec.digest.DigestUtils.sha1Hex(Ljava/lang/String;)Ljava/lang/String;: http://clojure.org/
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at com.machinepublishers.jbrowserdriver.StreamConnection.exec(StreamConnection.java:367)
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at com.machinepublishers.jbrowserdriver.StreamConnection.getResponseCode(StreamConnection.java:447)
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at com.sun.webkit.network.URLLoader.receiveResponse(URLLoader.java:420)
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at com.sun.webkit.network.URLLoader.doRun(URLLoader.java:164)
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at com.sun.webkit.network.URLLoader.lambda$run$94(URLLoader.java:129)
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at java.security.AccessController.doPrivileged(Native Method)
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at com.sun.webkit.network.URLLoader.run(URLLoader.java:128)
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[2017-07-18T23:47:43.013][Instance 2][Port 50001] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at java.lang.Thread.run(Thread.java:745)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] Caused by: java.lang.NoSuchMethodError: org.apache.commons.codec.digest.DigestUtils.sha1Hex(Ljava/lang/String;)Ljava/lang/String;
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at com.machinepublishers.jbrowserdriver.HttpCache.getEntry(HttpCache.java:87)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at org.apache.http.impl.client.cache.CacheInvalidator.getEntry(CacheInvalidator.java:137)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at org.apache.http.impl.client.cache.CacheInvalidator.flushInvalidatedCacheEntries(CacheInvalidator.java:86)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at org.apache.http.impl.client.cache.BasicHttpCache.flushInvalidatedCacheEntriesFor(BasicHttpCache.java:361)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at org.apache.http.impl.client.cache.CachingExec.flushEntriesInvalidatedByRequest(CachingExec.java:420)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at org.apache.http.impl.client.cache.CachingExec.execute(CachingExec.java:265)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
[2017-07-18T23:47:43.014][Instance 2][Port 50001] at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
[2017-07-18T23:47:43.015][Instance 2][Port 50001] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
[2017-07-18T23:47:43.015][Instance 2][Port 50001] at com.machinepublishers.jbrowserdriver.StreamConnectionClient.execute(StreamConnectionClient.java:175)
[2017-07-18T23:47:43.015][Instance 2][Port 50001] at com.machinepublishers.jbrowserdriver.StreamConnection.exec(StreamConnection.java:333)
[2017-07-18T23:47:43.015][Instance 2][Port 50001] ... 11 more
[2017-07-18T23:47:43.015][Instance 2][Port 50001]

lein test :only glitter-truck.core-test/simplest-test

ERROR in (simplest-test) (NativeConstructorAccessorImpl.java:-2)
matching line
expected: (= "I hope you find Clojure's combination of facilities elegant, powerful, practical and fun to use." (foo))
actual: org.openqa.selenium.NoSuchElementException: Element not found or does not exist.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'machine.local', ip: '192.168.1.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_102'
Driver info: driver.version: unknown
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'machine.local', ip: '192.168.1.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_102'
Driver info: driver.version: JBrowserDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance (Constructor.java:423)
com.machinepublishers.jbrowserdriver.Util.handleException (Util.java:131)
com.machinepublishers.jbrowserdriver.JBrowserDriver.findElementsByXPath (JBrowserDriver.java:769)
sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke (Method.java:498)
clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:93)
clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
sparkledriver.core$find_by_xpath_STAR_.invokeStatic (core.clj:127)
sparkledriver.core$find_by_xpath_STAR_.invoke (core.clj:124)
glitter_truck.core$foo.invokeStatic (core.clj:8)
glitter_truck.core$foo.invoke (core.clj:4)
glitter_truck.core_test$fn__345.invokeStatic (core_test.clj:14)
glitter_truck.core_test/fn (core_test.clj:6)
clojure.test$test_var$fn__7983.invoke (test.clj:716)
clojure.test$test_var.invokeStatic (test.clj:716)
clojure.test$test_var.invoke (test.clj:707)
clojure.test$test_vars$fn__8005$fn__8010.invoke (test.clj:734)
clojure.test$default_fixture.invokeStatic (test.clj:686)
clojure.test$default_fixture.invoke (test.clj:682)
clojure.test$test_vars$fn__8005.invoke (test.clj:734)
clojure.test$default_fixture.invokeStatic (test.clj:686)
clojure.test$default_fixture.invoke (test.clj:682)
clojure.test$test_vars.invokeStatic (test.clj:730)
clojure.test$test_all_vars.invokeStatic (test.clj:736)
clojure.test$test_ns.invokeStatic (test.clj:757)
clojure.test$test_ns.invoke (test.clj:742)
user$eval85$fn__136.invoke (form-init5469215561029139845.clj:1)
clojure.lang.AFn.applyToHelper (AFn.java:156)
clojure.lang.AFn.applyTo (AFn.java:144)
clojure.core$apply.invokeStatic (core.clj:648)
clojure.core$apply.invoke (core.clj:641)
leiningen.core.injected$compose_hooks$fn__19.doInvoke (form-init5469215561029139845.clj:1)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invokeStatic (core.clj:646)
clojure.core$apply.invoke (core.clj:641)
leiningen.core.injected$run_hooks.invokeStatic (form-init5469215561029139845.clj:1)
leiningen.core.injected$run_hooks.invoke (form-init5469215561029139845.clj:1)
leiningen.core.injected$prepare_for_hooks$fn__24$fn__25.doInvoke (form-init5469215561029139845.clj:1)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
clojure.lang.RestFn.invoke (RestFn.java:408)
clojure.core$map$fn__4785.invoke (core.clj:2646)
clojure.lang.LazySeq.sval (LazySeq.java:40)
clojure.lang.LazySeq.seq (LazySeq.java:49)
clojure.lang.Cons.next (Cons.java:39)
clojure.lang.RT.boundedLength (RT.java:1749)
clojure.lang.RestFn.applyTo (RestFn.java:130)
clojure.core$apply.invokeStatic (core.clj:648)
clojure.test$run_tests.invokeStatic (test.clj:767)
clojure.test$run_tests.doInvoke (test.clj:767)
clojure.lang.RestFn.applyTo (RestFn.java:137)
clojure.core$apply.invokeStatic (core.clj:646)
clojure.core$apply.invoke (core.clj:641)
user$eval85$fn__148$fn__179.invoke (form-init5469215561029139845.clj:1)
user$eval85$fn__148$fn__149.invoke (form-init5469215561029139845.clj:1)
user$eval85$fn__148.invoke (form-init5469215561029139845.clj:1)
user$eval85.invokeStatic (form-init5469215561029139845.clj:1)
user$eval85.invoke (form-init5469215561029139845.clj:1)
clojure.lang.Compiler.eval (Compiler.java:6927)
clojure.lang.Compiler.eval (Compiler.java:6917)
clojure.lang.Compiler.load (Compiler.java:7379)
clojure.lang.Compiler.loadFile (Compiler.java:7317)
clojure.main$load_script.invokeStatic (main.clj:275)
clojure.main$init_opt.invokeStatic (main.clj:277)
clojure.main$init_opt.invoke (main.clj:277)
clojure.main$initialize.invokeStatic (main.clj:308)
clojure.main$null_opt.invokeStatic (main.clj:342)
clojure.main$null_opt.invoke (main.clj:339)
clojure.main$main.invokeStatic (main.clj:421)
clojure.main$main.doInvoke (main.clj:384)
clojure.lang.RestFn.invoke (RestFn.java:421)
clojure.lang.Var.invoke (Var.java:383)
clojure.lang.AFn.applyToHelper (AFn.java:156)
clojure.lang.Var.applyTo (Var.java:700)
clojure.main.main (main.java:37)
Caused by: org.openqa.selenium.NoSuchElementException: Element not found or does not exist.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'machine.local', ip: '192.168.1.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_102'
Driver info: driver.version: unknown
at com.machinepublishers.jbrowserdriver.ElementServer.validate (ElementServer.java:212)
com.machinepublishers.jbrowserdriver.ElementServer.access$000 (ElementServer.java:61)
com.machinepublishers.jbrowserdriver.ElementServer$1.perform (ElementServer.java:155)
com.machinepublishers.jbrowserdriver.AppThread$Runner.run (AppThread.java:91)
com.sun.javafx.application.PlatformImpl.lambda$null$173 (PlatformImpl.java:295)
java.security.AccessController.doPrivileged (AccessController.java:-2)
com.sun.javafx.application.PlatformImpl.lambda$runLater$174 (PlatformImpl.java:294)
com.machinepublishers.glass.ui.monocle.RunnableProcessor.runLoop (RunnableProcessor.java:94)
com.machinepublishers.glass.ui.monocle.RunnableProcessor.run (RunnableProcessor.java:53)
java.lang.Thread.run (Thread.java:745)

Ran 1 tests containing 2 assertions.
1 failures, 1 errors.
Tests failed.

Then I tried to setup project.clj like this, with sparkledriver under :test profile:

(defproject glitter-truck "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 ;; [ring "1.6.2"]
                 ;; [compojure "1.6.0"]
                 ;; [crypto-random "1.2.0"]
                 ]
  :profiles {:test {:dependencies [[sparkledriver "0.1.8"]]}})

Running the test like this, it passes, but uncommenting one of the dependencies, it fails again, with the same error.

Is there something else that needs to be done to use sparkledriver within a project?
Am I missing something really obvious?

Error while running the example

Hi @jackrusher

I was trying to play with the sparkledriver for a project and I keep running into this warning message upon running the code in the ReadMe.md

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[2017-09-16T06:31:38.162] java.lang.ExceptionInInitializerError
[2017-09-16T06:31:38.164] 	at com.machinepublishers.jbrowserdriver.JBrowserDriverServer.main(JBrowserDriverServer.java:81)
[2017-09-16T06:31:48.200] Caused by: org.openqa.selenium.WebDriverException: org.apache.http.impl.cookie.RFC2965Spec.<init>(boolean, [Lorg.apache.http.cookie.CommonCookieAttributeHandler;)
[2017-09-16T06:31:48.201] Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
[2017-09-16T06:31:48.203] System info: host: 'abhinavs-MacBook-Pro.local', ip: '192.168.1.4', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.4', java.version: '1.8.0_131'
[2017-09-16T06:31:48.205] Driver info: driver.version: unknown
[2017-09-16T06:31:48.206] 	at com.machinepublishers.jbrowserdriver.Util.handleException(Util.java:139)
[2017-09-16T06:31:48.206] 	at com.machinepublishers.jbrowserdriver.LaxCookieSpecProvider.create(LaxCookieSpecProvider.java:170)
[2017-09-16T06:31:48.207] 	at com.machinepublishers.jbrowserdriver.CookieStore.<clinit>(CookieStore.java:42)
[2017-09-16T06:31:48.207] 	... 1 more
[2017-09-16T06:31:48.207] Caused by: java.lang.NoSuchMethodException: org.apache.http.impl.cookie.RFC2965Spec.<init>(boolean, [Lorg.apache.http.cookie.CommonCookieAttributeHandler;)
[2017-09-16T06:31:48.208] 	at java.lang.Class.getConstructor0(Class.java:3082)
[2017-09-16T06:31:48.208] 	at java.lang.Class.getDeclaredConstructor(Class.java:2178)
[2017-09-16T06:31:48.208] 	at com.machinepublishers.jbrowserdriver.LaxCookieSpecProvider.create(LaxCookieSpecProvider.java:95)
[2017-09-16T06:31:48.209] 	... 2 more

However, the code does print out the expected
I hope you find Clojure's combination of facilities elegant, powerful, practical and fun to use.

And it doesn't happen again after the first call , could you please guide me how to solve this?

Error : Could not launch browser

Hi @jackrusher

I'm trying this out on a different machine, ubuntu 16.04 but upon executing the example I run into the following error

2. Unhandled org.openqa.selenium.WebDriverException
   Could not launch browser. Build info: version: '2.53.0', revision:
   '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
   System info: host: 'neanderthal', ip: '127.0.1.1', os.name: 'Linux', os.arch:
   'amd64', os.version: '4.4.0-93-generic', java.version: '1.8.0_144' Driver
   info: driver.version: JBrowserDriver

                 Util.java:  139  com.machinepublishers.jbrowserdriver.Util/handleException
       JBrowserDriver.java:  339  com.machinepublishers.jbrowserdriver.JBrowserDriver/<init>
NativeConstructorAccessorImpl.java:   -2  sun.reflect.NativeConstructorAccessorImpl/newInstance0
NativeConstructorAccessorImpl.java:   62  sun.reflect.NativeConstructorAccessorImpl/newInstance
DelegatingConstructorAccessorImpl.java:   45  sun.reflect.DelegatingConstructorAccessorImpl/newInstance
          Constructor.java:  423  java.lang.reflect.Constructor/newInstance
            Reflector.java:  180  clojure.lang.Reflector/invokeConstructor
               browser.clj:   56  sparkledriver.browser/make-browser
               browser.clj:   34  sparkledriver.browser/make-browser
               RestFn.java:  397  clojure.lang.RestFn/invoke
                      REPL:   17  user/eval17718
                      REPL:   17  user/eval17718
             Compiler.java: 7005  clojure.lang.Compiler/eval
             Compiler.java: 6968  clojure.lang.Compiler/eval
                  core.clj: 3194  clojure.core/eval
                  core.clj: 3190  clojure.core/eval
                  main.clj:  242  clojure.main/repl/read-eval-print/fn
                  main.clj:  242  clojure.main/repl/read-eval-print
                  main.clj:  260  clojure.main/repl/fn
                  main.clj:  260  clojure.main/repl
                  main.clj:  176  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1970  clojure.core/with-bindings*
                  core.clj: 1970  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1149  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  624  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  748  java.lang.Thread/run

1. Caused by java.lang.IllegalStateException
   Could not launch browser.

       JBrowserDriver.java:  339  com.machinepublishers.jbrowserdriver.JBrowserDriver/<init>
NativeConstructorAccessorImpl.java:   -2  sun.reflect.NativeConstructorAccessorImpl/newInstance0
NativeConstructorAccessorImpl.java:   62  sun.reflect.NativeConstructorAccessorImpl/newInstance
DelegatingConstructorAccessorImpl.java:   45  sun.reflect.DelegatingConstructorAccessorImpl/newInstance
          Constructor.java:  423  java.lang.reflect.Constructor/newInstance
            Reflector.java:  180  clojure.lang.Reflector/invokeConstructor
               browser.clj:   56  sparkledriver.browser/make-browser
               browser.clj:   34  sparkledriver.browser/make-browser
               RestFn.java:  397  clojure.lang.RestFn/invoke
                      REPL:   17  user/eval17718
                      REPL:   17  user/eval17718
             Compiler.java: 7005  clojure.lang.Compiler/eval
             Compiler.java: 6968  clojure.lang.Compiler/eval
                  core.clj: 3194  clojure.core/eval
                  core.clj: 3190  clojure.core/eval
                  main.clj:  242  clojure.main/repl/read-eval-print/fn
                  main.clj:  242  clojure.main/repl/read-eval-print
                  main.clj:  260  clojure.main/repl/fn
                  main.clj:  260  clojure.main/repl
                  main.clj:  176  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1970  clojure.core/with-bindings*
                  core.clj: 1970  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1149  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  624  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  748  java.lang.Thread/run

Am I doing something silly here ?

Fails when used with lucidity library for clojure

Hi @jackrusher

I'm reporting an issue regarding the failure of jBrowserDriver engine to start when I included https://clojars.org/zcaudate/lucid as a dependency.

Here's my configuration

  :dependencies [[org.clojure/clojure "1.9.0"]
                 [sparkledriver "0.2.2"]
;; This inclusion causes many errors in the code
                 [zcaudate/lucid "1.4.4"]
                ; [zcaudate/lucid "1.4.4" :exclusions [org.slf4j/slf4j-log4j] ]


]

src file missing

Hi,

is it me or am I doing something wrong ... looks like the src/sparkledriver/core.clj is missing since release 0.2.0?!

screenshot on element (yet) not working

According to the documentation the screenshot function takes either browser or element ... unfortunately I am getting a Screenshot not supported on jBrowserDriver WebElements exception.

This jBrowserDriver issue report indicates that this feature is (yet) not implemented. You might adapt your documentation to avoid confusion.

API suggestions

Hi Jack,

I've been putting SparkleDriver to use a bit more, and these were some of the things I ran into that could potentially be useful inside the library. If you tell me which of these you like then I'm happy to make a PR.

  • call (str) on fetch! url

java.net.URI/java.net.URL/lambdaisland.uri.URI all return the url as a string when coerced to string, so this would make it possible to use these directly

  • page-text

A simple helper

(defn page-text [] 
  (text (find-by-tag "html")))
  • title
(defn title [] ;; or page-title?
  (sd/inner-html (sd/find-by-css browser "head title")))
  • current-path

like current-url but only returns the path section, e.g. "/profile"

  • wrap find-by-css / find-by-xpath to throw a more descriptive error message

If you look at the jBrowserDriver implementation the exception just gets a generic message string, "Element not found", so you don't know which element is not found.

Instead the finders could catch the NoSuchElementException, and raise a slightly more helpful exception

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.