Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(mcp): encourage relative path usage (#37857)
Pavel Feldman7fbba7563a5e
diff --git a/packages/playwright/src/mcp/browser/config.ts b/packages/playwright/src/mcp/browser/config.tsindex d79cd236da..0dec6a1166 100644--- a/packages/playwright/src/mcp/browser/config.ts+++ b/packages/playwright/src/mcp/browser/config.ts@@ -328,7 +328,7 @@ async function resolveFile(config: FullConfig, clientInfo: ClientInfo, fileName:fileName = fileName.split('\\').join('/');const resolvedFile = path.resolve(dir, fileName);if (!resolvedFile.startsWith(path.resolve(dir) + path.sep))- throw new Error(`Resolved file path for ${fileName} is outside of the output directory`);+ throw new Error(`Resolved file path ${resolvedFile} is outside of the output directory ${dir}. Use relative file names to stay within the output directory.`);return resolvedFile;}diff --git a/packages/playwright/src/mcp/browser/tools/pdf.ts b/packages/playwright/src/mcp/browser/tools/pdf.tsindex 13127f031b..accb071ffd 100644--- a/packages/playwright/src/mcp/browser/tools/pdf.ts+++ b/packages/playwright/src/mcp/browser/tools/pdf.ts@@ -20,7 +20,7 @@ import * as javascript from '../codegen';import { dateAsFileName } from './utils';const pdfSchema = z.object({- filename: z.string().optional().describe('File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified.'),+ filename: z.string().optional().describe('File name to save the pdf to. Defaults to `page-{timestamp}.pdf` if not specified. Prefer relative file names to stay within the output directory.'),});const pdf = defineTabTool({diff --git a/packages/playwright/src/mcp/browser/tools/screenshot.ts b/packages/playwright/src/mcp/browser/tools/screenshot.tsindex 51f51a5e80..18335b0b09 100644--- a/packages/playwright/src/mcp/browser/tools/screenshot.ts+++ b/packages/playwright/src/mcp/browser/tools/screenshot.ts@@ -23,7 +23,7 @@ import type * as playwright from 'playwright-core';const screenshotSchema = z.object({type: z.enum(['png', 'jpeg']).default('png').describe('Image format for the screenshot. Default is png.'),- filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified.'),+ filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified. Prefer relative file names to stay within the output directory.'),element: z.string().optional().describe('Human-readable element description used to obtain permission to screenshot the element. If not provided, the screenshot will be taken of viewport. If element is provided, ref must be provided too.'),ref: z.string().optional().describe('Exact target element reference from the page snapshot. If not provided, the screenshot will be taken of viewport. If ref is provided, element must be provided too.'),fullPage: z.boolean().optional().describe('When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Cannot be used with element screenshots.'),