Liking cljdoc? Tell your friends :D

com.blockether.spel.page

Page operations - navigation, content, evaluation, screenshots.

The Page class is the central API surface of Playwright. Wraps all Page methods with idiomatic Clojure functions.

Page operations - navigation, content, evaluation, screenshots.

The Page class is the central API surface of Playwright. Wraps all
Page methods with idiomatic Clojure functions.
raw docstring

add-script-tagclj

(add-script-tag page opts)

Adds a script tag to the page.

Params: page - Page instance. opts - Map with :url, :path, or :content.

Returns: ElementHandle or anomaly map.

Adds a script tag to the page.

Params:
`page` - Page instance.
`opts` - Map with :url, :path, or :content.

Returns:
ElementHandle or anomaly map.
sourceraw docstring

add-style-tagclj

(add-style-tag page opts)

Adds a style tag to the page.

Params: page - Page instance. opts - Map with :url, :path, or :content.

Returns: ElementHandle or anomaly map.

Adds a style tag to the page.

Params:
`page` - Page instance.
`opts` - Map with :url, :path, or :content.

Returns:
ElementHandle or anomaly map.
sourceraw docstring

bring-to-frontclj

(bring-to-front page)

Brings page to front (activates tab).

Params: page - Page instance.

Brings page to front (activates tab).

Params:
`page` - Page instance.
sourceraw docstring

contentclj

(content page)

Returns the full HTML content of the page.

Params: page - Page instance.

Returns: String. HTML content.

Returns the full HTML content of the page.

Params:
`page` - Page instance.

Returns:
String. HTML content.
sourceraw docstring

emulate-media!clj

(emulate-media! page media-opts)

Emulates media type and features.

Params: page - Page instance. opts - Map. Emulate media options.

Emulates media type and features.

Params:
`page` - Page instance.
`opts` - Map. Emulate media options.
sourceraw docstring

evaluateclj

(evaluate page expression)
(evaluate page expression arg)

Evaluates JavaScript expression in the page context.

Params: page - Page instance. expression - String. JavaScript expression. arg - Optional. Argument to pass to the expression.

Returns: Result of JavaScript evaluation or anomaly map on failure.

Evaluates JavaScript expression in the page context.

Params:
`page`       - Page instance.
`expression` - String. JavaScript expression.
`arg`        - Optional. Argument to pass to the expression.

Returns:
Result of JavaScript evaluation or anomaly map on failure.
sourceraw docstring

evaluate-handleclj

(evaluate-handle page expression)
(evaluate-handle page expression arg)

Like evaluate, but returns a JSHandle.

Params: page - Page instance. expression - String. JavaScript expression. arg - Optional. Argument.

Returns: JSHandle or anomaly map.

Like evaluate, but returns a JSHandle.

Params:
`page`       - Page instance.
`expression` - String. JavaScript expression.
`arg`        - Optional. Argument.

Returns:
JSHandle or anomaly map.
sourceraw docstring

expose-binding!clj

(expose-binding! page name f)

Exposes a Clojure function as a binding.

Params: page - Page instance. name - String. Binding name. fn - Function. The binding function.

Exposes a Clojure function as a binding.

Params:
`page` - Page instance.
`name` - String. Binding name.
`fn`   - Function. The binding function.
sourceraw docstring

expose-function!clj

(expose-function! page name f)

Exposes a Clojure function to JavaScript.

Params: page - Page instance. name - String. Function name in JavaScript. fn - Function. The Clojure function to expose.

Exposes a Clojure function to JavaScript.

Params:
`page` - Page instance.
`name` - String. Function name in JavaScript.
`fn`   - Function. The Clojure function to expose.
sourceraw docstring

frame-by-nameclj

(frame-by-name page name)

Returns a frame by its name attribute.

Params: page - Page instance. name - String. Frame name.

Returns: Frame or nil.

Returns a frame by its name attribute.

Params:
`page` - Page instance.
`name` - String. Frame name.

Returns:
Frame or nil.
sourceraw docstring

frame-by-urlclj

(frame-by-url page pattern)

Returns a frame by matching URL pattern.

Params: page - Page instance. pattern - String glob, regex Pattern, or predicate.

Returns: Frame or nil.

Returns a frame by matching URL pattern.

Params:
`page`    - Page instance.
`pattern` - String glob, regex Pattern, or predicate.

Returns:
Frame or nil.
sourceraw docstring

framesclj

(frames page)

Returns all frames in the page.

Params: page - Page instance.

Returns: Vector of Frame instances.

Returns all frames in the page.

Params:
`page` - Page instance.

Returns:
Vector of Frame instances.
sourceraw docstring

