diff --git a/README.md b/README.md index 03f67e1d..e9500aa6 100644 --- a/README.md +++ b/README.md @@ -1373,15 +1373,13 @@ If for some reason you want to use a single instance, you can use fixtures like (def ^:dynamic *driver*) (defn fixture-browser [f] - (let [driver (chrome-headless)] + (with-chrome-headless {:args ["--no-sandbox"]} driver + (disconnect-driver driver) (binding [*driver* driver] - (disconnect-driver driver) (f)) - (connect-driver driver) - (quit driver))) + (connect-driver driver))) -;; if you want reset some changes (delete cookie, refresh page and etc), or Vice versa, -;; make pre-settings before test you can use fixture like this: +;; creating a session every time that automatically erases resources (defn fixture-clear-browser [f] (connect-driver *driver*) (go *driver* "http://google.com") @@ -1393,7 +1391,7 @@ If for some reason you want to use a single instance, you can use fixtures like :once fixture-browser) -;;this is run `every` time before each test +;; this is run `every` time before each test (use-fixtures :each fixture-clear-browser) @@ -1401,6 +1399,26 @@ If for some reason you want to use a single instance, you can use fixtures like ...some tests ``` +For faster testing you can use this example: + +```clojure +..... + +(defn fixture-browser [f] + (with-chrome-headless {:args ["--no-sandbox"]} driver + (binding [*driver* driver] + (f)))) + +;; note that resources, such as cookies, are deleted manually, +;; so this does not guarantee that the tests are clean +(defn fixture-clear-browser [f] + (delete-cookies *driver*) + (go *driver* "http://google.com") + (f)) + +...... +``` + ### Multi-Driver Fixtures In the example above, we examined a case when you run tests against a single