Skip to main content

ScreenshotHandlerConfig

Where page screenshots are stored, in what format, and what part of the page is captured.

Notesโ€‹

Shared by both screenshot handlers โ€” WebDriverScreenshotHandler and PlaywrightScreenshotHandler โ€” so a configuration written for one works for the other.

A screenshot can be written to disk, stored on the document as a field, or both, and targets decides which. Storing images in a field puts the encoded image into the document that goes to your committer, which most indexes are not happy to receive: prefer DIRECTORY, and keep the path in a field with targetDirField when you need to find the file again later.

By default screenshots land in ./screenshots, in dated subdirectories, as PNG.

Examplesโ€‹

screenshotHandler:
targets:
- DIRECTORY
targetDir: ./screenshots
targetDirStructure: URL2PATH
imageFormat: png
cssSelector: "main"

Usageโ€‹

Full configuration skeleton, with every option and its default
cssSelector: string
imageFormat: string
targetDir: string
targetDirField: string
targetDirStructure: URL2PATH
targetMetaField: string
targets:
- METADATA

Propertiesโ€‹

PropertyTypeRequiredDefault
cssSelectorstringNo-
imageFormatstringNopng
targetDirstringNo-
targetDirFieldstringNocrawler.screenshot-path
targetDirStructureenumNoDATETIME
targetMetaFieldstringNocrawler.screenshot
targetsenum[]No-

Property Detailsโ€‹

cssSelectorโ€‹

Capture only the element matching this CSS selector instead of the whole page. Leave blank for the full page.

imageFormatโ€‹

Image format to write, as an ImageIO format name (png by default, jpg and gif also work). PNG keeps text crisp; JPEG produces smaller files for photographic pages.

targetDirโ€‹

Directory screenshots are written to when targets includes DIRECTORY. Default is ./screenshots.

targetDirFieldโ€‹

Document field that receives the path of the file written to targetDir. Default is document.screenshot-path. This is how a committed document points at its screenshot without carrying the image itself.

targetDirStructureโ€‹

How subdirectories under targetDir are laid out: DATETIME (the default, 2026/08/11/13/34/12/), DATE (2026/08/11/), or URL2PATH โ€” one directory per URL segment, which keeps a site's structure visible on disk.

Allowed Valuesโ€‹

  • URL2PATH
  • DATE
  • DATETIME

targetMetaFieldโ€‹

Document field that receives the image itself, Base64-encoded, when targets includes METADATA. Default is document.screenshot.

targetsโ€‹

Where to store the screenshot: DIRECTORY (the default), METADATA, or both.