get-by-alt-textclj

(get-by-alt-text page text)

Locates elements by alt text.

Params: page - Page instance. text - String or Pattern.

Returns: Locator instance.

Locates elements by alt text.

Params:
`page` - Page instance.
`text` - String or Pattern.

Returns:
Locator instance.
sourceraw docstring

get-by-labelclj

(get-by-label page text)

Locates elements by their label text.

Params: page - Page instance. text - String or Pattern.

Returns: Locator instance.

Locates elements by their label text.

Params:
`page` - Page instance.
`text` - String or Pattern.

Returns:
Locator instance.
sourceraw docstring

get-by-placeholderclj

(get-by-placeholder page text)

Locates elements by placeholder text.

Params: page - Page instance. text - String or Pattern.

Returns: Locator instance.

Locates elements by placeholder text.

Params:
`page` - Page instance.
`text` - String or Pattern.

Returns:
Locator instance.
sourceraw docstring

get-by-roleclj

(get-by-role page role)
(get-by-role page role opts)

Locates elements by their ARIA role.

Params: page - Page instance. role - AriaRole enum value. opts - Map, optional. GetByRoleOptions: :name - String or Pattern. Accessible name to match. :exact - Boolean. Exact match for name. :checked - Boolean. Match checked state. :disabled - Boolean. Match disabled state. :expanded - Boolean. Match expanded state. :include-hidden - Boolean. Include hidden elements. :level - Integer. Heading level. :pressed - Boolean. Match pressed state. :selected - Boolean. Match selected state.

Returns: Locator instance.

Locates elements by their ARIA role.

Params:
`page` - Page instance.
`role` - AriaRole enum value.
`opts` - Map, optional. GetByRoleOptions:
         :name           - String or Pattern. Accessible name to match.
         :exact          - Boolean. Exact match for name.
         :checked        - Boolean. Match checked state.
         :disabled       - Boolean. Match disabled state.
         :expanded       - Boolean. Match expanded state.
         :include-hidden - Boolean. Include hidden elements.
         :level          - Integer. Heading level.
         :pressed        - Boolean. Match pressed state.
         :selected       - Boolean. Match selected state.

Returns:
Locator instance.
sourceraw docstring

get-by-test-idclj

(get-by-test-id page test-id)

Locates elements by test ID attribute.

Params: page - Page instance. test-id - String or Pattern.

Returns: Locator instance.

Locates elements by test ID attribute.

Params:
`page`    - Page instance.
`test-id` - String or Pattern.

Returns:
Locator instance.
sourceraw docstring

get-by-textclj

(get-by-text page text)

Locates elements by their text content.

Params: page - Page instance. text - String or Pattern.

Returns: Locator instance.

Locates elements by their text content.

Params:
`page` - Page instance.
`text` - String or Pattern.

Returns:
Locator instance.
sourceraw docstring

get-by-titleclj

(get-by-title page text)

Locates elements by title attribute.

Params: page - Page instance. text - String or Pattern.

Returns: Locator instance.

Locates elements by title attribute.

Params:
`page` - Page instance.
`text` - String or Pattern.

Returns:
Locator instance.
sourceraw docstring

go-backclj

(go-back page)
(go-back page nav-opts)

Navigates back in history.

Params: page - Page instance. opts - Map, optional. Navigation options.

Returns: Response or nil, or anomaly map on failure.

Navigates back in history.

Params:
`page` - Page instance.
`opts` - Map, optional. Navigation options.

Returns:
Response or nil, or anomaly map on failure.
sourceraw docstring

go-forwardclj

(go-forward page)
(go-forward page nav-opts)

Navigates forward in history.

Params: page - Page instance. opts - Map, optional. Navigation options.

Returns: Response or nil, or anomaly map on failure.

Navigates forward in history.

Params:
`page` - Page instance.
`opts` - Map, optional. Navigation options.

Returns:
Response or nil, or anomaly map on failure.
sourceraw docstring

is-closed?clj

(is-closed? page)

Returns true if the page has been closed.

Params: page - Page instance.

Returns: Boolean.

Returns true if the page has been closed.

Params:
`page` - Page instance.

Returns:
Boolean.
sourceraw docstring

locatorclj

(locator page selector)

Creates a Locator for finding elements on the page.

Params: page - Page instance. selector - String. CSS or text selector.

Returns: Locator instance.

Creates a Locator for finding elements on the page.

Params:
`page`     - Page instance.
`selector` - String. CSS or text selector.

Returns:
Locator instance.
sourceraw docstring

main-frameclj

(main-frame page)

Returns the main frame of the page.

Params: page - Page instance.

Returns: Frame instance.

