Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(cli): implement test harness (#38914)

Pavel Feldman95a728a03707
diff --git a/packages/playwright/src/mcp/browser/response.ts b/packages/playwright/src/mcp/browser/response.ts
index a91c3b6840..910833bb58 100644
--- a/packages/playwright/src/mcp/browser/response.ts
+++ b/packages/playwright/src/mcp/browser/response.ts
@@ -72,12 +72,12 @@ export class Response {
// What can go into a file goes into a file in outputMode === file.
if (this._context.config.outputMode === 'file') {
if (!result.suggestedFilename)
- result.suggestedFilename = dateAsFileName(result.ext ?? (result.text ? 'txt' : 'bin'));
+ result.suggestedFilename = dateAsFileName(result.ext ?? (result.text !== undefined ? 'txt' : 'bin'));
}
const entry: Result = { text: result.text, data: result.data, title: result.title };
if (result.suggestedFilename)
- entry.filename = await this._context.outputFile(result.suggestedFilename, { origin: 'llm', title: result.title ?? 'Saved result' });
+ entry.filename = await this._context.outputFile(result.suggestedFilename, { origin: 'llm', title: result.title || 'Saved result' });
this._results.push(entry);
return { fileName: entry.filename };
@@ -124,10 +124,11 @@ export class Response {
const text = addSection('Result');
for (const result of this._results) {
if (result.filename) {
- text.push(`- [${result.title}](${rootPath ? path.relative(rootPath, result.filename) : result.filename})`);
+ if (result.text !== undefined || result.data)
+ text.push(`- [${result.title}](${rootPath ? path.relative(rootPath, result.filename) : result.filename})`);
if (result.data)
await fs.promises.writeFile(result.filename, result.data);
- else if (result.text)
+ else if (result.text !== undefined)
await fs.promises.writeFile(result.filename, this._redactText(result.text));
} else if (result.text) {
text.push(result.text);
@@ -247,7 +248,7 @@ export function renderTabMarkdown(tab: TabHeader): string[] {
export function renderTabsMarkdown(tabs: TabHeader[]): string[] {
if (!tabs.length)
- return ['No open tabs. Use the "browser_navigate" tool to navigate to a page first.'];
+ return ['No open tabs. Navigate to a URL to create one.'];
const lines: string[] = [];
for (let i = 0; i < tabs.length; i++) {
diff --git a/packages/playwright/src/mcp/browser/tools/common.ts b/packages/playwright/src/mcp/browser/tools/common.ts
index a834e10ebd..0fe3144aa0 100644
--- a/packages/playwright/src/mcp/browser/tools/common.ts
+++ b/packages/playwright/src/mcp/browser/tools/common.ts
@@ -52,10 +52,7 @@ const resize = defineTabTool({
handle: async (tab, params, response) => {
response.addCode(`await page.setViewportSize({ width: ${params.width}, height: ${params.height} });`);
-
- await tab.waitForCompletion(async () => {
- await tab.page.setViewportSize({ width: params.width, height: params.height });
- });
+ await tab.page.setViewportSize({ width: params.width, height: params.height });
},
});
diff --git a/packages/playwright/src/mcp/browser/tools/console.ts b/packages/playwright/src/mcp/browser/tools/console.ts
index 857fd072f5..bca8d3bff4 100644
--- a/packages/playwright/src/mcp/browser/tools/console.ts
+++ b/packages/playwright/src/mcp/browser/tools/console.ts
@@ -32,7 +32,7 @@ const console = defineTabTool({
handle: async (tab, params, response) => {
const messages = await tab.consoleMessages(params.level);
const text = messages.map(message => message.toString()).join('\n');
- await response.addResult({ text, suggestedFilename: params.filename });
+ await response.addResult({ text, suggestedFilename: params.filename, title: 'Console' });
},
});
diff --git a/packages/playwright/src/mcp/browser/tools/dialogs.ts b/packages/playwright/src/mcp/browser/tools/dialogs.ts
index cf54079650..7af62cf133 100644
--- a/packages/playwright/src/mcp/browser/tools/dialogs.ts
+++ b/packages/playwright/src/mcp/browser/tools/dialogs.ts
@@ -32,8 +32,6 @@ export const handleDialog = defineTabTool({
},
handle: async (tab, params, response) => {
- response.setIncludeSnapshot();
-
const dialogState = tab.modalStates().find(state => state.type === 'dialog');
if (!dialogState)
throw new Error('No dialog visible');
diff --git a/packages/playwright/src/mcp/browser/tools/evaluate.ts b/packages/playwright/src/mcp/browser/tools/evaluate.ts
index e85f03582f..5e629c4003 100644
--- a/packages/playwright/src/mcp/browser/tools/evaluate.ts
+++ b/packages/playwright/src/mcp/browser/tools/evaluate.ts
@@ -25,7 +25,6 @@ const evaluateSchema = z.object({
function: z.string().describe('() => { /* code */ } or (element) => { /* code */ } when element is provided'),
element: z.string().optional().describe('Human-readable element description used to obtain permission to interact with the element'),
ref: z.string().optional().describe('Exact target element reference from the page snapshot'),
- filename: z.string().optional().describe('Filename to save the result to. If not provided, result is returned as JSON string.'),
});
const evaluate = defineTabTool({
@@ -39,11 +38,9 @@ const evaluate = defineTabTool({
},
handle: async (tab, params, response) => {
- response.setIncludeSnapshot();
-
let locator: Awaited<ReturnType<Tab['refLocator']>> | undefined;
- if (params.ref && params.element) {
- locator = await tab.refLocator({ ref: params.ref, element: params.element });
+ if (params.ref) {
+ locator = await tab.refLocator({ ref: params.ref, element: params.element || 'element' });
response.addCode(`await page.${locator.resolved}.evaluate(${escapeWithQuotes(params.function)});`);
} else {
response.addCode(`await page.evaluate(${escapeWithQuotes(params.function)});`);
@@ -53,7 +50,7 @@ const evaluate = defineTabTool({
const receiver = locator?.locator ?? tab.page;
const result = await receiver._evaluateFunction(params.function);
const text = JSON.stringify(result, null, 2) || 'undefined';
- await response.addResult({ text, suggestedFilename: params.filename });
+ response.addTextResult(text);
});
},
});
diff --git a/packages/playwright/src/mcp/browser/tools/network.ts b/packages/playwright/src/mcp/browser/tools/network.ts
index d8428d119c..3907dacbba 100644
--- a/packages/playwright/src/mcp/browser/tools/network.ts
+++ b/packages/playwright/src/mcp/browser/tools/network.ts
@@ -42,7 +42,7 @@ const requests = defineTabTool({
if (rendered)
text.push(rendered);
}
- await response.addResult({ text: text.join('\n'), suggestedFilename: params.filename });
+ await response.addResult({ text: text.join('\n'), suggestedFilename: params.filename, title: 'Network' });
},
});
diff --git a/packages/playwright/src/mcp/browser/tools/runCode.ts b/packages/playwright/src/mcp/browser/tools/runCode.ts
index 75ea8b5844..03d7922911 100644
--- a/packages/playwright/src/mcp/browser/tools/runCode.ts
+++ b/packages/playwright/src/mcp/browser/tools/runCode.ts
@@ -23,7 +23,6 @@ import { defineTabTool } from './tool';
const codeSchema = z.object({
code: z.string().describe(`A JavaScript function containing Playwright code to execute. It will be invoked with a single argument, page, which you can use for any page interaction. For example: \`async (page) => { await page.getByRole('button', { name: 'Submit' }).click(); return await page.title(); }\``),
- filename: z.string().optional().describe('Filename to save the result to. If not provided, result is returned as JSON string.'),
});
const runCode = defineTabTool({
@@ -37,7 +36,6 @@ const runCode = defineTabTool({
},
handle: async (tab, params, response) => {
- response.setIncludeSnapshot();
response.addCode(`await (${params.code})(page);`);
const __end__ = new ManualPromise<void>();
const context = {
@@ -57,7 +55,7 @@ const runCode = defineTabTool({
await vm.runInContext(snippet, context);
const result = await __end__;
if (typeof result === 'string')
- await response.addResult({ text: result, suggestedFilename: params.filename });
+ response.addTextResult(result);
});
},
});
diff --git a/packages/playwright/src/mcp/browser/tools/screenshot.ts b/packages/playwright/src/mcp/browser/tools/screenshot.ts
index 2403831f5d..c03118f3e5 100644
--- a/packages/playwright/src/mcp/browser/tools/screenshot.ts
+++ b/packages/playwright/src/mcp/browser/tools/screenshot.ts
@@ -43,8 +43,6 @@ const screenshot = defineTabTool({
},
handle: async (tab, params, response) => {
- if (!!params.element !== !!params.ref)
- throw new Error('Both element and ref must be provided or neither.');
if (params.fullPage && params.ref)
throw new Error('fullPage cannot be used with element screenshots.');
@@ -55,9 +53,8 @@ const screenshot = defineTabTool({
scale: 'css',
...(params.fullPage !== undefined && { fullPage: params.fullPage })
};
- const isElementScreenshot = params.element && params.ref;
- const screenshotTarget = isElementScreenshot ? params.element : (params.fullPage ? 'full page' : 'viewport');
+ const screenshotTarget = params.ref ? params.element || 'element' : (params.fullPage ? 'full page' : 'viewport');
const ref = params.ref ? await tab.refLocator({ element: params.element || '', ref: params.ref }) : null;
const data = ref ? await ref.locator.screenshot(options) : await tab.page.screenshot(options);
diff --git a/packages/playwright/src/mcp/browser/tools/snapshot.ts b/packages/playwright/src/mcp/browser/tools/snapshot.ts
index e8620e0a55..ad64d995d9 100644
--- a/packages/playwright/src/mcp/browser/tools/snapshot.ts
+++ b/packages/playwright/src/mcp/browser/tools/snapshot.ts
@@ -191,8 +191,9 @@ const check = defineTabTool({
},
handle: async (tab, params, response) => {
- const { resolved } = await tab.refLocator(params);
+ const { locator, resolved } = await tab.refLocator(params);
response.addCode(`await page.${resolved}.check();`);
+ await locator.check();
},
});
@@ -208,8 +209,9 @@ const uncheck = defineTabTool({
},
handle: async (tab, params, response) => {
- const { resolved } = await tab.refLocator(params);
+ const { locator, resolved } = await tab.refLocator(params);
response.addCode(`await page.${resolved}.uncheck();`);
+ await locator.uncheck();
},
});
diff --git a/packages/playwright/src/mcp/terminal/cli.ts b/packages/playwright/src/mcp/terminal/cli.ts
index 0c7116e979..c6aa4b8edc 100644
--- a/packages/playwright/src/mcp/terminal/cli.ts
+++ b/packages/playwright/src/mcp/terminal/cli.ts
@@ -18,6 +18,7 @@
/* eslint-disable no-restricted-properties */
import { spawn } from 'child_process';
+
import crypto from 'crypto';
import fs from 'fs';
import net from 'net';
@@ -26,6 +27,8 @@ import path from 'path';
import { debug } from 'playwright-core/lib/utilsBundle';
import { SocketConnection } from './socketConnection';
+import type { SpawnOptions } from 'child_process';
+
const debugCli = debug('pw:cli');
const packageJSON = require('../../../package.json');
@@ -158,7 +161,7 @@ class SessionManager {
}
private async _connect(sessionName: string): Promise<Session> {
- const socketPath = this._daemonSocketPath(sessionName);
+ const socketPath = process.env.PLAYWRIGHT_DAEMON_SOCKET_PATH || this._daemonSocketPath(sessionName);
debugCli(`Connecting to daemon at ${socketPath}`);
const socketExists = await fs.promises.stat(socketPath)
@@ -176,11 +179,11 @@ class SessionManager {
}
}
- const cliPath = path.join(__dirname, '../../../cli.js');
- debugCli(`Will launch daemon process: ${cliPath}`);
+ if (process.env.PLAYWRIGHT_DAEMON_SOCKET_PATH)
+ throw new Error(`Socket path ${socketPath} does not exist`);
const userDataDir = path.resolve(daemonSocketDir, `${sessionName}-user-data`);
- const child = spawn(process.execPath, [cliPath, 'run-mcp-server', `--daemon=${socketPath}`, `--user-data-dir=${userDataDir}`], {
+ const child = spawnDaemon(socketPath, userDataDir, {
detached: true,
stdio: 'ignore',
cwd: process.cwd(), // Will be used as root.
@@ -298,6 +301,12 @@ const daemonSocketDir = (() => {
return path.join(localCacheDir, 'ms-playwright', 'daemon', 'daemon', socketDirHash);
})();
+function spawnDaemon(socketPath: string, userDataDir: string, options: SpawnOptions) {
+ const cliPath = path.join(__dirname, '../../../cli.js');
+ debugCli(`Will launch daemon process: ${cliPath}`);
+ return spawn(process.execPath, [cliPath, 'run-mcp-server', `--daemon=${socketPath}`, `--user-data-dir=${userDataDir}`], options);
+}
+
async function main() {
const argv = process.argv.slice(2);
const args = require('minimist')(argv);
diff --git a/packages/playwright/src/mcp/terminal/command.ts b/packages/playwright/src/mcp/terminal/command.ts
index 152414669d..b0e44c0b72 100644
--- a/packages/playwright/src/mcp/terminal/command.ts
+++ b/packages/playwright/src/mcp/terminal/command.ts
@@ -25,7 +25,7 @@ export type CommandSchema<Args extends zodType.ZodTypeAny, Options extends zodTy
description: string;
args?: Args;
options?: Options;
- toolName: string | ((args: zodType.infer<Args>, options: zodType.infer<Options>) => string);
+ toolName: string | ((args: zodType.infer<Args> & zodType.infer<Options>) => string);
toolParams: (args: zodType.infer<Args> & zodType.infer<Options>) => any;
};
@@ -51,7 +51,7 @@ export function parseCommand(command: AnyCommandSchema, args: Record<string, str
throw new Error(formatZodError(e as zodType.ZodError));
}
- const toolName = typeof command.toolName === 'function' ? command.toolName(parsedArgsObject, options) : command.toolName;
+ const toolName = typeof command.toolName === 'function' ? command.toolName({ ...parsedArgsObject, ...options }) : command.toolName;
const toolParams = command.toolParams({ ...parsedArgsObject, ...options });
return { toolName, toolParams };
}
diff --git a/packages/playwright/src/mcp/terminal/commands.ts b/packages/playwright/src/mcp/terminal/commands.ts
index 99025fb16f..dc183b64e2 100644
--- a/packages/playwright/src/mcp/terminal/commands.ts
+++ b/packages/playwright/src/mcp/terminal/commands.ts
@@ -227,7 +227,7 @@ const fill = declareCommand({
options: z.object({
submit: z.boolean().optional().describe('Whether to submit entered text (press Enter after)'),
}),
- toolName: 'browser_fill',
+ toolName: 'browser_type',
toolParams: ({ ref, text, submit }) => ({ ref, text, submit }),
});
@@ -242,16 +242,16 @@ const hover = declareCommand({
toolParams: ({ ref }) => ({ ref }),
});
-const selectOption = declareCommand({
+const select = declareCommand({
name: 'select',
description: 'Select an option in a dropdown',
category: 'core',
args: z.object({
ref: z.string().describe('Exact target element reference from the page snapshot'),
- vals: z.array(z.string()).describe('Array of values to select in the dropdown. This can be a single value or multiple values.'),
+ val: z.string().describe('Value to select in the dropdown'),
}),
toolName: 'browser_select_option',
- toolParams: ({ ref, vals: values }) => ({ ref, values }),
+ toolParams: ({ ref, val: value }) => ({ ref, values: [value] }),
});
const fileUpload = declareCommand({
@@ -308,7 +308,7 @@ const evaluate = declareCommand({
ref: z.string().optional().describe('Exact target element reference from the page snapshot'),
}),
toolName: 'browser_evaluate',
- toolParams: ({ func: fn, ref }) => ({ function: fn, ref }),
+ toolParams: ({ func, ref }) => ({ function: func, ref }),
});
const dialogAccept = declareCommand({
@@ -398,10 +398,10 @@ const screenshot = declareCommand({
}),
options: z.object({
filename: z.string().optional().describe('File name to save the screenshot to. Defaults to `page-{timestamp}.{png|jpeg}` if not specified.'),
- fullPage: z.boolean().optional().describe('When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.'),
+ ['full-page']: z.boolean().optional().describe('When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.'),
}),
toolName: 'browser_take_screenshot',
- toolParams: ({ ref, filename, fullPage }) => ({ filename, ref, fullPage }),
+ toolParams: ({ ref, filename, ['full-page']: fullPage }) => ({ filename, ref, fullPage }),
});
const pdfSave = declareCommand({
@@ -428,8 +428,8 @@ const consoleList = declareCommand({
options: z.object({
clear: z.boolean().optional().describe('Whether to clear the console list'),
}),
- toolName: 'browser_console_messages',
- toolParams: ({ ['min-level']: minLevel }) => ({ minLevel }),
+ toolName: ({ clear }) => clear ? 'browser_console_clear' : 'browser_console_messages',
+ toolParams: ({ ['min-level']: level, clear }) => clear ? ({}) : ({ level }),
});
const networkRequests = declareCommand({
@@ -441,8 +441,8 @@ const networkRequests = declareCommand({
static: z.boolean().optional().describe('Whether to include successful static resources like images, fonts, scripts, etc. Defaults to false.'),
clear: z.boolean().optional().describe('Whether to clear the network list'),
}),
- toolName: 'browser_network_requests',
- toolParams: ({ static: includeStatic }) => ({ includeStatic }),
+ toolName: ({ clear }) => clear ? 'browser_network_clear' : 'browser_network_requests',
+ toolParams: ({ static: includeStatic, clear }) => clear ? ({}) : ({ includeStatic }),
});
const runCode = declareCommand({
@@ -525,7 +525,7 @@ const commandsArray: AnyCommandSchema[] = [
fill,
drag,
hover,
- selectOption,
+ select,
fileUpload,
check,
uncheck,
diff --git a/packages/playwright/src/mcp/terminal/help.json b/packages/playwright/src/mcp/terminal/help.json
index 743df89eb4..15f83917cc 100644
--- a/packages/playwright/src/mcp/terminal/help.json
+++ b/packages/playwright/src/mcp/terminal/help.json
@@ -1,5 +1,5 @@
{
- "global": "Usage: playwright-cli <command> [args] [options]\n\nCore:\n open <url> open url\n close close the page\n type <text> type text into editable element\n click <ref> [button] perform click on a web page\n dblclick <ref> [button] perform double click on a web page\n fill <ref> <text> fill text into editable element\n drag <startRef> <endRef> perform drag and drop between two elements\n hover <ref> hover over element on page\n select <ref> <vals> select an option in a dropdown\n upload <file> upload one or multiple files\n check <ref> check a checkbox or radio button\n uncheck <ref> uncheck a checkbox or radio button\n snapshot capture page snapshot to obtain element ref\n eval <func> [ref] evaluate javascript expression on page or element\n dialog-accept [prompt] accept a dialog\n dialog-dismiss dismiss a dialog\n resize <w> <h> resize the browser window\n\nNavigation:\n go-back go back to the previous page\n go-forward go forward to the next page\n reload reload the current page\n\nKeyboard:\n key-press <key> press a key on the keyboard, `a`, `arrowleft`\n key-down <key> press a key down on the keyboard\n key-up <key> press a key up on the keyboard\n\nMouse:\n mouse-move <x> <y> move mouse to a given position\n mouse-down [button] press mouse down\n mouse-up [button] press mouse up\n mouse-wheel <dx> <dy> scroll mouse wheel\n\nSave as:\n screenshot [ref] screenshot of the current page or element\n pdf save page as pdf\n\nTabs:\n tab-list list all tabs\n tab-new [url] create a new tab\n tab-close [index] close a browser tab\n tab-select <index> select a browser tab\n\nDevTools:\n console [min-level] list console messages\n network list all network requests since loading the page\n run-code <code> run playwright code snippet\n tracing-start start trace recording\n tracing-stop stop trace recording\n\nSessions:\n session-list list all sessions\n session-stop [name] stop session\n session-stop-all stop all sessions\n session-delete [name] delete session data",
+ "global": "Usage: playwright-cli <command> [args] [options]\n\nCore:\n open <url> open url\n close close the page\n type <text> type text into editable element\n click <ref> [button] perform click on a web page\n dblclick <ref> [button] perform double click on a web page\n fill <ref> <text> fill text into editable element\n drag <startRef> <endRef> perform drag and drop between two elements\n hover <ref> hover over element on page\n select <ref> <val> select an option in a dropdown\n upload <file> upload one or multiple files\n check <ref> check a checkbox or radio button\n uncheck <ref> uncheck a checkbox or radio button\n snapshot capture page snapshot to obtain element ref\n eval <func> [ref] evaluate javascript expression on page or element\n dialog-accept [prompt] accept a dialog\n dialog-dismiss dismiss a dialog\n resize <w> <h> resize the browser window\n\nNavigation:\n go-back go back to the previous page\n go-forward go forward to the next page\n reload reload the current page\n\nKeyboard:\n key-press <key> press a key on the keyboard, `a`, `arrowleft`\n key-down <key> press a key down on the keyboard\n key-up <key> press a key up on the keyboard\n\nMouse:\n mouse-move <x> <y> move mouse to a given position\n mouse-down [button] press mouse down\n mouse-up [button] press mouse up\n mouse-wheel <dx> <dy> scroll mouse wheel\n\nSave as:\n screenshot [ref] screenshot of the current page or element\n pdf save page as pdf\n\nTabs:\n tab-list list all tabs\n tab-new [url] create a new tab\n tab-close [index] close a browser tab\n tab-select <index> select a browser tab\n\nDevTools:\n console [min-level] list console messages\n network list all network requests since loading the page\n run-code <code> run playwright code snippet\n tracing-start start trace recording\n tracing-stop stop trace recording\n\nSessions:\n session-list list all sessions\n session-stop [name] stop session\n session-stop-all stop all sessions\n session-delete [name] delete session data",
"commands": {
"open": "playwright-cli open <url>\n\nOpen URL\n\nArguments:\n <url> the url to navigate to\nOptions:\n --headed run browser in headed mode",
"close": "playwright-cli close \n\nClose the page\n",
@@ -9,7 +9,7 @@
"fill": "playwright-cli fill <ref> <text>\n\nFill text into editable element\n\nArguments:\n <ref> exact target element reference from the page snapshot\n <text> text to fill into the element\nOptions:\n --submit whether to submit entered text (press enter after)",
"drag": "playwright-cli drag <startRef> <endRef>\n\nPerform drag and drop between two elements\n\nArguments:\n <startRef> exact source element reference from the page snapshot\n <endRef> exact target element reference from the page snapshot\nOptions:\n --headed run browser in headed mode",
"hover": "playwright-cli hover <ref>\n\nHover over element on page\n\nArguments:\n <ref> exact target element reference from the page snapshot",
- "select": "playwright-cli select <ref> <vals>\n\nSelect an option in a dropdown\n\nArguments:\n <ref> exact target element reference from the page snapshot\n <vals> array of values to select in the dropdown. this can be a single value or multiple values.",
+ "select": "playwright-cli select <ref> <val>\n\nSelect an option in a dropdown\n\nArguments:\n <ref> exact target element reference from the page snapshot\n <val> value to select in the dropdown",
"upload": "playwright-cli upload <file>\n\nUpload one or multiple files\n\nArguments:\n <file> the absolute paths to the files to upload",
"check": "playwright-cli check <ref>\n\nCheck a checkbox or radio button\n\nArguments:\n <ref> exact target element reference from the page snapshot",
"uncheck": "playwright-cli uncheck <ref>\n\nUncheck a checkbox or radio button\n\nArguments:\n <ref> exact target element reference from the page snapshot",
@@ -29,7 +29,7 @@
"mouse-down": "playwright-cli mouse-down [button]\n\nPress mouse down\n\nArguments:\n [button] button to press, defaults to left",
"mouse-up": "playwright-cli mouse-up [button]\n\nPress mouse up\n\nArguments:\n [button] button to press, defaults to left",
"mouse-wheel": "playwright-cli mouse-wheel <dx> <dy>\n\nScroll mouse wheel\n\nArguments:\n <dx> y delta\n <dy> x delta",
- "screenshot": "playwright-cli screenshot [ref]\n\nscreenshot of the current page or element\n\nArguments:\n [ref] exact target element reference from the page snapshot.\nOptions:\n --filename file name to save the screenshot to. defaults to `page-{timestamp}.{png|jpeg}` if not specified.\n --fullPage when true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.",
+ "screenshot": "playwright-cli screenshot [ref]\n\nscreenshot of the current page or element\n\nArguments:\n [ref] exact target element reference from the page snapshot.\nOptions:\n --filename file name to save the screenshot to. defaults to `page-{timestamp}.{png|jpeg}` if not specified.\n --full-page when true, takes a screenshot of the full scrollable page, instead of the currently visible viewport.",
"pdf": "playwright-cli pdf \n\nSave page as PDF\n\nOptions:\n --filename file name to save the pdf to. defaults to `page-{timestamp}.pdf` if not specified.",
"tab-list": "playwright-cli tab-list \n\nList all tabs\n",
"tab-new": "playwright-cli tab-new [url]\n\nCreate a new tab\n\nArguments:\n [url] the url to navigate to in the new tab. if omitted, the new tab will be blank.",
diff --git a/tests/mcp/cli-fixtures.ts b/tests/mcp/cli-fixtures.ts
new file mode 100644
index 0000000000..40ad1aa525
--- /dev/null
+++ b/tests/mcp/cli-fixtures.ts
@@ -0,0 +1,160 @@
+/**
+ * Copyright (c) Microsoft Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import fs from 'fs';
+import os from 'os';
+import path from 'path';
+import { spawn } from 'child_process';
+
+import { test as baseTest } from './fixtures';
+import { calculateSha1 } from '../../packages/playwright-core/src/server/utils/crypto';
+
+import type { ChildProcess } from 'child_process';
+
+export { expect } from './fixtures';
+export const test = baseTest.extend<{
+ socketPath: string;
+ daemon: ChildProcess;
+ cli: (...args: string[]) => Promise<{ output: string, error: string, snapshot?: string, attachments?: { name: string, data: Buffer | null }[] }>;
+}>({
+ socketPath: async ({}, use, testInfo) => {
+ if (os.platform() === 'win32') {
+ const hash = calculateSha1(testInfo.outputPath());
+ await use(`\\\\.\\pipe\\${hash}`);
+ return;
+ }
+ await use(path.join(test.info().outputPath(), 'socket.sock'));
+ },
+
+ daemon: async ({ socketPath }, use, testInfo) => {
+ const userDataDir = testInfo.outputPath('user-data-dir');
+
+ const daemonPath = path.resolve(__dirname, '../../packages/playwright/cli.js');
+ const daemon = spawn(process.execPath, [daemonPath, 'run-mcp-server', `--daemon=${socketPath}`, `--user-data-dir=${userDataDir}`], {
+ stdio: 'pipe',
+ cwd: testInfo.outputPath(),
+ });
+ let stderr = '';
+ await new Promise<void>((resolve, reject) => {
+ daemon.stdout.on('data', () => {});
+ daemon.stderr.on('data', data => {
+ stderr += data.toString();
+ if (stderr.includes('Daemon server listening'))
+ resolve();
+ });
+ daemon.on('close', code => {
+ if (code === 0)
+ resolve();
+ else
+ reject(new Error(`Daemon exited with code ${code}`));
+ });
+ });
+ await use(daemon);
+ daemon.kill('SIGTERM');
+ },
+
+ cli: async ({ socketPath }, use, testInfo) => {
+ await use(async (...args: string[]) => {
+ const cli = spawn(process.execPath, [require.resolve('../../packages/playwright/lib/mcp/terminal/cli.js'), ...args], {
+ cwd: testInfo.outputPath(),
+ stdio: 'pipe',
+ env: {
+ ...process.env,
+ PLAYWRIGHT_DAEMON_SOCKET_PATH: socketPath,
+ },
+ });
+ let stdout = '';
+ let stderr = '';
+ cli.stdout.on('data', data => { stdout += data.toString(); });
+ cli.stderr.on('data', data => { stderr += data.toString(); });
+ await new Promise<void>((resolve, reject) => {
+ cli.on('close', code => {
+ if (code === 0)
+ resolve();
+ else
+ reject(new Error(`CLI exited with code ${code}: ${stderr}`));
+ });
+ });
+ let snapshot: string | undefined;
+ if (stdout.includes('### Snapshot'))
+ snapshot = await loadSnapshot(stdout);
+ const attachments = loadAttachments(stdout);
+ return { output: stdout.trim(), error: stderr.trim(), snapshot, attachments };
+ });
+ },
+});
+
+export function loadAttachments(output: string) {
+ // attachments look like md links - [Page as pdf](.playwright-cli/page-2026-01-22T23-13-56-347Z.pdf)
+ const match = output.match(/- \[(.+)\]\((.+)\)/g);
+ if (!match)
+ return [];
+
+ return match.map(m => {
+ const [, name, path] = m.match(/- \[(.+)\]\((.+)\)/)!;
+ try {
+ const data = fs.readFileSync(test.info().outputPath(path));
+ return { name, data };
+ } catch (e) {
+ return { name, data: null };
+ }
+ });
+}
+
+export async function loadSnapshot(output: string) {
+ const match = output.match(/- File: (.+)/m);
+ if (!match)
+ throw new Error('Snapshot file not found');
+ const snapshotPath = match[1];
+ const fileName = test.info().outputPath(snapshotPath);
+ return await fs.promises.readFile(fileName, 'utf8');
+}
+
+export const eventsPage = `<!DOCTYPE html>
+<html>
+ <body style="width: 400px; height: 400px; margin: 0; padding: 0;">
+ <div id='square'style="width: 100px; height: 100px;"></div>
+ <div id='log'></div>
+ <script>
+ const logElement = document.querySelector('#log');
+
+ const log = (...args) => {
+ const el = document.createElement('div');
+ el.textContent = args.join(' ');
+ logElement.appendChild(el);
+ };
+ document.body.addEventListener('mousemove', (event) => {
+ log('mouse move', event.clientX, event.clientY);
+ });
+ document.body.addEventListener('mousedown', () => {
+ log('mouse down');
+ });
+ document.body.addEventListener('mouseup', () => {
+ log('mouse up');
+ });
+ document.body.addEventListener('wheel', (event) => {
+ log('wheel', event.deltaX, event.deltaY);
+ });
+ document.body.addEventListener('click', () => {
+ log('click', event.button);
+ });
+ document.body.addEventListener('dblclick', (event) => {
+ log('dblclick', event.button);
+ });
+ </script>
+ </body>
+</html>
+`;
diff --git a/tests/mcp/cli.spec.ts b/tests/mcp/cli.spec.ts
new file mode 100644
index 0000000000..4dd2a6df94
--- /dev/null
+++ b/tests/mcp/cli.spec.ts
@@ -0,0 +1,350 @@
+/**
+ * Copyright (c) Microsoft Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { test, expect, eventsPage } from './cli-fixtures';
+
+test.skip(({}) => process.platform === 'win32');
+
+test.describe('help', () => {
+ test('prints help by default', async ({ cli }) => {
+ const { output } = await cli('--help');
+ expect(output).toContain('Usage: playwright-cli <command>');
+ });
+
+ test('prints command help', async ({ cli }) => {
+ const { output } = await cli('click', '--help');
+ expect(output).toContain('playwright-cli click <ref> [button]');
+ });
+});
+
+test.describe('core', () => {
+ test('open', async ({ cli, daemon, server }) => {
+ const { output, snapshot } = await cli('open', server.HELLO_WORLD);
+ expect(output).toContain(`### Page
+- Page URL: ${server.HELLO_WORLD}
+- Page Title: Title`);
+
+ expect(snapshot).toContain(`- generic [active] [ref=e1]: Hello, world!`);
+ });
+
+ test('close', async ({ cli, daemon, server }) => {
+ await cli('open', server.HELLO_WORLD);
+ const { output } = await cli('close');
+ expect(output).toContain(`No open tabs. Navigate to a URL to create one.`);
+ });
+
+ test('click button', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<button>Submit</button>`, 'text/html');
+
+ const { snapshot } = await cli('open', server.PREFIX);
+ expect(snapshot).toContain(`- button "Submit" [ref=e2]`);
+
+ const { snapshot: clickSnapshot } = await cli('click', 'e2');
+ expect(clickSnapshot).toBeTruthy();
+ });
+
+ test('click link', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<a href="/hello-world">Hello, world!</a>`, 'text/html');
+
+ const { snapshot } = await cli('open', server.PREFIX);
+ expect(snapshot).toContain(`- link \"Hello, world!\" [ref=e2]`);
+
+ const { output: clickOutput, snapshot: clickSnapshot } = await cli('click', 'e2');
+ expect(clickOutput).toContain(`### Page
+- Page URL: ${server.HELLO_WORLD}
+- Page Title: Title`);
+ expect(clickSnapshot).toContain('Hello, world!');
+ });
+
+ test('dblclick', async ({ cli, daemon, server }) => {
+ server.setContent('/', eventsPage, 'text/html');
+ await cli('open', server.PREFIX);
+ const { snapshot } = await cli('dblclick', 'e2');
+ expect(snapshot).toContain('dblclick 0');
+ });
+
+ test('type', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<input type=text>`, 'text/html');
+ const { snapshot } = await cli('open', server.PREFIX);
+ expect(snapshot).toContain(`- textbox [ref=e2]`);
+
+ const { snapshot: typeSnapshot } = await cli('type', 'Hello, world!', '--submit');
+ expect(typeSnapshot).toBe(`- textbox [ref=e2]`);
+ });
+
+ test('fill', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<input type=text>`, 'text/html');
+ const { snapshot } = await cli('open', server.PREFIX);
+ expect(snapshot).toContain(`- textbox [ref=e2]`);
+
+ const { snapshot: fillSnapshot } = await cli('fill', 'e2', 'Hello, world!', '--submit');
+ expect(fillSnapshot).toBe(`- textbox [active] [ref=e2]: Hello, world!`);
+ });
+
+ test('hover', async ({ cli, daemon, server }) => {
+ server.setContent('/', eventsPage, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('hover', 'e2');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toContain('mouse move 50 50');
+ });
+
+ test('select', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<select><option value="1">One</option><option value="2">Two</option></select>`, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('select', 'e2', 'Two');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toContain('- option "Two" [selected]');
+ });
+
+ test('check', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<input type="checkbox">`, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('check', 'e2');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toContain('- checkbox [checked] [active] [ref=e2]');
+ });
+
+ test('uncheck', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<input type="checkbox" checked>`, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('uncheck', 'e2');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toContain('- checkbox [active] [ref=e2]');
+ });
+
+ test('eval', async ({ cli, daemon, server }) => {
+ await cli('open', server.HELLO_WORLD);
+ const { output } = await cli('eval', '() => document.title');
+ expect(output).toContain('"Title"');
+ });
+
+ test('eval <ref>', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<button>Submit</button>`, 'text/html');
+ await cli('open', server.PREFIX);
+ const { output } = await cli('eval', 'element => element.nodeName', 'e2');
+ expect(output).toContain('"BUTTON"');
+ });
+
+ test('dialog-accept', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<button onclick="alert('MyAlert')">Button</button>`, 'text/html');
+ await cli('open', server.PREFIX);
+ const { output } = await cli('click', 'e2');
+ expect(output).toContain('MyAlert');
+ await cli('dialog-accept');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).not.toContain('MyAlert');
+ });
+
+ test('dialog-dismiss', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<button onclick="alert('MyAlert')">Button</button>`, 'text/html');
+ await cli('open', server.PREFIX);
+ const { output } = await cli('click', 'e2');
+ expect(output).toContain('MyAlert');
+ await cli('dialog-dismiss');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).not.toContain('MyAlert');
+ });
+
+ test('dialog-accept <prompt>', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<button onclick="document.body.textContent = prompt('MyAlert')">Button</button>`, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('click', 'e2');
+ await cli('dialog-accept', 'my reply');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toContain('my reply');
+ });
+
+ test('resize', async ({ cli, daemon, server }) => {
+ await cli('open', server.PREFIX);
+ await cli('resize', '480', '320');
+ const { output } = await cli('eval', '() => window.innerWidth + "x" + window.innerHeight');
+ expect(output).toContain('480x320');
+ });
+});
+
+test.describe('navigation', () => {
+ test('go-back', async ({ cli, daemon, server }) => {
+ await cli('open', server.HELLO_WORLD);
+ await cli('open', server.PREFIX);
+ const { output } = await cli('go-back');
+ expect(output).toContain(`### Page
+- Page URL: ${server.HELLO_WORLD}
+- Page Title: Title`);
+ });
+
+ test('go-forward', async ({ cli, daemon, server }) => {
+ await cli('open', server.PREFIX);
+ await cli('open', server.HELLO_WORLD);
+ await cli('go-back');
+ const { output } = await cli('go-forward');
+ expect(output).toContain(`### Page
+- Page URL: ${server.HELLO_WORLD}
+- Page Title: Title`);
+ });
+});
+
+test.describe('keyboard', () => {
+ test('key-press', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<input type=text>`, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('click', 'e2');
+ await cli('key-press', 'h');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toBe(`- textbox [active] [ref=e2]: h`);
+ });
+
+ test('key-down key-up', async ({ cli, daemon, server }) => {
+ server.setContent('/', `<input type=text>`, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('click', 'e2');
+ await cli('key-down', 'h');
+ await cli('key-up', 'h');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toBe(`- textbox [active] [ref=e2]: h`);
+ });
+});
+
+test.describe('mouse', () => {
+ test('mouse-move', async ({ cli, daemon, server }) => {
+ server.setContent('/', eventsPage, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('mouse-move', '45', '35');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toContain('mouse move 45 35');
+ });
+
+ test('mouse-down mouse-up', async ({ cli, daemon, server }) => {
+ server.setContent('/', eventsPage, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('mouse-move', '45', '35');
+ await cli('mouse-down');
+ await cli('mouse-up');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toContain('mouse down');
+ expect(snapshot).toContain('mouse up');
+ });
+
+ test('mouse-wheel', async ({ cli, daemon, server }) => {
+ server.setContent('/', eventsPage, 'text/html');
+ await cli('open', server.PREFIX);
+ await cli('mouse-wheel', '10', '5');
+ const { snapshot } = await cli('snapshot');
+ expect(snapshot).toContain('wheel 5 10');
+ });
+});
+
+
+test.describe('save as', () => {
+ test('screenshot', async ({ cli, daemon, server, mcpBrowser }) => {
+ await cli('open', server.HELLO_WORLD);
+ const { attachments } = await cli('screenshot');
+ expect(attachments[0].name).toEqual('Screenshot of viewport');
+ expect(attachments[0].data).toEqual(expect.any(Buffer));
+ });
+
+ test('screenshot <ref>', async ({ cli, daemon, server, mcpBrowser }) => {
+ server.setContent('/', `<div id="square" style="width: 100px; height: 100px; background-color: red;"></div>`, 'text/html');
+ await cli('open', server.PREFIX);
+ const { attachments } = await cli('screenshot', 'e2');
+ expect(attachments[0].name).toEqual('Screenshot of element');
+ expect(attachments[0].data).toEqual(expect.any(Buffer));
+ });
+
+ test('screenshot --full-page', async ({ cli, daemon, server, mcpBrowser }) => {
+ await cli('open', server.HELLO_WORLD);
+ const { attachments } = await cli('screenshot', '--full-page');
+ expect(attachments[0].name).toEqual('Screenshot of full page');
+ expect(attachments[0].data).toEqual(expect.any(Buffer));
+ });
+
+ test('pdf', async ({ cli, daemon, server, mcpBrowser }) => {
+ test.skip(mcpBrowser !== 'chromium' && mcpBrowser !== 'chrome', 'PDF is only supported in Chromium and Chrome');
+ await cli('open', server.HELLO_WORLD);
+ const { attachments } = await cli('pdf');
+ expect(attachments[0].name).toEqual('Page as pdf');
+ expect(attachments[0].data).toEqual(expect.any(Buffer));
+ });
+});
+
+test.describe('devtools', () => {
+ test('console', async ({ cli, daemon, server }) => {
+ await cli('open', server.PREFIX);
+ await cli('eval', 'console.log("Hello, world!")');
+ const { attachments } = await cli('console');
+ expect(attachments[0].name).toEqual('Console');
+ expect(attachments[0].data.toString()).toContain('Hello, world!');
+ });
+
+ test('console error', async ({ cli, daemon, server }) => {
+ await cli('open', server.PREFIX);
+ await cli('eval', 'console.log("log-level")');
+ await cli('eval', 'console.error("error-level")');
+ const { attachments } = await cli('console', 'error');
+ expect(attachments[0].name).toEqual('Console');
+ expect(attachments[0].data.toString()).not.toContain('log-level');
+ expect(attachments[0].data.toString()).toContain('error-level');
+ });
+
+ test('console --clear', async ({ cli, daemon, server }) => {
+ await cli('open', server.PREFIX);
+ await cli('eval', 'console.log("log-level")');
+ await cli('console', '--clear');
+ const { attachments } = await cli('console');
+ expect(attachments[0].name).toEqual('Console');
+ expect(attachments[0].data.toString()).not.toContain('log-level');
+ });
+
+ test('network', async ({ cli, daemon, server }) => {
+ await cli('open', server.PREFIX);
+ await cli('eval', '() => fetch("/hello-world")');
+ const { attachments } = await cli('network');
+ expect(attachments[0].name).toEqual('Network');
+ expect(attachments[0].data.toString()).not.toContain(`[GET] ${`${server.PREFIX}/`} => [200] OK`);
+ expect(attachments[0].data.toString()).toContain(`[GET] ${`${server.PREFIX}/hello-world`} => [200] OK`);
+ });
+
+ test('network --static', async ({ cli, daemon, server }) => {
+ await cli('open', server.PREFIX);
+ const { attachments } = await cli('network', '--static');
+ expect(attachments[0].name).toEqual('Network');
+ expect(attachments[0].data.toString()).toContain(`[GET] ${`${server.PREFIX}/`} => [200] OK`);
+ });
+
+ test('network --clear', async ({ cli, daemon, server }) => {
+ await cli('open', server.PREFIX);
+ await cli('eval', '() => fetch("/hello-world")');
+ await cli('network', '--clear');
+ const { attachments } = await cli('network');
+ expect(attachments[0].name).toEqual('Network');
+ expect(attachments[0].data.toString()).not.toContain(`[GET] ${`${server.PREFIX}/hello-world`} => [200] OK`);
+ });
+
+ test('run-code', async ({ cli, daemon, server }) => {
+ await cli('open', server.HELLO_WORLD);
+ const { output } = await cli('run-code', '() => page.title()');
+ expect(output).toContain('"Title"');
+ });
+
+ test('tracing-start-stop', async ({ cli, daemon, server }) => {
+ await cli('open', server.HELLO_WORLD);
+ const { output } = await cli('tracing-start');
+ expect(output).toContain('Tracing started, saving to');
+ await cli('eval', '() => fetch("/hello-world")');
+ const { output: tracingStopOutput } = await cli('tracing-stop');
+ expect(tracingStopOutput).toContain('Tracing stopped.');
+ });
+});
diff --git a/tests/mcp/dialogs.spec.ts b/tests/mcp/dialogs.spec.ts
index 8f3dba07f7..c0515f566c 100644
--- a/tests/mcp/dialogs.spec.ts
+++ b/tests/mcp/dialogs.spec.ts
@@ -139,7 +139,6 @@ test('confirm dialog (true)', async ({ client, server }) => {
},
})).toHaveResponse({
modalState: undefined,
- snapshot: expect.stringContaining(`generic [active] [ref=e1]: "true"`),
});
});
@@ -175,7 +174,6 @@ test('confirm dialog (false)', async ({ client, server }) => {
},
})).toHaveResponse({
modalState: undefined,
- snapshot: expect.stringContaining(`generic [active] [ref=e1]: "false"`),
});
});
@@ -213,7 +211,7 @@ test('prompt dialog', async ({ client, server }) => {
});
expect(result).toHaveResponse({
- snapshot: expect.stringContaining(`generic [active] [ref=e1]: Answer`),
+ modalState: undefined,
});
});
diff --git a/tests/mcp/snapshot-mode.spec.ts b/tests/mcp/snapshot-mode.spec.ts
index d379da7dfe..bf692dedb0 100644
--- a/tests/mcp/snapshot-mode.spec.ts
+++ b/tests/mcp/snapshot-mode.spec.ts
@@ -35,7 +35,7 @@ test('should respect --snapshot-mode=full', async ({ startClient, server }) => {
- button "Button 1" [ref=e2]`),
});
- expect(await client.callTool({
+ await client.callTool({
name: 'browser_evaluate',
arguments: {
function: `async () => {
@@ -44,6 +44,10 @@ test('should respect --snapshot-mode=full', async ({ startClient, server }) => {
document.body.appendChild(button2);
}`,
},
+ });
+
+ expect(await client.callTool({
+ name: 'browser_snapshot',
})).toHaveResponse({
snapshot: expect.stringContaining(`
- button "Button 1" [ref=e2]
@@ -68,7 +72,7 @@ test('should respect --snapshot-mode=incremental', async ({ startClient, server
- button "Button 1" [ref=e2]`),
});
- expect(await client.callTool({
+ await client.callTool({
name: 'browser_evaluate',
arguments: {
function: `async () => {
@@ -77,11 +81,19 @@ test('should respect --snapshot-mode=incremental', async ({ startClient, server
document.body.appendChild(button2);
}`,
},
+ });
+
+ expect(await client.callTool({
+ name: 'browser_click',
+ arguments: {
+ element: 'Button 2',
+ ref: 'e3',
+ },
})).toHaveResponse({
snapshot: expect.stringContaining(`
-- <changed> generic [active] [ref=e1]:
+- <changed> generic [ref=e1]:
- ref=e2 [unchanged]
- - button \"Button 2\" [ref=e3]`),
+ - button \"Button 2\" [active] [ref=e3]`),
});
});
diff --git a/tests/mcp/terminal.spec.ts b/tests/mcp/terminal.spec.ts
deleted file mode 100644
index 6b6375db1b..0000000000
--- a/tests/mcp/terminal.spec.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import path from 'path';
-import { test, expect } from './fixtures';
-
-test('terminal mode', async ({ startClient, server }) => {
- server.setContent('/', formHtml, 'text/html');
- const outputDir = test.info().outputPath('output');
-
- const { client } = await startClient({
- args: ['--codegen=none', '--output-mode=file', '--snapshot-mode=full', '--output-dir=' + outputDir],
- });
-
- expect(await client.callTool({
- name: 'browser_navigate',
- arguments: { url: server.PREFIX },
- })).toHaveTextResponse(`### Page
-- Page URL: ${server.PREFIX}/
-
-### Snapshot
-- File: output${path.sep}snapshot-1.yml
-`);
-
- expect(await client.callTool({
- name: 'browser_type',
- arguments: {
- ref: 'e4',
- element: 'Name textbox',
- text: 'John Doe',
- },
- })).toHaveTextResponse('');
-
- expect(await client.callTool({
- name: 'browser_type',
- arguments: {
- ref: 'e6',
- element: 'Email textbox',
- },
- })).toHaveTextResponse('');
-
- expect(await client.callTool({
- name: 'browser_type',
- arguments: {
- ref: 'e8',
- element: 'Age textbox',
- text: '25',
- },
- })).toHaveTextResponse('');
-
- expect(await client.callTool({
- name: 'browser_select_option',
- arguments: {
- ref: 'e10',
- element: 'Country select',
- values: ['United States'],
- },
- })).toHaveTextResponse(`### Snapshot
-- File: output${path.sep}snapshot-5.yml
-`);
-
- expect(await client.callTool({
- name: 'browser_click',
- arguments: {
- ref: 'e12',
- element: 'Subscribe checkbox',
- },
- })).toHaveTextResponse(`### Snapshot
-- File: output${path.sep}snapshot-6.yml
-`);
-});
-
-
-const formHtml = `
- <!DOCTYPE html>
- <html>
- <body>
- <form>
- <label>
- <input type="text" id="name" name="name" />
- Name
- </label>
- <label>
- <input type="email" id="email" name="email" />
- Email
- </label>
- <label>
- <input type="range" id="age" name="age" min="18" max="100" />
- Age
- </label>
- <label>
- <select id="country" name="country">
- <option value="">Choose a country</option>
- <option value="us">United States</option>
- <option value="uk">United Kingdom</option>
- </select>
- Country
- </label>
- <label>
- <input type="checkbox" name="subscribe" value="newsletter" />
- Subscribe to newsletter
- </label>
- </form>
- </body>
- </html>`;