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
feat(cli): add video-chapter command (#39891)
Pavel Feldman9377dab3e620
diff --git a/docs/src/getting-started-cli.md b/docs/src/getting-started-cli.mdindex 6f12199ef6..8a1bb6e355 100644--- a/docs/src/getting-started-cli.md+++ b/docs/src/getting-started-cli.md@@ -200,7 +200,8 @@ playwright-cli run-code <code> # run Playwright code snippetplaywright-cli tracing-start # start trace recordingplaywright-cli tracing-stop # stop trace recordingplaywright-cli video-start # start video recording-playwright-cli video-stop [filename] # stop video recording+playwright-cli video-chapter <title> # add chapter marker to video+playwright-cli video-stop --filename=f # stop video recording```## Sessionsdiff --git a/packages/playwright-core/src/tools/backend/video.ts b/packages/playwright-core/src/tools/backend/video.tsindex 432be49c25..b386b60c7f 100644--- a/packages/playwright-core/src/tools/backend/video.ts+++ b/packages/playwright-core/src/tools/backend/video.ts@@ -18,7 +18,7 @@ import path from 'path';import { z } from '../../zodBundle';import { defineTool } from './tool';-const startVideo = defineTool({+const videoStart = defineTool({capability: 'devtools',schema: {@@ -40,7 +40,7 @@ const startVideo = defineTool({},});-const stopVideo = defineTool({+const videoStop = defineTool({capability: 'devtools',schema: {@@ -73,7 +73,33 @@ const stopVideo = defineTool({},});+const videoChapter = defineTool({+ capability: 'devtools',++ schema: {+ name: 'browser_video_chapter',+ title: 'Video chapter',+ description: 'Add a chapter marker to the video recording. Shows a full-screen chapter card with blurred backdrop.',+ inputSchema: z.object({+ title: z.string().describe('Chapter title'),+ description: z.string().optional().describe('Chapter description'),+ duration: z.number().optional().describe('Duration in milliseconds to show the chapter card'),+ }),+ type: 'readOnly',+ },++ handle: async (context, params, response) => {+ const tab = context.currentTabOrDie();+ await tab.page.overlay.chapter(params.title, {+ description: params.description,+ duration: params.duration,+ });+ response.addTextResult(`Chapter '${params.title}' added.`);+ },+});+export default [- startVideo,- stopVideo,+ videoStart,+ videoStop,+ videoChapter,];diff --git a/packages/playwright-core/src/tools/cli-client/skill/SKILL.md b/packages/playwright-core/src/tools/cli-client/skill/SKILL.mdindex cac4db32a2..0515a03a55 100644--- a/packages/playwright-core/src/tools/cli-client/skill/SKILL.md+++ b/packages/playwright-core/src/tools/cli-client/skill/SKILL.md@@ -156,6 +156,7 @@ playwright-cli run-code --filename=script.jsplaywright-cli tracing-startplaywright-cli tracing-stopplaywright-cli video-start+playwright-cli video-chapter "Chapter Title" --description="Details" --duration=2000playwright-cli video-stop video.webm```diff --git a/packages/playwright-core/src/tools/cli-client/skill/references/video-recording.md b/packages/playwright-core/src/tools/cli-client/skill/references/video-recording.mdindex 0116ece790..de77603857 100644--- a/packages/playwright-core/src/tools/cli-client/skill/references/video-recording.md+++ b/packages/playwright-core/src/tools/cli-client/skill/references/video-recording.md@@ -11,10 +11,16 @@ playwright-cli open# Start recordingplaywright-cli video-start+# Add a chapter marker for section transitions+playwright-cli video-chapter "Getting Started" --description="Opening the homepage" --duration=2000+# Navigate and perform actionsplaywright-cli goto https://example.complaywright-cli snapshotplaywright-cli click e1++# Add another chapter+playwright-cli video-chapter "Filling Form" --description="Entering test data" --duration=2000playwright-cli fill e2 "test input"# Stop and savediff --git a/packages/playwright-core/src/tools/cli-daemon/commands.ts b/packages/playwright-core/src/tools/cli-daemon/commands.tsindex b9f3398c01..0d177522a7 100644--- a/packages/playwright-core/src/tools/cli-daemon/commands.ts+++ b/packages/playwright-core/src/tools/cli-daemon/commands.ts@@ -813,6 +813,21 @@ const videoStop = declareCommand({toolParams: ({ filename }) => ({ filename }),});+const videoChapter = declareCommand({+ name: 'video-chapter',+ description: 'Add a chapter marker to the video recording',+ category: 'devtools',+ args: z.object({+ title: z.string().describe('Chapter title.'),+ }),+ options: z.object({+ description: z.string().optional().describe('Chapter description.'),+ duration: numberArg.optional().describe('Duration in milliseconds to show the chapter card.'),+ }),+ toolName: 'browser_video_chapter',+ toolParams: ({ title, description, duration }) => ({ title, description, duration }),+});+const devtoolsShow = declareCommand({name: 'show',description: 'Show browser DevTools',@@ -1027,6 +1042,7 @@ const commandsArray: AnyCommandSchema[] = [tracingStop,videoStart,videoStop,+ videoChapter,devtoolsShow,pauseAt,resume,diff --git a/tests/mcp/cli-devtools.spec.ts b/tests/mcp/cli-devtools.spec.tsindex 1f8f82ff36..da81832301 100644--- a/tests/mcp/cli-devtools.spec.ts+++ b/tests/mcp/cli-devtools.spec.ts@@ -151,3 +151,11 @@ test('video-start-stop', async ({ cli, server }) => {const { output: videoStopOutput } = await cli('video-stop', '--filename=video.webm');expect(videoStopOutput).toContain(`### Result\n- [Video](video.webm)\n- [Video](video-1.webm)`);});++test('video-chapter', async ({ cli, server }) => {+ await cli('open', server.HELLO_WORLD);+ await cli('video-start');+ const { output } = await cli('video-chapter', 'Introduction', '--description=Welcome to the demo', '--duration=100');+ expect(output).toContain(`Chapter 'Introduction' added.`);+ await cli('video-stop');+});