Skip to content

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

fix(test): unflake waitForSelector when browser closes test (#767)

Joel Einbinder2b231c9e1b09
diff --git a/test/launcher.spec.js b/test/launcher.spec.js
index 3f836851a3..64e109f056 100644
--- a/test/launcher.spec.js
+++ b/test/launcher.spec.js
@@ -172,6 +172,10 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
const remote = await playwright.connect(browserApp.connectOptions());
const page = await remote.defaultContext().newPage();
const watchdog = page.waitForSelector('div', { timeout: 60000 }).catch(e => e);
+
+ // Make sure the previous waitForSelector has time to make it to the browser before we disconnect.
+ await page.waitForSelector('body');
+
await remote.disconnect();
const error = await watchdog;
expect(error.message).toContain('Protocol error');