Can't start chrome driver with `:profile` option
qazwsxpawel opened this issue · comments
Version
etaoin/etaoin {:mvn/version "1.0.38"}
Platform
Operating System: MacOS 12.4
Clojure version: 1.11.1
JDK vendor and version: openjdk version "11.0.9.1" 2020-11-04 LTS
Browser vendor: Chrome Version 106.0.5249.103 (Official Build) (arm64)
WebDriver version: ChromeDriver 106.0.5249.61
Symptom
Trying to start session with :profile
opt
(ns extension
(:require [etaoin.api :as e]
[etaoin.keys :as k]))
(def driver (e/chrome {:profile "/Users/xxx/Library/Application Support/Google/Chrome/Profile 6"}))
The browser starts with the right profile but I'm seeing
Execution error (ExceptionInfo) at slingshot.support/stack-trace (support.clj:201).
throw+: {:response {:sessionId "38335d5abd3bf95011514534aa99caf2", :status 13, :value {:message "unknown error: Chrome failed to start: exited normally.\n (unknown error: DevToolsActivePort file doesn't exist)\n (The process started from chrome location /Applications/Google Chrome.app/Contents/MacOS/Google Chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)\n (Driver info: chromedriver=106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}),platform=Mac OS X 12.4.0 arm64)"}}, :path "session", :payload {:desiredCapabilities {:loggingPrefs {:browser "ALL"}, :chromeOptions {:args ("--user-data-dir=/Users/xxx/Library/Application Support/Google/Chrome" "--profile-directory=Profile 6")}}}, :method :post, :type :etaoin/http-error, :port 63633, :host "127.0.0.1", :status 200, :webdriver-url nil, :driver {:type :chrome, :host "127.0.0.1", :port 63633, :url "http://127.0.0.1:63633", :locator "xpath", :capabilities {:loggingPrefs {:browser "ALL"}, :chromeOptions {:args ("--user-data-dir=/Users/xxx/Library/Application Support/Google/Chrome" "--profile-directory=Profile 6")}}, :args ("chromedriver" "--port=63633"), :process {:proc #object[java.lang.ProcessImpl 0x4ffb3ba0 "Process[pid=35304, exitValue=\"not exited\"]"], :exit nil, :in #object[java.lang.ProcessImpl$ProcessPipeOutputStream 0x239243e6 "java.lang.ProcessImpl$ProcessPipeOutputStream@239243e6"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x63e45cde "java.lang.ProcessBuilder$NullInputStream@63e45cde"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x63e45cde "java.lang.ProcessBuilder$NullInputStream@63e45cde"], :prev nil, :cmd ["chromedriver" "--port=63633"]}}}
Multiple methods in multimethod 'simple-dispatch' match dispatch value: class babashka.process.Process -> interface clojure.lang.IPersistentMap and interface clojure.lang.IDeref, and neither is preferred
java.lang.IllegalArgumentException: Multiple methods in multimethod 'simple-dispatch' match dispatch value: class babashka.process.Process -> interface clojure.lang.IPersistentMap and interface clojure.lang.IDeref, and neither is preferred
The browser is still around but can't interact with it
There is mention of babashka but this is used from regular Clojure session
Happy to provide more info and/or minimal repro repo if need be
Thanks!
Thanks for raising an issue @qazwsxpawel!
These WebDrivers can be a bit fiddly.
I retried your scenario and got the same error you did:
unknown error: DevToolsActivePort file doesn't exist
I did a little Google for this and found some folks using Chrome's --disable-dev-shm-usage
arg to get around this symptom. I don't know the details/reasons/nuances, but it seems to work:
(require '[etaoin.api :as e])
(def driver (e/chrome {:profile "/Users/lee/Library/Application Support/Google/Chrome/Profile 1"
:args ["--disable-dev-shm-usage"]}))
(e/go driver "https://clojure.org")
(e/get-title driver)
;; => "Clojure"
Lemme know if this works for you too.
Thanks @lread!
Will try it out :)
I've actually had some success with pointing the driver to an empty directory and allowing it to create the profile data there, then configuring the browser after it's been created and re-using for subsequent runs (seems to work fine :))
(e/chrome {:profile "/path/to/some/empty/dir")})
Huh @qazwsxpawel! Go figure. So it might be a privs thing?
I'm gonna assume we are good here and close this one.
Please do re-open if you want to explore further.