{"record":{"id":"9fa1e148e129c86c","repo":"microsoft/playwright","slug":"arguments-can-not-specify-page-to-be-opened-9fa1e1","errorCode":null,"errorMessage":"Arguments can not specify page to be opened","messagePattern":"Arguments can not specify page to be opened","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/chromium/chromium.ts","lineNumber":373,"sourceCode":"    const chromeArguments = this._innerDefaultArgs(options);\n    chromeArguments.push(`--user-data-dir=${userDataDir}`);\n    chromeArguments.push('--remote-debugging-pipe');\n    if (isPersistent)\n      chromeArguments.push('about:blank');\n    else\n      chromeArguments.push('--no-startup-window');\n    return chromeArguments;\n  }\n\n  private _innerDefaultArgs(options: types.LaunchOptions): string[] {\n    const { args = [] } = options;\n    const userDataDirArg = args.find(arg => arg.startsWith('--user-data-dir'));\n    if (userDataDirArg)\n      throw this._createUserDataDirArgMisuseError('--user-data-dir');\n    if (args.find(arg => arg.startsWith('--remote-debugging-pipe')))\n      throw new Error('Playwright manages remote debugging connection itself.');\n    if (args.find(arg => !arg.startsWith('-')))\n      throw new Error('Arguments can not specify page to be opened');\n    const chromeArguments = [...chromiumSwitches()];\n\n    // See https://issues.chromium.org/issues/40277080\n    chromeArguments.push('--enable-unsafe-swiftshader');\n\n    if (options.headless) {\n      chromeArguments.push('--headless');\n\n      chromeArguments.push(\n          '--hide-scrollbars',\n          '--mute-audio',\n          '--blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4',\n      );\n    }\n    if (options.chromiumSandbox !== true)\n      chromeArguments.push('--no-sandbox');\n    const proxy = options.proxyOverride || options.proxy;\n    if (proxy) {","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/chromium/chromium.ts#L355-L391","documentation":"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.","triggerScenarios":"chromium.launch({ args: ['https://example.com'] }) or ['about:blank'] passed as a positional value inside args.","commonSituations":"Migrating a Puppeteer/CLI Chrome invocation that opens a URL at startup. Wanting a default landing page and assuming args is the place.","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."],"exampleFix":"// before\nconst b = await chromium.launch({ args: ['https://example.com'] });\n// after\nconst b = await chromium.launch();\nconst p = await b.newPage();\nawait p.goto('https://example.com');","handlingStrategy":"validation","validationCode":"function sanitizeArgs(args: string[]): string[] {\n  const positional = args.filter(a => !a.startsWith('-'));\n  if (positional.length) throw new Error(`Positional args not allowed (open via page.goto instead): ${positional}`);\n  return args;\n}","typeGuard":"function argsAreFlagsOnly(args: string[]): boolean {\n  return args.every(a => a.startsWith('-'));\n}","tryCatchPattern":null,"preventionTips":["Open URLs with page.goto after launch, never via args.","Assert every entry in args starts with '--' in a preflight check."],"tags":["launch","chromium","args"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}