chore: allow reusing tab over cdp (#170)

Fixes https://github.com/microsoft/playwright-mcp/issues/164
This commit is contained in:
Pavel Feldman
2025-04-14 16:39:58 -07:00
committed by GitHub
parent e729494bd9
commit 606b898a71
7 changed files with 63 additions and 21 deletions

View File

@@ -35,3 +35,27 @@ Navigated to data:text/html,<html><title>Title</title><body>Hello, world!</body>
`
);
});
test('cdp server reuse tab', async ({ cdpEndpoint, startClient }) => {
const client = await startClient({ args: [`--cdp-endpoint=${cdpEndpoint}`] });
expect(await client.callTool({
name: 'browser_click',
arguments: {
element: 'Hello, world!',
ref: 'f0',
},
})).toHaveTextContent(`Error: No current snapshot available. Capture a snapshot of navigate to a new location first.`);
expect(await client.callTool({
name: 'browser_snapshot',
arguments: {},
})).toHaveTextContent(`
- Page URL: data:text/html,hello world
- Page Title:
- Page Snapshot
\`\`\`yaml
- text: hello world
\`\`\`
`);
});