Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test(chromium): add failing test for connecting to a browser with pages (#6502)

Joel Einbinder2ea465bc82f5
diff --git a/tests/chromium/chromium.spec.ts b/tests/chromium/chromium.spec.ts
index 67caa90948..77e0adc22d 100644
--- a/tests/chromium/chromium.spec.ts
+++ b/tests/chromium/chromium.spec.ts
@@ -238,3 +238,31 @@ playwrightTest('should send extra headers with connect request', async ({browser
expect(request.headers['foo']).toBe('bar');
}
});
+
+playwrightTest('should report all pages in an existing browser', async ({ browserType, browserOptions }, testInfo) => {
+ playwrightTest.fail();
+ const port = 9339 + testInfo.workerIndex;
+ const browserServer = await browserType.launch({
+ ...browserOptions,
+ args: ['--remote-debugging-port=' + port]
+ });
+ try {
+ const cdpBrowser = await browserType.connectOverCDP({
+ endpointURL: `http://localhost:${port}/`,
+ });
+ const contexts = cdpBrowser.contexts();
+ expect(contexts.length).toBe(1);
+ for (let i = 0; i < 3; i++)
+ await contexts[0].newPage();
+ await cdpBrowser.close();
+
+ const cdpBrowser2 = await browserType.connectOverCDP({
+ endpointURL: `http://localhost:${port}/`,
+ });
+ expect(cdpBrowser2.contexts()[0].pages().length).toBe(3);
+
+ await cdpBrowser2.close();
+ } finally {
+ await browserServer.close();
+ }
+});