Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/playwright-core/src/tools/backend/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ const videoStop = defineTool({
ext: 'webm',
suggestedFilename: fileName
}, 'Video');
await response.addFileResult(resolvedFile, null);
await response.addFileResult({
...resolvedFile,
printableLink: `- [Video](${resolvedFile.fileName})`,
}, null);
}
},
});
Expand Down
4 changes: 2 additions & 2 deletions tests/mcp/cli-devtools.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ test('tracing-start-stop', async ({ cli, server }, testInfo) => {
expect(fs.existsSync(testInfo.outputPath('.playwright-cli', 'traces', `trace-${timestamp}.network`))).toBeTruthy();
});

test('video-start-stop', async ({ cli, server }) => {
test('video-start-stop', async ({ cli, server }, testInfo) => {
await cli('open', server.HELLO_WORLD);
const { output: videoStartOutput } = await cli('video-start', 'recordings/video.webm', '--size=400x300');
expect(videoStartOutput).toContain('Video recording started.');
Expand All @@ -244,7 +244,7 @@ test('video-start-stop', async ({ cli, server }) => {
const { output: tabCloseOutput } = await cli('tab-close');
expect(tabCloseOutput).toContain(`0: (current) [](${server.EMPTY_PAGE})`);
const { output: videoStopOutput } = await cli('video-stop');
expect(videoStopOutput).toContain(`### Result\n- [Video](recordings${path.sep}video.webm)\n- [Video](recordings${path.sep}video-1.webm)`);
expect(videoStopOutput).toContain(`### Result\n- [Video](${testInfo.outputPath('recordings', 'video.webm')})\n- [Video](${testInfo.outputPath('recordings', 'video-1.webm')})`);
});

test('video-chapter', async ({ cli, server }) => {
Expand Down
23 changes: 23 additions & 0 deletions tests/mcp/video.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import fs from 'fs';
import path from 'path';

import { test, expect } from './fixtures';
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
Expand Down Expand Up @@ -95,6 +96,28 @@ test('reports missing ffmpeg, not missing browser, when recordVideo is enabled',
});
});

test.describe('video tools', () => {
test.use({ mcpArgs: ['--caps=devtools'] });

test('browser_stop_video returns the absolute video path', async ({ client, server }, testInfo) => {
await navigateToTestPage(client, server);

expect(await client.callTool({
name: 'browser_start_video',
arguments: { filename: path.join('recordings', 'video.webm') },
})).toHaveResponse({
result: 'Video recording started.',
});

expect(await client.callTool({
name: 'browser_stop_video',
arguments: {},
})).toHaveResponse({
result: `- [Video](${testInfo.outputPath('recordings', 'video.webm')})`,
});
});
});

test.describe('action overlays', () => {
test.use({ mcpArgs: ['--caps=devtools'] });

Expand Down