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โ
- YAML
- JSON
- XML
screenshotHandler:
targets:
- DIRECTORY
targetDir: ./screenshots
targetDirStructure: URL2PATH
imageFormat: png
cssSelector: "main"
{
"screenshotHandler": {
"targets": [
"DIRECTORY"
],
"targetDir": "./screenshots",
"targetDirStructure": "URL2PATH",
"imageFormat": "png",
"cssSelector": "main"
}
}
<screenshotHandler>
<targets>
<target>DIRECTORY</target>
</targets>
<targetDir>./screenshots</targetDir>
<targetDirStructure>URL2PATH</targetDirStructure>
<imageFormat>png</imageFormat>
<cssSelector>main</cssSelector>
</screenshotHandler>
Usageโ
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
cssSelector: string
imageFormat: string
targetDir: string
targetDirField: string
targetDirStructure: URL2PATH
targetMetaField: string
targets:
- METADATA
{
"cssSelector": "string",
"imageFormat": "string",
"targetDir": "string",
"targetDirField": "string",
"targetDirStructure": "URL2PATH",
"targetMetaField": "string",
"targets": [
"METADATA"
]
}
<configuration>
<cssSelector>string</cssSelector>
<imageFormat>string</imageFormat>
<targetDir>string</targetDir>
<targetDirField>string</targetDirField>
<targetDirStructure>URL2PATH</targetDirStructure>
<targetMetaField>string</targetMetaField>
<targets>
<target>METADATA</target>
</targets>
</configuration>
Propertiesโ
| Property | Type | Required | Default |
|---|---|---|---|
cssSelector | string | No | - |
imageFormat | string | No | png |
targetDir | string | No | - |
targetDirField | string | No | crawler.screenshot-path |
targetDirStructure | enum | No | DATETIME |
targetMetaField | string | No | crawler.screenshot |
targets | enum[] | 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โ
URL2PATHDATEDATETIME
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.