Returns the main frame of the page.

Params:
`page` - Page instance.

Returns:
Frame instance.
sourceraw docstring

(navigate page url)
(navigate page url nav-opts)

Navigates the page to a URL.

Params: page - Page instance. url - String. URL to navigate to. opts - Map, optional. Navigation options.

Returns: Response or nil, or anomaly map on failure.

Navigates the page to a URL.

Params:
`page` - Page instance.
`url`  - String. URL to navigate to.
`opts` - Map, optional. Navigation options.

Returns:
Response or nil, or anomaly map on failure.
sourceraw docstring

on-closeclj

(on-close page handler)

Registers a handler for page close.

Params: page - Page instance. handler - Function called with the page when it closes.

Registers a handler for page close.

Params:
`page`    - Page instance.
`handler` - Function called with the page when it closes.
sourceraw docstring

on-consoleclj

(on-console page handler)

Registers a handler for console messages.

Params: page - Page instance. handler - Function that receives a ConsoleMessage.

Registers a handler for console messages.

Params:
`page`    - Page instance.
`handler` - Function that receives a ConsoleMessage.
sourceraw docstring

on-dialogclj

(on-dialog page handler)

Registers a handler for dialogs.

Params: page - Page instance. handler - Function that receives a Dialog.

Registers a handler for dialogs.

Params:
`page`    - Page instance.
`handler` - Function that receives a Dialog.
sourceraw docstring

on-downloadclj

(on-download page handler)

Registers a handler for downloads.

Params: page - Page instance. handler - Function that receives a Download.

Registers a handler for downloads.

Params:
`page`    - Page instance.
`handler` - Function that receives a Download.
sourceraw docstring

on-page-errorclj

(on-page-error page handler)

Registers a handler for page errors.

Params: page - Page instance. handler - Function that receives an error string.

Registers a handler for page errors.

Params:
`page`    - Page instance.
`handler` - Function that receives an error string.
sourceraw docstring

on-popupclj

(on-popup page handler)

Registers a handler for popup pages.

Params: page - Page instance. handler - Function that receives a Page.

Registers a handler for popup pages.

Params:
`page`    - Page instance.
`handler` - Function that receives a Page.
sourceraw docstring

on-requestclj

(on-request page handler)

Registers a handler for requests.

Params: page - Page instance. handler - Function that receives a Request.

Registers a handler for requests.

Params:
`page`    - Page instance.
`handler` - Function that receives a Request.
sourceraw docstring

on-responseclj

(on-response page handler)

Registers a handler for responses.

Params: page - Page instance. handler - Function that receives a Response.

Registers a handler for responses.

Params:
`page`    - Page instance.
`handler` - Function that receives a Response.
sourceraw docstring

once-dialogclj

(once-dialog page handler)

Registers a one-time handler for the next dialog. The handler is automatically removed after the first dialog is handled.

Params: page - Page instance. handler - Function that receives a Dialog.

Registers a one-time handler for the next dialog.
The handler is automatically removed after the first dialog is handled.

Params:
`page`    - Page instance.
`handler` - Function that receives a Dialog.
sourceraw docstring

openerclj

(opener page)

Returns the opener page, if any.

Params: page - Page instance.

Returns: Page or nil.

Returns the opener page, if any.

Params:
`page` - Page instance.

Returns:
Page or nil.
sourceraw docstring

page-contextclj

(page-context page)

Returns the BrowserContext that the page belongs to.

Params: page - Page instance.

Returns: BrowserContext instance.

Returns the BrowserContext that the page belongs to.

Params:
`page` - Page instance.

Returns:
BrowserContext instance.
sourceraw docstring

page-keyboardclj

(page-keyboard page)

Returns the Keyboard for this page.

Params: page - Page instance.

Returns: Keyboard instance.

Returns the Keyboard for this page.

Params:
`page` - Page instance.

Returns:
Keyboard instance.
sourceraw docstring

page-mouseclj

(page-mouse page)

Returns the Mouse for this page.

Params: page - Page instance.

Returns: Mouse instance.

Returns the Mouse for this page.

Params:
`page` - Page instance.

Returns:
Mouse instance.
sourceraw docstring

page-touchscreenclj

(page-touchscreen page)

Returns the Touchscreen for this page.

Params: page - Page instance.

Returns: Touchscreen instance.

Returns the Touchscreen for this page.

Params:
`page` - Page instance.

Returns:
Touchscreen instance.
sourceraw docstring

pdfclj

(pdf page)
(pdf page pdf-opts)

Generates a PDF of the page. Only works in Chromium headless.

Params: page - Page instance. opts - Map, optional. PDF options.

