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
test: fixed flaky connectOverCDP tests (#6436)
Max Schmittd902b06fd13d
diff --git a/src/server/browserType.ts b/src/server/browserType.tsindex 575e9ee25d..43dbe021ad 100644--- a/src/server/browserType.ts+++ b/src/server/browserType.ts@@ -186,7 +186,8 @@ export abstract class BrowserType extends SdkObject {await validateHostRequirements(this._registry, options.channel as registry.BrowserName);let wsEndpointCallback: ((wsEndpoint: string) => void) | undefined;- const wsEndpoint = options.useWebSocket ? new Promise<string>(f => wsEndpointCallback = f) : undefined;+ const shouldWaitForWSListening = options.useWebSocket || options.args?.some(a => a.startsWith('--remote-debugging-port'));+ const waitForWSEndpoint = shouldWaitForWSListening ? new Promise<string>(f => wsEndpointCallback = f) : undefined;// Note: it is important to define these variables before launchProcess, so that we don't get// "Cannot access 'browserServer' before initialization" if something went wrong.let transport: ConnectionTransport | undefined = undefined;@@ -242,8 +243,11 @@ export abstract class BrowserType extends SdkObject {kill};progress.cleanupWhenAborted(() => closeOrKill(progress.timeUntilDeadline()));+ let wsEndpoint: string | undefined;+ if (shouldWaitForWSListening)+ wsEndpoint = await waitForWSEndpoint;if (options.useWebSocket) {- transport = await WebSocketTransport.connect(progress, await wsEndpoint!);+ transport = await WebSocketTransport.connect(progress, wsEndpoint!);} else {const stdio = launchedProcess.stdio as unknown as [NodeJS.ReadableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.ReadableStream];transport = new PipeTransport(stdio[3], stdio[4]);