From dcaaf68f1ad21750e08ade13043c022d538c5b33 Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Wed, 14 Jan 2026 12:09:34 +0100 Subject: [PATCH] Make wsUrl optional in getCDPSessionForPage, default to getCdpUrl() --- playwriter/src/cdp-session.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/playwriter/src/cdp-session.ts b/playwriter/src/cdp-session.ts index 14e9abd..4edda2e 100644 --- a/playwriter/src/cdp-session.ts +++ b/playwriter/src/cdp-session.ts @@ -2,6 +2,7 @@ import WebSocket from 'ws' import type { Page } from 'playwright-core' import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js' import type { CDPResponseBase, CDPEventBase } from './cdp-types.js' +import { getCdpUrl } from './utils.js' /** * Common interface for CDP sessions that works with both our CDPSession @@ -162,8 +163,9 @@ export class CDPSession implements ICDPSession { } } -export async function getCDPSessionForPage({ page, wsUrl }: { page: Page; wsUrl: string }): Promise { - const ws = new WebSocket(wsUrl) +export async function getCDPSessionForPage({ page, wsUrl }: { page: Page; wsUrl?: string }): Promise { + const resolvedWsUrl = wsUrl || getCdpUrl() + const ws = new WebSocket(resolvedWsUrl) await new Promise((resolve, reject) => { ws.on('open', resolve)