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: revert 9e555a9 (#40552)
Pavel Feldmanae5733104f89
diff --git a/tests/mcp/cli-fixtures.ts b/tests/mcp/cli-fixtures.tsindex 8feaede043..887894218a 100644--- a/tests/mcp/cli-fixtures.ts+++ b/tests/mcp/cli-fixtures.ts@@ -30,7 +30,7 @@ export const test = baseTest.extend<{boundBrowser: Browser,cliEnv: Record<string, string>,startDashboardServer: (options?: { cwd?: string, session?: string }) => Promise<Page>,- connectToDashboard: () => Promise<Browser>;+ connectToDashboard: (bindTitle: string) => Promise<Browser>;cli: (...args: any[]) => Promise<{output: string,error: string,@@ -60,8 +60,7 @@ export const test = baseTest.extend<{});},connectToDashboard: async ({ cli, playwright }, use) => {- await use(async () => {- const bindTitle = cliEnv().PWTEST_DASHBOARD_APP_BIND_TITLE;+ await use(async (bindTitle: string) => {let endpoint = '';await expect(async () => {const { output } = await cli('list', '--all', '--json');@@ -121,11 +120,10 @@ function cliEnv() {PLAYWRIGHT_DAEMON_SESSION_DIR: test.info().outputPath('daemon'),PLAYWRIGHT_SOCKETS_DIR: path.join(os.tmpdir(), 'ds' + String(test.info().workerIndex)),PWTEST_CLI_CHANNEL_SCAN_DISABLED_FOR_TEST: '1',- PWTEST_DASHBOARD_APP_BIND_TITLE: `--playwright-internal--${test.info().testId}`,};}-async function runCli(childProcess: CommonFixtures['childProcess'], args: string[], cliOptions: { cwd?: string, env?: Record<string, string> }, options: { mcpBrowser: string, mcpHeadless: boolean }) {+async function runCli(childProcess: CommonFixtures['childProcess'], args: string[], cliOptions: { cwd?: string, env?: Record<string, string>, bindTitle?: string }, options: { mcpBrowser: string, mcpHeadless: boolean }) {const testInfo = test.info();const cli = childProcess({command: [process.execPath, require.resolve('../../packages/playwright-core/lib/tools/cli-client/cli.js'), ...args],@@ -135,6 +133,7 @@ async function runCli(childProcess: CommonFixtures['childProcess'], args: stringPLAYWRIGHT_MCP_BROWSER: options.mcpBrowser,PLAYWRIGHT_MCP_HEADLESS: String(options.mcpHeadless),PWTEST_PRINT_DASHBOARD_PID_FOR_TEST: '1',+ PWTEST_DASHBOARD_APP_BIND_TITLE: cliOptions.bindTitle,...cliOptions.env,}),});diff --git a/tests/mcp/dashboard.spec.ts b/tests/mcp/dashboard.spec.tsindex 36de649ea5..0a801dab4f 100644--- a/tests/mcp/dashboard.spec.ts+++ b/tests/mcp/dashboard.spec.ts@@ -122,12 +122,13 @@ function isAlive(pid: number): boolean {}test('daemon show: closing page exits the process', async ({ cli, connectToDashboard }) => {- const { exitCode, dashboardPid } = await cli('show');+ const bindTitle = `--playwright-internal--${crypto.randomUUID()}`;+ const { exitCode, dashboardPid } = await cli('show', { bindTitle });expect(exitCode).toBe(0);expect(dashboardPid).toBeDefined();expect(isAlive(dashboardPid)).toBe(true);- const browser = await connectToDashboard();+ const browser = await connectToDashboard(bindTitle);const page = browser.contexts()[0].pages()[0];await page.close();@@ -163,8 +164,9 @@ function verifyAnnotateOutput(output: string, expectedText: string, outputDir: stest('should capture annotations via show --annotate', async ({ connectToDashboard, cli, server }) => {await cli('open', server.EMPTY_PAGE);- await cli('show');- const browser = await connectToDashboard();+ const bindTitle = `--playwright-internal--${crypto.randomUUID()}`;+ await cli('show', { bindTitle });+ const browser = await connectToDashboard(bindTitle);const dashboard = browser.contexts()[0].pages()[0];await dashboard.getByRole('navigation', { name: 'Sessions' }).getByRole('option').first().click();@@ -189,7 +191,7 @@ test('should start dashboard and annotate when no dashboard is running', async (let done = false;void annotatePromise.finally(() => { done = true; });- const browser = await connectToDashboard();+ const browser = await connectToDashboard(bindTitle);try {const dashboard = browser.contexts()[0].pages()[0];await drawAndSubmitAnnotation(dashboard, 'hi');@@ -203,7 +205,7 @@ test('should start dashboard and annotate when no dashboard is running', async (verifyAnnotateOutput(output, 'hi', test.info().outputDir);});-test('should enter annotate mode on fresh dashboard.tsx mount with -s --annotate', async ({ connectToDashboard, cli, server }) => {+test('should enter annotate mode on fresh dashboard.tsx mount with annotate', async ({ connectToDashboard, cli, server }) => {await cli('-s=first', 'open', server.EMPTY_PAGE);await cli('-s=second', 'open', server.EMPTY_PAGE);@@ -212,7 +214,7 @@ test('should enter annotate mode on fresh dashboard.tsx mount with -s --annotatelet done = false;void annotatePromise.finally(() => { done = true; });- const browser = await connectToDashboard();+ const browser = await connectToDashboard(bindTitle);try {const dashboard = browser.contexts()[0].pages()[0];await expect(dashboard.getByRole('main', { name: 'Dashboard: annotate' })).toBeVisible();@@ -231,16 +233,20 @@ test('should annotate via direct browser_annotate MCP call', async ({ connectToDconst page = await boundBrowser.newPage();await page.goto(server.EMPTY_PAGE);+ const bindTitle = `--playwright-internal--${crypto.randomUUID()}`;const { client } = await startClient({args: ['--endpoint=default', '--caps=devtools'],- env: cliEnv,+ env: {+ ...cliEnv,+ PWTEST_DASHBOARD_APP_BIND_TITLE: bindTitle,+ },});const annotatePromise = client.callTool({ name: 'browser_annotate' });let done = false;void annotatePromise.then(() => { done = true; });- const browser = await connectToDashboard();+ const browser = await connectToDashboard(bindTitle);try {const dashboard = browser.contexts()[0].pages()[0];await expect(dashboard.getByRole('main', { name: 'Dashboard: annotate' })).toBeVisible();@@ -260,15 +266,19 @@ test('should cancel browser_annotate when the MCP request is aborted', async ({const page = await boundBrowser.newPage();await page.goto(server.EMPTY_PAGE);+ const bindTitle = `--playwright-internal--${crypto.randomUUID()}`;const { client } = await startClient({args: ['--endpoint=default', '--caps=devtools'],- env: cliEnv,+ env: {+ ...cliEnv,+ PWTEST_DASHBOARD_APP_BIND_TITLE: bindTitle,+ },});const controller = new AbortController();const annotatePromise = client.callTool({ name: 'browser_annotate' }, undefined, { signal: controller.signal }).catch(() => {});- const browser = await connectToDashboard();+ const browser = await connectToDashboard(bindTitle);try {const dashboard = browser.contexts()[0].pages()[0];await expect(dashboard.getByRole('main', { name: 'Dashboard: annotate' })).toBeVisible();@@ -287,14 +297,18 @@ test('should cancel browser_annotate when the MCP client disconnects', async ({const page = await boundBrowser.newPage();await page.goto(server.EMPTY_PAGE);+ const bindTitle = `--playwright-internal--${crypto.randomUUID()}`;const { client } = await startClient({args: ['--endpoint=default', '--caps=devtools'],- env: cliEnv,+ env: {+ ...cliEnv,+ PWTEST_DASHBOARD_APP_BIND_TITLE: bindTitle,+ },});void client.callTool({ name: 'browser_annotate' }).catch(() => {});- const browser = await connectToDashboard();+ const browser = await connectToDashboard(bindTitle);try {const dashboard = browser.contexts()[0].pages()[0];await expect(dashboard.getByRole('main', { name: 'Dashboard: annotate' })).toBeVisible();@@ -315,8 +329,9 @@ test('should switch screencast to -s session on show --annotate', async ({ conneawait cli('-s=first', 'open', server.PREFIX + '/red');await cli('-s=second', 'open', server.PREFIX + '/green');- await cli('-s=first', 'show');- const browser = await connectToDashboard();+ const bindTitle = `--playwright-internal--${crypto.randomUUID()}`;+ await cli('-s=first', 'show', { bindTitle });+ const browser = await connectToDashboard(bindTitle);const dashboard = browser.contexts()[0].pages()[0];await expect(dashboard.locator('#display')).toBeVisible();@@ -358,8 +373,9 @@ test('should switch screencast to -s session on show --annotate', async ({ connetest('should disengage annotate mode when --annotate client disconnects', async ({ connectToDashboard, cli, childProcess, cliEnv, mcpBrowser, mcpHeadless, server }) => {await cli('open', server.EMPTY_PAGE);- await cli('show');- const browser = await connectToDashboard();+ const bindTitle = `--playwright-internal--${crypto.randomUUID()}`;+ await cli('show', { bindTitle });+ const browser = await connectToDashboard(bindTitle);const dashboard = browser.contexts()[0].pages()[0];await dashboard.getByRole('navigation', { name: 'Sessions' }).getByRole('option').first().click();