Returns: byte[] of the PDF data, or anomaly map on failure.

Generates a PDF of the page. Only works in Chromium headless.

Params:
`page` - Page instance.
`opts` - Map, optional. PDF options.

Returns:
byte[] of the PDF data, or anomaly map on failure.
sourceraw docstring

reloadclj

(reload page)
(reload page nav-opts)

Reloads the page.

Params: page - Page instance. opts - Map, optional. Reload options.

Returns: Response or nil, or anomaly map on failure.

Reloads the page.

Params:
`page` - Page instance.
`opts` - Map, optional. Reload options.

Returns:
Response or nil, or anomaly map on failure.
sourceraw docstring

route!clj

(route! page pattern handler)

Registers a route handler for URL pattern.

Params: page - Page instance. pattern - String glob or regex Pattern. handler - Function that receives a Route.

Registers a route handler for URL pattern.

Params:
`page`    - Page instance.
`pattern` - String glob or regex Pattern.
`handler` - Function that receives a Route.
sourceraw docstring

screenshotclj

(screenshot page)
(screenshot page ss-opts)

Takes a screenshot of the page.

Params: page - Page instance. opts - Map, optional. Screenshot options.

Returns: byte[] of the image data, or anomaly map on failure.

Takes a screenshot of the page.

Params:
`page` - Page instance.
`opts` - Map, optional. Screenshot options.

Returns:
byte[] of the image data, or anomaly map on failure.
sourceraw docstring

set-content!clj

(set-content! page html)
(set-content! page html set-opts)

Sets the HTML content of the page.

Params: page - Page instance. html - String. HTML content. opts - Map, optional. Options.

Sets the HTML content of the page.

Params:
`page` - Page instance.
`html` - String. HTML content.
`opts` - Map, optional. Options.
sourceraw docstring

set-default-navigation-timeout!clj

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

Sets the default navigation timeout.

Params: page - Page instance. timeout - Double. Timeout in milliseconds.

Sets the default navigation timeout.

Params:
`page`    - Page instance.
`timeout` - Double. Timeout in milliseconds.
sourceraw docstring

set-default-timeout!clj

(set-default-timeout! page timeout)

Sets the default timeout for page operations.

Params: page - Page instance. timeout - Double. Timeout in milliseconds.

Sets the default timeout for page operations.

Params:
`page`    - Page instance.
`timeout` - Double. Timeout in milliseconds.
sourceraw docstring

set-extra-http-headers!clj

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

Sets extra HTTP headers for all requests on this page.

Params: page - Page instance. headers - Map of string->string.

Sets extra HTTP headers for all requests on this page.

Params:
`page`    - Page instance.
`headers` - Map of string->string.
sourceraw docstring

set-viewport-size!clj

(set-viewport-size! page width height)

Sets the viewport size.

Params: page - Page instance. width - Long. Width in pixels. height - Long. Height in pixels.

Sets the viewport size.

Params:
`page`   - Page instance.
`width`  - Long. Width in pixels.
`height` - Long. Height in pixels.
sourceraw docstring

titleclj

(title page)

Returns the page title.

Params: page - Page instance.

Returns: String.

Returns the page title.

Params:
`page` - Page instance.

Returns:
String.
sourceraw docstring

unroute!clj

(unroute! page pattern)

Removes a route handler.

Params: page - Page instance. pattern - String glob or regex Pattern.

Removes a route handler.

Params:
`page`    - Page instance.
`pattern` - String glob or regex Pattern.
sourceraw docstring

urlclj

(url page)

Returns the current page URL.

Params: page - Page instance.

Returns: String.

Returns the current page URL.

Params:
`page` - Page instance.

Returns:
String.
sourceraw docstring

videoclj

(video page)

Returns the Video for this page, if recording.

Params: page - Page instance.

Returns: Video or nil.

Returns the Video for this page, if recording.

Params:
`page` - Page instance.

Returns:
Video or nil.
sourceraw docstring

viewport-sizeclj

(viewport-size page)

Returns the viewport size of the page.

Params: page - Page instance.

Returns: Map with :width and :height, or nil.

Returns the viewport size of the page.

Params:
`page` - Page instance.

Returns:
Map with :width and :height, or nil.
sourceraw docstring

wait-for-downloadclj

(wait-for-download page action)
(wait-for-download page action opts)

Waits for a download to start while executing action.

Params: page - Page instance. action - No-arg function that triggers the download. opts - Optional map. {:predicate fn, :timeout ms}

Returns: Download or anomaly map on timeout.

Waits for a download to start while executing `action`.

Params:
`page`   - Page instance.
`action` - No-arg function that triggers the download.
`opts`   - Optional map. {:predicate fn, :timeout ms}

