Liking cljdoc? Tell your friends :D

com.blockether.spel.core

Playwright lifecycle management and browser launching.

Entry point for all Playwright operations. Creates Playwright instances and launches browsers (Chromium, Firefox, WebKit).

Usage: (with-playwright [pw (create)] (with-browser [browser (launch-chromium pw {:headless true})] (with-page [page (new-page browser)] (navigate page "https://example.com") (text-content page "h1"))))

All operations return anomaly maps on failure instead of throwing exceptions.

Playwright lifecycle management and browser launching.

Entry point for all Playwright operations. Creates Playwright instances
and launches browsers (Chromium, Firefox, WebKit).

Usage:
(with-playwright [pw (create)]
  (with-browser [browser (launch-chromium pw {:headless true})]
    (with-page [page (new-page browser)]
      (navigate page "https://example.com")
      (text-content page "h1"))))

All operations return anomaly maps on failure instead of throwing exceptions.
raw docstring

anomaly?clj

Returns true if x is an anomaly map (has a recognized anomaly category). Re-exported from com.blockether.anomaly.core for caller convenience.

Returns true if x is an anomaly map (has a recognized anomaly category).
Re-exported from com.blockether.anomaly.core for caller convenience.
sourceraw docstring

browser-connected?clj

(browser-connected? browser)

Returns true if the browser is connected.

Params: browser - Browser instance.

Returns: Boolean.

Returns true if the browser is connected.

Params:
`browser` - Browser instance.

Returns:
Boolean.
sourceraw docstring

browser-contextsclj

(browser-contexts browser)

Returns all browser contexts.

Params: browser - Browser instance.

Returns: Vector of BrowserContext instances.

Returns all browser contexts.

Params:
`browser` - Browser instance.

Returns:
Vector of BrowserContext instances.
sourceraw docstring

browser-type-nameclj

(browser-type-name bt)

Returns the name of the browser type.

Params: bt - BrowserType instance.

Returns: String. "chromium", "firefox", or "webkit".

Returns the name of the browser type.

Params:
`bt` - BrowserType instance.

Returns:
String. "chromium", "firefox", or "webkit".
sourceraw docstring

browser-versionclj

(browser-version browser)

Returns the browser version string.

Params: browser - Browser instance.

Returns: String. Browser version.

Returns the browser version string.

Params:
`browser` - Browser instance.

Returns:
String. Browser version.
sourceraw docstring

chromiumclj

(chromium pw)

Returns the Chromium BrowserType.

Params: pw - Playwright instance.

Returns: BrowserType for Chromium.

Returns the Chromium BrowserType.

Params:
`pw` - Playwright instance.

Returns:
BrowserType for Chromium.
sourceraw docstring

close!clj

(close! pw)

Closes a Playwright instance and releases all resources.

Params: pw - Playwright instance.

Returns: nil.

Closes a Playwright instance and releases all resources.

Params:
`pw` - Playwright instance.

Returns:
nil.
sourceraw docstring

close-browser!clj

(close-browser! browser)

Closes a browser and all its pages.

Params: browser - Browser instance.

Returns: nil.

Closes a browser and all its pages.

Params:
`browser` - Browser instance.

Returns:
nil.
sourceraw docstring

close-context!clj

(close-context! context)

Closes a browser context and all its pages.

Params: context - BrowserContext instance.

Returns: nil.

Closes a browser context and all its pages.

Params:
`context` - BrowserContext instance.

Returns:
nil.
sourceraw docstring

close-page!clj

(close-page! page)

Closes a page.

Params: page - Page instance.

Returns: nil.

Closes a page.

Params:
`page` - Page instance.

Returns:
nil.
sourceraw docstring

context-browserclj

(context-browser context)

Returns the browser that owns this context.

Params: context - BrowserContext instance.

Returns: Browser instance.

Returns the browser that owns this context.

Params:
`context` - BrowserContext instance.

Returns:
Browser instance.
sourceraw docstring

context-clear-cookies!clj

(context-clear-cookies! context)

Clears all cookies in the context.

Params: context - BrowserContext instance.

Clears all cookies in the context.

Params:
`context` - BrowserContext instance.
sourceraw docstring

context-clear-permissions!clj

(context-clear-permissions! context)

Clears all granted permissions.

Params: context - BrowserContext instance.

Clears all granted permissions.

Params:
`context` - BrowserContext instance.
sourceraw docstring

context-cookiesclj

(context-cookies context)

Returns all cookies in the context.

Params: context - BrowserContext instance.

Returns: Vector of cookie maps.

Returns all cookies in the context.

Params:
`context` - BrowserContext instance.

Returns:
Vector of cookie maps.
sourceraw docstring

context-grant-permissions!clj

(context-grant-permissions! context permissions)

Grants permissions to the context.

Params: context - BrowserContext instance. permissions - Collection of strings (e.g. ["geolocation"]).

Grants permissions to the context.

Params:
`context`     - BrowserContext instance.
`permissions` - Collection of strings (e.g. ["geolocation"]).
sourceraw docstring

context-pagesclj

(context-pages context)

Returns all pages in a context.

