Skip to content

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

test: fix webview2 globalSetup (#21220)

Max Schmitt960c7ebb7ec6
diff --git a/tests/webview2/globalSetup.ts b/tests/webview2/globalSetup.ts
index 6b815a5891..4ac3b9e0ba 100644
--- a/tests/webview2/globalSetup.ts
+++ b/tests/webview2/globalSetup.ts
@@ -31,7 +31,9 @@ export default async () => {
resolve();
}));
const browser = await playwright.chromium.connectOverCDP(`http://127.0.0.1:${cdpPort}`);
- const chromeVersion = await browser.contexts()[0].pages()[0].evaluate(() => navigator.userAgent.match(/Chrome\/(.*?) /)[1]);
+ const page = browser.contexts()[0].pages()[0];
+ await page.goto('data:text/html,');
+ const chromeVersion = await page.evaluate(() => navigator.userAgent.match(/Chrome\/(.*?) /)[1]);
process.env.PWTEST_WEBVIEW2_CHROMIUM_VERSION = chromeVersion;
await browser.close();
childProcess.spawnSync(`taskkill /pid ${spawnedProcess.pid} /T /F`, { shell: true });