Skip to content

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.

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). Without selector, the tab’s visible area or, with fullPage = 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 path and overwrites a file with the same name.
  • The format is decided by format, not by the file extension: use a matching extension (.png or .jpg).
ParameterTypeDefaultDescription
pathstring—File path to save to. E.g. C:/captures/screen.png. Supports expressions.
ParameterTypeDefaultDescription
pageZoanPageSession—The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page).
selectorselector—Capture only this element. Empty = page or visible area.
fullPageboolfalseCapture the whole scrollable page (ignored when selector is set).
formatstring"png"Image format: png · jpeg.
qualityint—JPEG quality from 0 to 100. Only with format = jpeg; with png it causes an error.

Returns a string with the path of the saved file, exactly as you gave it in path.

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: " + captura
MessageCause and fix
'path' is required.path is empty.
options.quality is unsupported for the png screenshotsYou set quality with PNG format. Remove it or use format = jpeg.
Timeout 30000ms exceededWith selector, the element didn’t appear or didn’t become visible. Check the selector.
File access errorThe 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.