Screenshot
Screenshot
Section titled “Screenshot”Type: page-screenshot · Package: Browser v1.0.9 · Output: string
Takes a screenshot of the full page, the visible area or a specific element, and saves it to an image file. It returns the file path. It’s very useful to keep evidence of what the bot did (a receipt, a status) and, above all, to diagnose failures in unattended runs: a screenshot in the catch shows you what the screen looked like when something went wrong.
How it works
Section titled “How it works”It captures the page (or the selector element) and saves it to path, in PNG (default) or JPEG format. It returns the path of the saved file.
- What is captured: with
selector, only that element (it scrolls it into view and waits for it to be visible, up to 30 s). Withoutselector, the tab’s visible area or, withfullPage = true, the whole scrollable page. - It works the same without a window (headless): it captures what the page renders, not the machine’s screen.
- It creates any missing folders in
pathand overwrites a file with the same name. - The format is decided by
format, not by the file extension: use a matching extension (.pngor.jpg).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | File path to save to. E.g. C:/captures/screen.png. Supports expressions. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
page | ZoanPageSession | — | The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page). |
selector | selector | — | Capture only this element. Empty = page or visible area. |
fullPage | bool | false | Capture the whole scrollable page (ignored when selector is set). |
format | string | "png" | Image format: png · jpeg. |
quality | int | — | JPEG quality from 0 to 100. Only with format = jpeg; with png it causes an error. |
Output
Section titled “Output”Returns a string with the path of the saved file, exactly as you gave it in path.
Example
Section titled “Example”Save evidence with a dated name, and capture the screen if something fails:
Try / Catch errorVariable = error ├─ try: │ Page Click selector = (#pagar) │ Page Screenshot path = "C:/evidence/payment_" + now().ToString("yyyyMMdd_HHmmss") + ".png" fullPage = true └─ catch: Page Screenshot path = "C:/evidence/ERROR.png" fullPage = true → output: captura Log level = error message = "Payment failed: " + error + ". Screenshot: " + capturaCommon errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'path' is required. | path is empty. |
options.quality is unsupported for the png screenshots | You set quality with PNG format. Remove it or use format = jpeg. |
Timeout 30000ms exceeded | With selector, the element didn’t appear or didn’t become visible. Check the selector. |
| File access error | The folder doesn’t allow writing or the file is open in another program. Use another path. |
'page' must be a ZoanPageSession. | page is empty outside a body. |
Related activities
Section titled “Related activities”- Try / Catch — take a screenshot while handling an error.
- Wait for Download — to download files generated by the page.