Skip to content

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

chore: fix protocol-types-generator to work with new API

Andrey Lushnikovcd68619786ec
diff --git a/utils/protocol-types-generator/index.js b/utils/protocol-types-generator/index.js
index 4ff2d38440..5ca9ce37b4 100644
--- a/utils/protocol-types-generator/index.js
+++ b/utils/protocol-types-generator/index.js
@@ -10,11 +10,13 @@ async function generateChromiunProtocol(revision) {
if (revision.local && fs.existsSync(outputPath))
return;
const playwright = await require('../../index').chromium;
- const browser = await playwright.launch({ executablePath: revision.executablePath });
+ const browserServer = await playwright.launchServer({ executablePath: revision.executablePath });
+ const origin = browserServer.wsEndpoint().match(/ws:\/\/([0-9A-Za-z:\.]*)\//)[1];
+ const browser = await playwright.connect({ wsEndpoint: browserServer.wsEndpoint() });
const page = await browser.newPage();
await page.goto(`http://${origin}/json/protocol`);
const json = JSON.parse(await page.evaluate(() => document.documentElement.innerText));
- await browser.close();
+ await browserServer.kill();
fs.writeFileSync(outputPath, jsonToTS(json));
console.log(`Wrote protocol.ts to ${path.relative(process.cwd(), outputPath)}`);
}