-
Notifications
You must be signed in to change notification settings - Fork 96
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
disconnect-driver resets headless mode #193
Comments
Hi, @metametadata For your goals, you can use fixtures, like this:
|
Thanks. But if I understand everything correctly, I would prefer to not "clear" by hand like this. Connecting/disconnecting looks more bulletproof (it for sure clears all state, e.g. including local storage) and needs less code. In either case, the API behaves unexpectedly (IMO of course), the MR doesn't address this root problem. This is my current code: ; Driver type used for all the tests
(def -driver-type :chrome)
(def -headless? true)
; Global driver instance
(def d nil)
(defn with-driver
":each fixture which will create a new driver session for each test case.
Driver process will be spawned if it's not already running."
[f]
; Start driver process if needed.
; Note that there's no need to destroy it explicitly because it will be killed when the parent process quits.
(when (nil? d)
(println (str "Start " (pr-str -driver-type) " (headless = " (pr-str -headless?) ") driver process..."))
(alter-var-root #'d (fn [_]
(-> (e/create-driver -driver-type)
(e/run-driver {:headless -headless?})))))
(e.client/with-pool {}
; HACK: needed because e/disconnect-driver erases all capabilities from driver.
; https://github.com/igrishaev/etaoin/issues/193.
(when -headless?
(swap! d e.driver/set-headless))
; Bump logging level to get fuller logs on test failures.
; It seems to be WARNING by default in Chrome and PhantomJS.
(swap! d e.driver/set-browser-log-level :debug)
(alter-var-root #'d e/connect-driver)
(f)
(alter-var-root #'d e/disconnect-driver)))
...
(use-fixtures :each with-driver)
(deftest ...) |
@metametadata We’ll fix it, thanks for feedback! |
Lib version: 0.3.2.
I've bumped into this issue because I want to start driver process once for the whole test suite and let every test connect/disconnect to it (instead of starting and quiting browser process in every test).
Steps:
Expected: nothing happens.
Actual: browser window pops up.
Code example:
It is caused by
disconnect-driver
which erases:capabilities
from driver atom including:chromeOptions {:args ["--headless"]}
. Thus secondconnect-driver
is made without the needed CLI arg.Possible solution is to not modify
:capabilities
inrun-driver
and letconnect-driver
generate:args
depending on:headless
flag from driver map.The text was updated successfully, but these errors were encountered: