diff --git a/bin/playwright-server.js b/bin/playwright-server.js index 597e5bd..c62e87d 100644 --- a/bin/playwright-server.js +++ b/bin/playwright-server.js @@ -318,7 +318,8 @@ class PlaywrightServer extends BaseHandler { const attached = await chromium.connectOverCDP(endpointURL, options || {}); const browserId = this.generateId('browser'); this.browsers.set(browserId, attached); - const context = await attached.newContext(); + const existingContexts = attached.contexts(); + const context = existingContexts.length > 0 ? existingContexts[0] : await attached.newContext(); const contextId = this.generateId('context'); this.contexts.set(contextId, { context, browserId, id: contextId }); return { browserId, defaultContextId: contextId, version: attached.version() };