From 3ad8c78cb893a089c082811968d0d7c2be8b9ba6 Mon Sep 17 00:00:00 2001 From: Antonin Hildebrand Date: Thu, 20 Dec 2018 16:04:46 +0100 Subject: [PATCH] test-lib: review assembling extension paths for chromedriver --- .../test_lib/dirac/test_lib/chrome_driver.clj | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/test/src/test_lib/dirac/test_lib/chrome_driver.clj b/test/src/test_lib/dirac/test_lib/chrome_driver.clj index cd76a792f6..31281e9d5c 100644 --- a/test/src/test_lib/dirac/test_lib/chrome_driver.clj +++ b/test/src/test_lib/dirac/test_lib/chrome_driver.clj @@ -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") @@ -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)] @@ -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"