Returns:
Download or anomaly map on timeout.
sourceraw docstring

wait-for-file-chooserclj

(wait-for-file-chooser page action)
(wait-for-file-chooser page action opts)

Waits for a file chooser dialog while executing action.

Params: page - Page instance. action - No-arg function that triggers the file chooser (e.g. clicking an input). opts - Optional map. {:predicate fn, :timeout ms}

Returns: FileChooser or anomaly map on timeout.

Example: (let [fc (page/wait-for-file-chooser pg #(locator/click (page/locator pg "input[type=file]")))] (util/file-chooser-set-files! fc "/path/to/file.txt"))

Waits for a file chooser dialog while executing `action`.

Params:
`page`   - Page instance.
`action` - No-arg function that triggers the file chooser (e.g. clicking an input).
`opts`   - Optional map. {:predicate fn, :timeout ms}

Returns:
FileChooser or anomaly map on timeout.

Example:
(let [fc (page/wait-for-file-chooser pg
           #(locator/click (page/locator pg "input[type=file]")))]
  (util/file-chooser-set-files! fc "/path/to/file.txt"))
sourceraw docstring

wait-for-functionclj

(wait-for-function page expression)

Waits for a JavaScript function to return a truthy value.

Params: page - Page instance. expression - String. JavaScript expression.

Returns: JSHandle or anomaly map on timeout.

Waits for a JavaScript function to return a truthy value.

Params:
`page`       - Page instance.
`expression` - String. JavaScript expression.

Returns:
JSHandle or anomaly map on timeout.
sourceraw docstring

wait-for-load-stateclj

(wait-for-load-state page)
(wait-for-load-state page state)

Waits for the page to reach a load state.

Params: page - Page instance. state - Keyword, optional. :load :domcontentloaded :networkidle.

Returns: nil or anomaly map on timeout.

Waits for the page to reach a load state.

Params:
`page`  - Page instance.
`state` - Keyword, optional. :load :domcontentloaded :networkidle.

Returns:
nil or anomaly map on timeout.
sourceraw docstring

wait-for-popupclj

(wait-for-popup page action)
(wait-for-popup page action opts)

Waits for a popup page to open while executing action.

Params: page - Page instance. action - No-arg function that triggers the popup. opts - Optional map. {:predicate fn, :timeout ms}

Returns: Page (the popup) or anomaly map on timeout.

Waits for a popup page to open while executing `action`.

Params:
`page`   - Page instance.
`action` - No-arg function that triggers the popup.
`opts`   - Optional map. {:predicate fn, :timeout ms}

Returns:
Page (the popup) or anomaly map on timeout.
sourceraw docstring

wait-for-responseclj

(wait-for-response page url-or-fn callback)

Waits for a response matching the URL or predicate.

Params: page - Page instance. url-or-fn - String or predicate fn. callback - Runnable to trigger the response.

Returns: Response or anomaly map on timeout.

Waits for a response matching the URL or predicate.

Params:
`page`      - Page instance.
`url-or-fn` - String or predicate fn.
`callback`  - Runnable to trigger the response.

Returns:
Response or anomaly map on timeout.
sourceraw docstring

wait-for-selectorclj

(wait-for-selector page selector)
(wait-for-selector page selector wait-opts)

Waits for a selector to satisfy a condition.

Params: page - Page instance. selector - String. CSS selector. opts - Map, optional. Wait options.

Returns: ElementHandle or nil, or anomaly map on timeout.

Waits for a selector to satisfy a condition.

Params:
`page`     - Page instance.
`selector` - String. CSS selector.
`opts`     - Map, optional. Wait options.

Returns:
ElementHandle or nil, or anomaly map on timeout.
sourceraw docstring

wait-for-timeoutclj

(wait-for-timeout page timeout)

Waits for the specified time in milliseconds.

Params: page - Page instance. timeout - Double. Time to wait in ms.

Waits for the specified time in milliseconds.

Params:
`page`    - Page instance.
`timeout` - Double. Time to wait in ms.
sourceraw docstring

wait-for-urlclj

(wait-for-url page url)

Waits for the page to navigate to a URL.

Params: page - Page instance. url - String glob, regex Pattern, or predicate.

Waits for the page to navigate to a URL.

Params:
`page` - Page instance.
`url`  - String glob, regex Pattern, or predicate.
sourceraw docstring

workersclj

(workers page)

Returns all workers in the page.

Params: page - Page instance.

Returns: Vector of Worker instances.

Returns all workers in the page.

Params:
`page` - Page instance.

Returns:
Vector of Worker instances.
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