Params: context - BrowserContext instance.

Returns: Vector of Page instances.

Returns all pages in a context.

Params:
`context` - BrowserContext instance.

Returns:
Vector of Page instances.
sourceraw docstring

context-set-default-navigation-timeout!clj

(context-set-default-navigation-timeout! context timeout)

Sets the default navigation timeout.

Params: context - BrowserContext instance. timeout - Double. Timeout in milliseconds.

Sets the default navigation timeout.

Params:
`context` - BrowserContext instance.
`timeout` - Double. Timeout in milliseconds.
sourceraw docstring

context-set-default-timeout!clj

(context-set-default-timeout! context timeout)

Sets the default timeout for context operations.

Params: context - BrowserContext instance. timeout - Double. Timeout in milliseconds.

Sets the default timeout for context operations.

Params:
`context` - BrowserContext instance.
`timeout` - Double. Timeout in milliseconds.
sourceraw docstring

context-set-extra-http-headers!clj

(context-set-extra-http-headers! context headers)

Sets extra HTTP headers for all requests in the context.

Params: context - BrowserContext instance. headers - Map of string->string.

Sets extra HTTP headers for all requests in the context.

Params:
`context` - BrowserContext instance.
`headers` - Map of string->string.
sourceraw docstring

context-set-offline!clj

(context-set-offline! context offline)

Sets the context to offline or online mode.

Params: context - BrowserContext instance. offline - Boolean.

Sets the context to offline or online mode.

Params:
`context` - BrowserContext instance.
`offline` - Boolean.
sourceraw docstring

createclj

(create)

Creates a new Playwright instance.

Returns: Playwright instance or anomaly map on failure.

Examples: (def pw (create)) ;; Use pw for browser launching, then (.close pw) when done.

Creates a new Playwright instance.

Returns:
Playwright instance or anomaly map on failure.

Examples:
(def pw (create))
;; Use pw for browser launching, then (.close pw) when done.
sourceraw docstring

firefoxclj

(firefox pw)

Returns the Firefox BrowserType.

Params: pw - Playwright instance.

Returns: BrowserType for Firefox.

Returns the Firefox BrowserType.

Params:
`pw` - Playwright instance.

Returns:
BrowserType for Firefox.
sourceraw docstring

launchclj

(launch browser-type)
(launch browser-type launch-opts)

Launches a browser of the given type.

Params: browser-type - BrowserType instance. opts - Map, optional. Launch options (see options/->launch-options).

Returns: Browser instance or anomaly map on failure.

Launches a browser of the given type.

Params:
`browser-type` - BrowserType instance.
`opts`         - Map, optional. Launch options (see options/->launch-options).

Returns:
Browser instance or anomaly map on failure.
sourceraw docstring

launch-chromiumclj

(launch-chromium pw)
(launch-chromium pw opts)

Launches Chromium browser.

Params: pw - Playwright instance. opts - Map, optional. Launch options.

Returns: Browser instance or anomaly map on failure.

Examples: (launch-chromium pw) (launch-chromium pw {:headless false :slow-mo 100})

Launches Chromium browser.

Params:
`pw`   - Playwright instance.
`opts` - Map, optional. Launch options.

Returns:
Browser instance or anomaly map on failure.

Examples:
(launch-chromium pw)
(launch-chromium pw {:headless false :slow-mo 100})
sourceraw docstring

launch-firefoxclj

(launch-firefox pw)
(launch-firefox pw opts)

Launches Firefox browser.

Params: pw - Playwright instance. opts - Map, optional. Launch options.

Returns: Browser instance or anomaly map on failure.

Launches Firefox browser.

Params:
`pw`   - Playwright instance.
`opts` - Map, optional. Launch options.

Returns:
Browser instance or anomaly map on failure.
sourceraw docstring

launch-persistent-contextclj

(launch-persistent-context browser-type user-data-dir)
(launch-persistent-context browser-type user-data-dir opts)

Launches a browser with a persistent user data directory (Chrome profile).

Unlike launch + new-context, this uses a real Chrome profile directory that persists cookies, localStorage, extensions, saved passwords, bookmarks, and other browser data across sessions.

Returns a BrowserContext directly (not a Browser). Closing the context automatically closes the browser.

Params: browser-type - BrowserType instance (from chromium, firefox, webkit). user-data-dir - String. Path to Chrome user data directory. Pass empty string for a temporary profile. opts - Map, optional. Combined launch + context options (see options/->launch-persistent-context-options).

Returns: BrowserContext instance or anomaly map on failure.

Examples: (launch-persistent-context (chromium pw) "/tmp/my-profile") (launch-persistent-context (chromium pw) "/tmp/my-profile" {:headless false :user-agent "MyAgent/1.0"})

Launches a browser with a persistent user data directory (Chrome profile).

Unlike `launch` + `new-context`, this uses a real Chrome profile directory
that persists cookies, localStorage, extensions, saved passwords, bookmarks,
and other browser data across sessions.

Returns a BrowserContext directly (not a Browser). Closing the context
automatically closes the browser.

