Skip to content

Commit

Permalink
test-lib: review assembling extension paths for chromedriver
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Dec 20, 2018
1 parent aa246b7 commit 3ad8c78
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions test/src/test_lib/dirac/test_lib/chrome_driver.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
[clojure.stacktrace :as stacktrace]
[dirac.settings :refer [get-script-runner-launch-delay]]
[environ.core :refer [env]])
(:import (java.nio.file Paths)
(java.util Date)
(:import (java.util Date)
(java.util.logging Level)
(org.openqa.selenium.chrome ChromeDriver ChromeDriverService$Builder ChromeOptions)
(org.openqa.selenium.logging LoggingPreferences LogType)
(org.openqa.selenium.remote CapabilityType DesiredCapabilities)))
(org.openqa.selenium.remote CapabilityType DesiredCapabilities)
(java.io File)))

(def ^:const CHROME_VERSION_PAGE "chrome://version")

Expand Down Expand Up @@ -53,13 +53,21 @@
(defn set-current-chrome-driver! [driver]
(reset! current-chrome-driver driver))

(defn canonical-path [path]
(-> (io/as-file path)
(.getCanonicalPath)))

(defn get-dirac-extension-path [dirac-root dev?]
(if dev?
[dirac-root "resources" "unpacked"]
[dirac-root "resources" "release"]))
(->> (if dev?
[dirac-root "resources" "unpacked"]
[dirac-root "resources" "release"])
(string/join File/separator)
(canonical-path)))

(defn get-marion-extension-path [dirac-root]
[dirac-root "test" "marion" "resources" "unpacked"]) ; note: we always use dev version, it is just a helper extension, no need for advanced compliation here
(->> [dirac-root "test" "marion" "resources" "unpacked"] ; note: we always use dev version, it is just a helper extension, no need for advanced compliation here
(string/join File/separator)
(canonical-path)))

(defn retrieve-chromedriver-log []
(if-some [log-path (:chrome-driver-log-path env)]
Expand Down Expand Up @@ -144,8 +152,7 @@
chrome-options (ChromeOptions.)
extension-paths [(get-dirac-extension-path dirac-root dirac-dev)
(get-marion-extension-path dirac-root)]
absolute-extension-paths (map #(.toAbsolutePath (Paths/get "" (into-array String %))) extension-paths)
load-extensions-arg (str "load-extension=" (string/join "," absolute-extension-paths))
load-extensions-arg (str "load-extension=" (string/join "," extension-paths))
args [; we need robust startup, chrome tends to display first-run dialogs on clean systems and blocks the driver
; but there are still some bugs: https://bugs.chromium.org/p/chromium/issues/detail?id=348426
;"--disable-application-cache"
Expand Down

0 comments on commit 3ad8c78

Please sign in to comment.