Skip to content

API Reference / @gtkx/testing / screenshot

Variable: screenshot

const screenshot: (widget, options?) => Promise<ScreenshotResult>

Defined in: packages/testing/dist/screenshot.d.ts:17

Captures a PNG snapshot of a widget, retrying until it has a paintable size, and writes the image to options.path when one is given, creating any missing parent directories. Popovers open inside the widget render on their own surfaces, so they are composited into the image at their on-screen positions. A display that never presents a frame leaves GTK without a cached render node, so the widget's contents are then snapshotted directly; when even that yields nothing, the failure names the display instead of blaming the widget.

Parameters

widget

Gtk.Widget

The widget to render to an image.

options?

ScreenshotOptions

Optional scale, timeout, retry interval, and output path.

Returns

Promise<ScreenshotResult>

The base64-encoded PNG data along with its mime type and dimensions.

Released under the MPL-2.0 License.