Skip to main content
macOS only Windows: unsupported operation Linux: unsupported operation

A screenshot is a PNG, base64-encoded in value. Paths follow http://127.0.0.1:4445/{token}; see the overview for the reply format and the errors.

Platforms#

The window’s WKWebView takes the snapshot itself (takeSnapshotWithConfiguration), at the screen’s scale (so 2x on a Retina display), and the plugin returns it as PNG. WebKit draws the page out of process, so the snapshot comes from the web view, on the main thread; it has 30 seconds (500 timeout, the web view did not draw a snapshot in time).

Windows (WebView2) and Linux (WebKitGTK) answer 500 unsupported operation for now. An element screenshot still scrolls the element into view first.

Take screenshot#

GET /session/{sessionId}/screenshot

Verified on macOS

The whole web view. On a Retina display a 900 x 700 window gave a 1800 x 1400 PNG.

sessionIdstringrequired#

The current session’s id.

valuestringrequired#

The PNG, base64-encoded.

Take element screenshot#

GET /session/{sessionId}/element/{elementId}/screenshot

Verified on macOS Not run on a real app yet: a zoomed page

The part of the view the element covers, after it is scrolled into view: the page scrolls it to the middle of the view at once, even when the page sets scroll-behavior: smooth, and cuts its box to the viewports it is in (its frames’ and the window’s). This also holds when the page is zoomed, as Tauri’s set_zoom and the zoom hotkeys do: the area is scaled by the web view’s pageZoom, which only a unit test of that conversion checks. On macOS a real app took the screenshot of a paragraph far below the view on a page with scroll-behavior: smooth.

sessionIdstringrequired#

The current session’s id.

elementIdstringrequired#

The element’s id.

valuestringrequired#

The PNG, base64-encoded.

Errors#

StatuserrorWhen
404no such element, stale element referenceThe element is unknown or gone.
500unsupported operationWindows and Linux.
500unable to capture screenThe element has no area in view; the window holds no WKWebView; WebKit gave no snapshot or the snapshot cannot be encoded.
500timeoutWebKit did not draw the snapshot within 30 seconds.