chore: fix operation over cdp (#440)

Ref https://github.com/microsoft/playwright-mcp/issues/439
This commit is contained in:
Pavel Feldman
2025-05-17 08:20:22 -07:00
committed by GitHub
parent c2b7fb29de
commit 1318e39fac
4 changed files with 46 additions and 53 deletions

View File

@@ -14,8 +14,6 @@
* limitations under the License.
*/
import { chromium } from 'playwright';
import { test, expect } from './fixtures.js';
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
@@ -139,17 +137,14 @@ test('close tab', async ({ client }) => {
\`\`\``);
});
test('reuse first tab when navigating', async ({ startClient, cdpEndpoint, server }) => {
server.setContent('/', `<title>Title</title><body>Body</body>`, 'text/html');
test('reuse first tab when navigating', async ({ startClient, cdpServer, server }) => {
const browserContext = await cdpServer.start();
const pages = browserContext.pages();
const browser = await chromium.connectOverCDP(await cdpEndpoint());
const [context] = browser.contexts();
const pages = context.pages();
const client = await startClient({ args: [`--cdp-endpoint=${await cdpEndpoint()}`] });
const client = await startClient({ args: [`--cdp-endpoint=${cdpServer.endpoint}`] });
await client.callTool({
name: 'browser_navigate',
arguments: { url: server.PREFIX },
arguments: { url: server.HELLO_WORLD },
});
expect(pages.length).toBe(1);