PlaywrightScreenshotHandler
Captures page screenshots through Playwright, as a whole viewport or a single element.
Notes
Set as the screenshotHandler of a PlaywrightFetcher, this takes a
screenshot of every page the browser renders. With a cssSelector, Playwright
captures just that element itself — no full-page capture and crop, which is how
the WebDriver handler has to do it.
Where the image goes, in what format, and under what directory layout are all
in ScreenshotHandlerConfig, shared by both
handlers. Storing to DIRECTORY and indexing the path is almost always
preferable to putting an encoded image on the document.
Examples
- YAML
- JSON
- XML
fetchers:
- class: PlaywrightFetcher
browser: CHROMIUM
screenshotHandler:
targets:
- DIRECTORY
targetDir: ./screenshots
cssSelector: "article"
{
"fetchers": [
{
"class": "PlaywrightFetcher",
"browser": "CHROMIUM",
"screenshotHandler": {
"targets": [
"DIRECTORY"
],
"targetDir": "./screenshots",
"cssSelector": "article"
}
}
]
}
<fetchers>
<fetcher class="PlaywrightFetcher">
<browser>CHROMIUM</browser>
<screenshotHandler>
<targets>
<target>DIRECTORY</target>
</targets>
<targetDir>./screenshots</targetDir>
<cssSelector>article</cssSelector>
</screenshotHandler>
</fetcher>
</fetchers>
Usage
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
configuration:
cssSelector: string
imageFormat: string
targetDir: string
targetDirField: string
targetDirStructure: URL2PATH
targetMetaField: string
targets:
- METADATA
{
"configuration": {
"cssSelector": "string",
"imageFormat": "string",
"targetDir": "string",
"targetDirField": "string",
"targetDirStructure": "URL2PATH",
"targetMetaField": "string",
"targets": [
"METADATA"
]
}
}
<screenshotHandler>
<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>
</screenshotHandler>
Properties
| Property | Type | Required | Default |
|---|---|---|---|
configuration | ScreenshotHandlerConfig | No | - |
Property Details
configuration
Storage and capture options — targets, directory, format, CSS selector. See ScreenshotHandlerConfig.