Weird exception when trying to load a namespace that is using clj-webdriver taxi

136 views
Skip to first unread message

Bkumar

unread,
Nov 19, 2013, 5:51:13 AM11/19/13
to clj-we...@googlegroups.com
Hi,

I am seeing a weird compilation exception on lein repl. Not sure what's going wrong. It would be great if you could point me in the right direction.


; in Repl when I say
(use 'clj-exception.core)  ; I see below exception
;
;CompilerException java.lang.IllegalArgumentException: 
;        No implementation of method: :page-source of protocol: #'clj-webdriver.core/IDriver found for class: clojure.lang.Var$Unbound, compiling:(core.clj:84:30)
;

;However, below line doesn't throw any error
(use 'clj-webdriver.taxi)


;My project.clj
(defproject clj-exception "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.5.1"]
                 [clj-webdriver "0.6.0"]
                 [org.clojure/data.xml "0.0.7"]
                 [enlive "1.1.4"]]
  ; when VM is used, it's better to have headless mode option. Otherwise everything may go wrong!
  :jvm-opts ["-Djava.awt.headless=true"])

;core.clj
(ns clj-exception.core
  (:use [clojure.java.io])
  (:require [net.cgrand.enlive-html :as html]
            [clojure.data.xml :as xml]
            [clj-webdriver.taxi :as taxi])
  (:import (java.io StringReader)))

(def ^:private browser-count (atom 0))

(defn browser-up
  "Start up a browser if it's not already started."
  []
  (when (= 1 (swap! browser-count inc))
    (taxi/set-driver! {:browser :firefox})
    (taxi/implicit-wait 60000)))

(defn browser-down
  "If this is the last request, shut the browser down."
  [& {:keys [force] :or {force false}}]
  (when (zero? (swap! browser-count (if force (constantly 0) dec)))
    (taxi/quit)))

(def base-url "www.github.com/")

(defn go
  ([] (go base-url ""))
  ([path] (go base-url path))
  ([base-url path]
  (taxi/get-url (str base-url path))))

(defn page-html []
  (html/html-resource (java.io.StringReader. (taxi/page-source))))

(go)
(go "blog")
(println (page-html))

Thanks for your time.

-Bharat

Mayank Jain

unread,
Nov 19, 2013, 12:05:40 PM11/19/13
to clj-we...@googlegroups.com
You need to start the browser before doing any taxi api.
call browser-up function before calling go.
And I recommend not to copy paste this code and just try.
check the docs on how to run it.
Otherwise you won't understand whats happening.


--
You received this message because you are subscribed to the Google Groups "clj-webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-webdrive...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Mayank.

Bharat Kumar

unread,
Nov 19, 2013, 6:35:46 PM11/19/13
to clj-we...@googlegroups.com
Sorry, a newbie blunder. Thanks for the help.

If anyone is interested, url should be prefixed with protocol (ex: http/https) otherwise it does't work. 


--
You received this message because you are subscribed to a topic in the Google Groups "clj-webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clj-webdriver/rX_bGolPzyw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clj-webdrive...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages