microsoft/playwright · error · Error
Arguments can not specify page to be opened
Error message
Arguments can not specify page to be opened
What it means
Thrown in Chromium._innerDefaultArgs when any element of args does not start with '-' (i.e. it is a positional argument, typically a URL). Playwright controls the initial pages via its own protocol; letting the browser open an arbitrary page would race with context setup, so positional args are forbidden.
Source
Thrown at packages/playwright-core/src/server/chromium/chromium.ts:373
const chromeArguments = this._innerDefaultArgs(options);
chromeArguments.push(`--user-data-dir=${userDataDir}`);
chromeArguments.push('--remote-debugging-pipe');
if (isPersistent)
chromeArguments.push('about:blank');
else
chromeArguments.push('--no-startup-window');
return chromeArguments;
}
private _innerDefaultArgs(options: types.LaunchOptions): string[] {
const { args = [] } = options;
const userDataDirArg = args.find(arg => arg.startsWith('--user-data-dir'));
if (userDataDirArg)
throw this._createUserDataDirArgMisuseError('--user-data-dir');
if (args.find(arg => arg.startsWith('--remote-debugging-pipe')))
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');
const chromeArguments = [...chromiumSwitches()];
// See https://issues.chromium.org/issues/40277080
chromeArguments.push('--enable-unsafe-swiftshader');
if (options.headless) {
chromeArguments.push('--headless');
chromeArguments.push(
'--hide-scrollbars',
'--mute-audio',
'--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4',
);
}
if (options.chromiumSandbox !== true)
chromeArguments.push('--no-sandbox');
const proxy = options.proxyOverride || options.proxy;
if (proxy) {View on GitHub (pinned to c8fc3bf8d3)
Solutions
- Open pages through the API: after launch, do page.goto('https://example.com').
- For persistent contexts that need a startup URL, use context.pages() then goto, or pass the URL to the test runner's baseURL/page.goto.
- Keep args limited to '--flag' style switches.
Example fix
// before
const b = await chromium.launch({ args: ['https://example.com'] });
// after
const b = await chromium.launch();
const p = await b.newPage();
await p.goto('https://example.com'); Defensive patterns
Strategy: validation
Validate before calling
function sanitizeArgs(args: string[]): string[] {
const positional = args.filter(a => !a.startsWith('-'));
if (positional.length) throw new Error(`Positional args not allowed (open via page.goto instead): ${positional}`);
return args;
} Type guard
function argsAreFlagsOnly(args: string[]): boolean {
return args.every(a => a.startsWith('-'));
} Prevention
- Open URLs with page.goto after launch, never via args.
- Assert every entry in args starts with '--' in a preflight check.
When it happens
Trigger: chromium.launch({ args: ['https://example.com'] }) or ['about:blank'] passed as a positional value inside args.
Common situations: Migrating a Puppeteer/CLI Chrome invocation that opens a URL at startup. Wanting a default landing page and assuming args is the place.
Related errors
- Playwright manages remote debugging connection itself.
- Arguments can not specify page to be opened
- Unsupported ${this._name} channel "${options.channel}"
- Arguments can not specify page to be opened
- PDF creation is only working with Chromium
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/9fa1e148e129c86c.
Report an issue: GitHub.