microsoft/playwright · error · Error
fullPage cannot be used with element screenshots.
Error message
fullPage cannot be used with element screenshots.
What it means
Thrown by browser_take_screenshot when params.fullPage is truthy AND params.target is set. A full-page screenshot captures the entire scrollable document, which is mutually exclusive with capturing only a single element/target.
Source
Thrown at packages/playwright-core/src/tools/backend/screenshot.ts:64
case '.jpeg': return 'jpeg';
case '.webp': return 'webp';
}
return undefined;
}
const screenshot = defineTabTool({
capability: 'core',
schema: {
name: 'browser_take_screenshot',
title: 'Take a screenshot',
description: `Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.`,
inputSchema: screenshotSchema,
type: 'readOnly',
},
handle: async (tab, params, response) => {
if (params.fullPage && params.target)
throw new Error('fullPage cannot be used with element screenshots.');
const fileType: ImageFormat = params.type ?? inferTypeFromFilename(params.filename) ?? 'png';
const options: playwright.PageScreenshotOptions = {
type: fileType,
quality: fileType === 'jpeg' ? 90 : undefined,
scale: params.scale,
...tab.actionTimeoutOptions,
...(params.fullPage !== undefined && { fullPage: params.fullPage })
};
const screenshotTargetLabel = params.target ? params.element || 'element' : (params.fullPage ? 'full page' : 'viewport');
const target = params.target ? await tab.targetLocator({ element: params.element, target: params.target }) : null;
const data = target ? await target.locator.screenshot(options) : await tab.page.screenshot(options);
const resolvedFile = await response.resolveClientFile({ prefix: target ? 'element' : 'page', ext: fileType, suggestedFilename: params.filename }, `Screenshot of ${screenshotTargetLabel}`);
response.addCode(`// Screenshot ${screenshotTargetLabel} and save it as ${resolvedFile.relativeName}`);
if (target)View on GitHub (pinned to c8fc3bf8d3)
Solutions
- Drop params.target when taking a full-page screenshot.
- Or drop params.fullPage (or set it false/undefined) when targeting an element.
- Build the params object via two distinct code paths for 'page' vs 'element' screenshots.
Example fix
// before
await client.callTool('browser_take_screenshot', {
fullPage: true, target: 'e5', element: 'logo'
}); // throws
// after - pick one
await client.callTool('browser_take_screenshot', { fullPage: true });
// or
await client.callTool('browser_take_screenshot', { target: 'e5', element: 'logo' }); Defensive patterns
Strategy: validation
Validate before calling
function buildScreenshotParams(p: { fullPage?: boolean; target?: string }) {
if (p.fullPage && p.target)
throw new Error('Choose fullPage OR target, not both');
return p;
} Type guard
function isFullPageScreenshot(p: { fullPage?: boolean; target?: string }): boolean {
return !!p.fullPage && !p.target;
} Try / catch
// Prefer validation; try/catch here only if params come from an untrusted source.
try {
await client.callTool('browser_take_screenshot', params);
} catch (e) {
if (e instanceof Error && e.message === 'fullPage cannot be used with element screenshots.') {
const { target, ...rest } = params;
await client.callTool('browser_take_screenshot', rest); // fall back to fullPage
} else throw e;
} Prevention
- Model full-page vs element screenshots as two distinct code paths.
- Never merge a generic options bag into screenshot params without clearing target when fullPage is set.
When it happens
Trigger: Calling the screenshot tool with both fullPage:true and a target (element ref or selector) in the same invocation.
Common situations: Agent passing a default options bag that includes fullPage:true and also targeting an element; reusing a params template without clearing conflicting flags.
Related errors
- Invalid location "${params.location}", expected format is <f
- At least one of "paths" or "data" must be provided.
- Tab index is required
- Either time, text or textGone must be provided
- Invalid input image
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/7e5bf779121c52fb.
Report an issue: GitHub.