Params:
`browser-type` - BrowserType instance (from `chromium`, `firefox`, `webkit`).
`user-data-dir` - String. Path to Chrome user data directory.
                  Pass empty string for a temporary profile.
`opts`          - Map, optional. Combined launch + context options
                  (see options/->launch-persistent-context-options).

Returns:
BrowserContext instance or anomaly map on failure.

Examples:
(launch-persistent-context (chromium pw) "/tmp/my-profile")
(launch-persistent-context (chromium pw) "/tmp/my-profile"
  {:headless false :user-agent "MyAgent/1.0"})
sourceraw docstring

launch-webkitclj

(launch-webkit pw)
(launch-webkit pw opts)

Launches WebKit browser.

Params: pw - Playwright instance. opts - Map, optional. Launch options.

Returns: Browser instance or anomaly map on failure.

Launches WebKit browser.

Params:
`pw`   - Playwright instance.
`opts` - Map, optional. Launch options.

Returns:
Browser instance or anomaly map on failure.
sourceraw docstring

new-contextclj

(new-context browser)
(new-context browser context-opts)

Creates a new browser context with optional configuration.

Params: browser - Browser instance. opts - Map, optional. Context options (see options/->new-context-options).

Returns: BrowserContext instance or anomaly map on failure.

Creates a new browser context with optional configuration.

Params:
`browser` - Browser instance.
`opts`    - Map, optional. Context options (see options/->new-context-options).

Returns:
BrowserContext instance or anomaly map on failure.
sourceraw docstring

new-pageclj

(new-page browser)
(new-page browser context-opts)

Creates a new page in a browser (creates implicit context).

Params: browser - Browser instance.

Returns: Page instance or anomaly map on failure.

Creates a new page in a browser (creates implicit context).

Params:
`browser` - Browser instance.

Returns:
Page instance or anomaly map on failure.
sourceraw docstring

new-page-from-contextclj

(new-page-from-context context)

Creates a new page in the given context.

Params: context - BrowserContext instance.

Returns: Page instance or anomaly map on failure.

Creates a new page in the given context.

Params:
`context` - BrowserContext instance.

Returns:
Page instance or anomaly map on failure.
sourceraw docstring

safecljmacro

(safe & body)

Wraps body in try/catch, returning anomaly map on Playwright errors.

Returns the result of body on success, or an anomaly map on failure. Catches TimeoutError, TargetClosedError, PlaywrightException, and any other Exception. All anomaly maps include the original exception, its class name, and full stack trace.

Wraps body in try/catch, returning anomaly map on Playwright errors.
 
Returns the result of body on success, or an anomaly map on failure.
Catches TimeoutError, TargetClosedError, PlaywrightException, and
any other Exception. All anomaly maps include the original exception,
its class name, and full stack trace.
sourceraw docstring

webkitclj

(webkit pw)

Returns the WebKit BrowserType.

Params: pw - Playwright instance.

Returns: BrowserType for WebKit.

Returns the WebKit BrowserType.

Params:
`pw` - Playwright instance.

Returns:
BrowserType for WebKit.
sourceraw docstring

with-browsercljmacro

(with-browser [sym expr] & body)

Binds a browser instance and ensures cleanup.

Usage: (with-browser [browser (launch-chromium pw)] (new-page browser))

Binds a browser instance and ensures cleanup.

Usage:
(with-browser [browser (launch-chromium pw)]
  (new-page browser))
sourceraw docstring

with-contextcljmacro

(with-context [sym expr] & body)

Binds a browser context and ensures cleanup.

Usage: (with-context [ctx (new-context browser)] (new-page-from-context ctx))

Binds a browser context and ensures cleanup.

Usage:
(with-context [ctx (new-context browser)]
  (new-page-from-context ctx))
sourceraw docstring

with-pagecljmacro

(with-page [sym expr] & body)

Binds a page instance and ensures cleanup.

Usage: (with-page [page (new-page browser)] (navigate page "https://example.com"))

Binds a page instance and ensures cleanup.

Usage:
(with-page [page (new-page browser)]
  (navigate page "https://example.com"))
sourceraw docstring

with-playwrightcljmacro

(with-playwright binding-vec & body)

Binds a Playwright instance and ensures cleanup.

Usage: (with-playwright [pw] ;; creates Playwright internally (launch-chromium pw)) (with-playwright [pw (create)] ;; uses provided expression (launch-chromium pw))

Binds a Playwright instance and ensures cleanup.

Usage:
(with-playwright [pw]              ;; creates Playwright internally
  (launch-chromium pw))
(with-playwright [pw (create)]     ;; uses provided expression
  (launch-chromium pw))
sourceraw docstring

wrap-errorclj

(wrap-error e)

Wraps Playwright exceptions into anomaly maps.

Includes the exception message, class, stack trace, and the original exception object for programmatic access.

Params: e - Exception from Playwright.

Returns: Anomaly map with appropriate category.

Wraps Playwright exceptions into anomaly maps.

Includes the exception message, class, stack trace, and the original
exception object for programmatic access.
 
Params:
`e` - Exception from Playwright.
 
Returns:
Anomaly map with appropriate category.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close