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
Firefox launch arguments must all be flags (start with `-`). A bare argument would be interpreted by Firefox as a URL/file to open, which conflicts with Playwright's BiDi-controlled session. `defaultArgs` rejects any arg not starting with `-`.
Source
Thrown at packages/playwright-core/src/server/bidi/bidiFirefox.ts:112
override supportsPipeTransport(): boolean {
return false;
}
override async prepareUserDataDir(options: types.LaunchOptions, userDataDir: string): Promise<void> {
await createProfile({
path: userDataDir,
preferences: options.firefoxUserPrefs || {},
});
}
override async defaultArgs(options: types.LaunchOptions, isPersistent: boolean, userDataDir: string) {
const { args = [], headless } = options;
const userDataDirArg = args.find(arg => arg.startsWith('-profile') || arg.startsWith('--profile'));
if (userDataDirArg)
throw this._createUserDataDirArgMisuseError('--profile');
if (args.find(arg => !arg.startsWith('-')))
throw new Error('Arguments can not specify page to be opened');
const firefoxArguments = ['--remote-debugging-port=0'];
if (headless)
firefoxArguments.push('--headless');
else
firefoxArguments.push('--foreground');
firefoxArguments.push(`--profile`, userDataDir);
firefoxArguments.push(...args);
return firefoxArguments;
}
override async waitForReadyState(options: types.LaunchOptions, browserLogsCollector: RecentLogsCollector): Promise<{ wsEndpoint?: string }> {
const result = new ManualPromise<{ wsEndpoint?: string }>();
browserLogsCollector.onMessage(message => {
const match = message.match(/WebDriver BiDi listening on (ws:\/\/.*)$/);
if (match)
result.resolve({ wsEndpoint: match[1] + '/session' });
});
return result;View on GitHub (pinned to c8fc3bf8d3)
Solutions
- Remove URLs/bare values from `args`; navigate with `page.goto()` after launch
- Use `baseURL` + `page.goto('/')` for startup navigation
- If you need a profile, omit it — Playwright manages `--profile` itself
Example fix
// before
const b = await firefox.launch({ args: ['https://example.com'] });
// after
const b = await firefox.launch();
const p = await b.newPage();
await p.goto('https://example.com'); Defensive patterns
Strategy: validation
Validate before calling
function sanitizeFirefoxArgs(args: string[]): string[] {
const bad = args.filter(a => !a.startsWith('-'));
if (bad.length) {
throw new Error(
`Firefox launch args must be flags (start with '-'). Non-flag values (${bad.join(', ')}) are not supported; use page.goto() instead.`
);
}
return args;
}
await firefox.launch({ args: sanitizeFirefoxArgs(rawArgs) }); Prevention
- Don't reuse Chromium launch arg lists verbatim with Firefox
- Navigate via page.goto() / baseURL, never via launch args
- Let Playwright manage --profile
When it happens
Trigger: `firefox.launch({ args: ['https://example.com'] })`, `args: ['about:blank']`, or any non-flag value in launch args.
Common situations: Copy-pasting Chromium launch conventions (where a URL sometimes works) to Firefox; trying to open a startup URL via args instead of `page.goto`; passing profile paths without the `-profile` prefix.
Related errors
- Cannot launch Firefox with relative home directory. Did you
- Playwright manages remote debugging connection itself.
- Arguments can not specify page to be opened
- Arguments can not specify page to be opened
- JSHandle is not a DOM node handle
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/42d4d999f59277a8.
Report an issue: GitHub.