(Created on )

Puppeteer: window.visualViewport is not supported.

The capture path needs window.visualViewport but the page environment does not provide it.


The capture path needs window.visualViewport but the page environment does not provide it.

Error message

window.visualViewport is not supported.

How this error happens

Element screenshots, and some BiDi clipped screenshots, read window.visualViewport to translate document coordinates. A browser environment without that API cannot supply those offsets.

The snippets use an open page in an environment without window.visualViewport.

await page.setContent(
    '<div id="preview">Preview</div>'
);

const preview = await page.$("#preview");

await preview.screenshot();

How to fix

Use a browser environment that supplies VisualViewport for element capture. If a whole-page image is sufficient, avoid element-relative clipping.

const image = await page.screenshot({
    fullPage: true,
    type: "png",
});

console.log(image.byteLength);

Things to keep in mind

The failing call is valid in a supported environment. It only reproduces this error when VisualViewport is absent. The correction captures the whole page, not just #preview; do not invent viewport offsets if precise element capture is required.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →