test: add a test for cdp w/ trace (#27410)

Closes https://github.com/microsoft/playwright/issues/27409
This commit is contained in:
Pavel Feldman 2023-10-03 13:00:35 -07:00 committed by GitHub
parent 2c56af3a3b
commit 13cca1db3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -446,3 +446,25 @@ test('emulate media should not be affected by second connectOverCDP', async ({ b
await browserServer.close();
}
});
test('should allow tracing over cdp session', async ({ browserType, mode }, testInfo) => {
const port = 9339 + testInfo.workerIndex;
const browserServer = await browserType.launch({
args: ['--remote-debugging-port=' + port]
});
try {
const cdpBrowser = await browserType.connectOverCDP({
endpointURL: `http://127.0.0.1:${port}/`,
});
const [context] = cdpBrowser.contexts();
await context.tracing.start({ screenshots: true, snapshots: true });
const page = await context.newPage();
await page.evaluate(() => 2 + 2);
const traceZip = testInfo.outputPath('trace.zip');
await context.tracing.stop({ path: traceZip });
await cdpBrowser.close();
expect(fs.existsSync(traceZip)).toBe(true);
} finally {
await browserServer.close();
}
});