Liking cljdoc? Tell your friends :D

cuic.chrome


Chromeclj

source

chrome?clj

(chrome? val)

Checks whether the given value is valid Chrome browser instance or not

Checks whether the given value is valid Chrome browser instance or not
sourceraw docstring

defaultsclj

Default launch options for non-headless Chrome instance

Default launch options for non-headless Chrome instance
sourceraw docstring

headless-defaultsclj

Default launch options for headless Chrome instance

Default launch options for headless Chrome instance
sourceraw docstring

launchclj

(launch)
(launch options)
(launch options chrome-path)
(launch options chrome-path timeout)

Launches a new local Chrome process with the given options and returns instance to the launched Chrome that can be used as a browser in cuic.core functions.

The provided options have defaults using either cuic.chrome/defaults or cuic.chrome/headless-defaults depending on whether the process was launched in headless mode or not. For full list of options, see https://peter.sh/experiments/chromium-command-line-switches. Option key will be the switch name without -- prefix, If option is boolean type flag its value must be passed as a boolean, e.g. --mute-audio becomes {:mute-audio true}. Other arguments should be passed as strings. The only exceptions are:

  • :window-size {:width <pos-int> :height <pos-int>}
  • :remote-debugging-port <pos-int>
  • :user-data-dir <java.nio.file.Path>

The function tries to auto-detect the path of the used Chrome binary, using known default locations. If you're using non-standard installation location, you can pass the custom path as a java.nio.file.Path parameter. The used installation must have at least Chromium version 64.0.3264.0 (r515411).

After the process is launched, the function waits until Chome devtools become available, using -Dcuic.chrome.timeout=<ms> timeout by default. This can be overrided with the last parameter. Devtools protocol port will be selected randomly unless explicitly specified in options.

By default each launched process will get its own temporary data directory, meaning that the launched instances do not share any state at all. When the instance gets closed, its temporary data directory will be deleted as well. If you want to share state between separate instances/processes, you should pass the data directory as :user-data-dir option. In this case, the directory won't be removed even if the instance gets closed: the invoker of this function is responsible for managing the directory's creation, access and removal.

Chrome instances implement java.lang.AutoCloseable so they can be used with Clojure's with-open macro.

;; Launch headless instance using provided defaults and
;; auto-detected binary
(def chrome (launch))

;; Launch non-headless instance using pre-defined data directory
(def data-dir
  (doto (io/file "chrome-data")
    (.mkdirs)))
(def chrome
  (launch {:headless      false
           :user-data-dir (.toPath data-dir)}))

;; Launch chrome from non-standard location
(def chrome (launch {} (.toPath (io/file "/tmp/chrome/google-chrome-stable"))))

;; Launch headless instance and use it as a default browser
;; and close the instance after usage
(with-open [chrome (launch)]
  (binding [c/*browser* chrome]
    ...do something...))
Launches a new local Chrome process with the given options and returns
instance to the launched Chrome that can be used as a browser in
[[cuic.core]] functions.

The provided options have defaults using either [[cuic.chrome/defaults]]
or  [[cuic.chrome/headless-defaults]] depending on whether the process
was launched in headless mode or not. For full list of options, see
https://peter.sh/experiments/chromium-command-line-switches. Option key
will be the switch name without `--` prefix, If option is boolean type
flag its value must be passed as a boolean, e.g. `--mute-audio` becomes
`{:mute-audio true}`. Other arguments should be passed as strings. The
only exceptions are:
   * `:window-size {:width <pos-int> :height <pos-int>}`
   * `:remote-debugging-port <pos-int>`
   * `:user-data-dir <java.nio.file.Path>`

The function tries to auto-detect the path of the used Chrome binary,
using known default locations. If you're using non-standard installation
location, you can pass the custom path as a `java.nio.file.Path` parameter.
The used installation must have **at least** Chromium version 64.0.3264.0
(r515411).

After the process is launched, the function waits until Chome devtools
become available, using `-Dcuic.chrome.timeout=<ms>` timeout by default.
This can be overrided with the last parameter. Devtools protocol port
will be selected randomly unless explicitly specified in options.

By default each launched process will get its own temporary data directory,
meaning that the launched instances do not share any state at all. When
the instance gets closed, its temporary data directory will be deleted
as well. If you want to share state between separate instances/processes,
you should pass the data directory as `:user-data-dir` option. In this case,
the directory won't be removed even if the instance gets closed: the invoker
of this function is responsible for managing the directory's creation, access
and removal.

Chrome instances implement `java.lang.AutoCloseable` so they can be used
with Clojure's `with-open` macro.

```clojure
;; Launch headless instance using provided defaults and
;; auto-detected binary
(def chrome (launch))

;; Launch non-headless instance using pre-defined data directory
(def data-dir
  (doto (io/file "chrome-data")
    (.mkdirs)))
(def chrome
  (launch {:headless      false
           :user-data-dir (.toPath data-dir)}))

;; Launch chrome from non-standard location
(def chrome (launch {} (.toPath (io/file "/tmp/chrome/google-chrome-stable"))))

;; Launch headless instance and use it as a default browser
;; and close the instance after usage
(with-open [chrome (launch)]
  (binding [c/*browser* chrome]
    ...do something...))
```
sourceraw docstring

set-cache-disabledclj

(set-cache-disabled chrome disabled?)

Toggles ignoring cache for each request. If true, cache will not be used.

Toggles ignoring cache for each request. If `true`, cache
will not be used.
sourceraw docstring

set-extra-headersclj

(set-extra-headers chrome http-headers)

Specifies whether to always send extra HTTP headers with the requests from this page. Can be used e.g. for impersonation in your tests.

Specifies whether to always send extra HTTP headers with the requests from
this page. Can be used e.g. for impersonation in your tests.
sourceraw docstring

terminateclj

(terminate chrome)

Terminates the given Chrome instance and cleans up its temporary resources and directories.

Terminates the given Chrome instance and cleans up its temporary
resources and directories.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close