Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add driver installation check #255

Merged
merged 2 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/etaoin/proc.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@
(into-array String)))

(defn run [args]
(let [pb (java.lang.ProcessBuilder. (java-params args))]
(let [binary (first args)
readme-link "https://github.com/igrishaev/etaoin#installing-the-browser-drivers"
pb (java.lang.ProcessBuilder. (java-params args))]
(.redirectOutput pb (java.io.File/createTempFile "driver.out" ".log"))
(.redirectError pb (java.io.File/createTempFile "driver.err" ".log"))
(.start pb)))
(try
(.start pb)
(catch java.io.IOException e
(throw (ex-info
(format "Cannot find a binary file `%s` for the driver.
Please ensure you have the driver installed and specify the path to it.
For driver installation, check out the official readme file from Etaoin: %s" binary readme-link)
{:args args} e))))))

;; todo store those streams

Expand Down
7 changes: 7 additions & 0 deletions test/etaoin/api_test2.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@
:args-driver ["--marionette-port" 2821]}))
(is (= @args
["geckodriver" "--port" 1234 "--marionette-port" 2821])))))))


(deftest test-fail-run-driver
(is (thrown-with-msg?
clojure.lang.ExceptionInfo
#"wrong-driver-path"
(chrome {:path-driver "wrong-driver-path"}))))