Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: throw when using headless-shell with headed mode (#33292)
Max Schmitt5c0fdfed50d3
diff --git a/packages/playwright-core/src/server/chromium/chromium.ts b/packages/playwright-core/src/server/chromium/chromium.tsindex 30bd2871b8..023ee0b7d1 100644--- a/packages/playwright-core/src/server/chromium/chromium.ts+++ b/packages/playwright-core/src/server/chromium/chromium.ts@@ -294,6 +294,8 @@ export class Chromium extends BrowserType {throw new Error('Playwright manages remote debugging connection itself.');if (args.find(arg => !arg.startsWith('-')))throw new Error('Arguments can not specify page to be opened');+ if (!options.headless && options.channel === 'chromium-headless-shell')+ throw new Error('Cannot launch headed Chromium with `chromium-headless-shell` channel. Consider using regular Chromium instead.');const chromeArguments = [...chromiumSwitches];if (os.platform() === 'darwin') {diff --git a/tests/library/chromium/launcher.spec.ts b/tests/library/chromium/launcher.spec.tsindex 8758e63c12..d891d99481 100644--- a/tests/library/chromium/launcher.spec.ts+++ b/tests/library/chromium/launcher.spec.ts@@ -184,3 +184,10 @@ it('should not create pages automatically', async ({ browserType }) => {await browser.close();expect(targets.length).toBe(0);});++it('should throw helpful error when launching chromium-headless-shell channel as headed', async ({ browserType, channel }) => {+ it.skip(channel !== 'chromium-headless-shell');+ await expect(browserType.launch({ channel: 'chromium-headless-shell', headless: false })).rejects.toThrow(+ 'Cannot launch headed Chromium with `chromium-headless-shell` channel. Consider using regular Chromium instead.'+ );+});