{"record":{"id":"f2279e46991c6b79","repo":"microsoft/playwright","slug":"arguments-can-not-specify-page-to-be-opened-f2279e","errorCode":null,"errorMessage":"Arguments can not specify page to be opened","messagePattern":"Arguments can not specify page to be opened","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/webkit/webkit.ts","lineNumber":107,"sourceCode":"\n  override doRewriteStartupLog(logs: string): string {\n    if (logs.includes('Failed to open display') || logs.includes('cannot open display'))\n      logs = '\\n' + wrapInASCIIBox(kNoXServerRunningError, 1);\n    return logs;\n  }\n\n  override attemptToGracefullyCloseBrowser(transport: ConnectionTransport): void {\n    // Note that it's fine to reuse the transport, since our connection ignores kBrowserCloseMessageId.\n    transport.send({ method: 'Playwright.close', params: {}, id: kBrowserCloseMessageId });\n  }\n\n  override async defaultArgs(options: types.LaunchOptions, isPersistent: boolean, userDataDir: string): Promise<string[]> {\n    const { args = [], headless } = 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('-')))\n      throw new Error('Arguments can not specify page to be opened');\n    const isWSL = options.channel === 'webkit-wsl';\n    const webkitArguments = [isWSL ? '--remote-debugging-port=0' : '--inspector-pipe'];\n\n    if (isWSL) {\n      const wslExecutablePath = options.executablePath || registry.findExecutable('webkit-wsl')!.wslExecutablePath!;\n      webkitArguments.unshift(\n          '-d', kWSLDistribution,\n          '-u', kWSLUser,\n          '--cd', kWSLHome,\n          '--',\n          wslExecutablePath,\n      );\n    }\n\n    if (process.platform === 'win32' && !isWSL)\n      webkitArguments.push('--disable-accelerated-compositing');\n    if (headless)\n      webkitArguments.push('--headless');","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/webkit/webkit.ts#L89-L125","documentation":"WebKit's defaultArgs rejects any launch argument that does not start with '-' (i.e. a positional argument). WebKit treats the first positional argument as a URL/file to open at startup, which conflicts with Playwright's own page management and would open an uncontrolled page. Only flag-style arguments (--flag or -flag) are permitted.","triggerScenarios":"Passing a URL or file path as a positional item in launch({ args: [...] }) for a webkit launch, e.g. args: ['https://example.com'] or args: ['/path/to/file']. Any arg not starting with '-' triggers it.","commonSituations":"Copy-pasting chromium launch args (which historically tolerated a URL) into a webkit launch; trying to open a startup page via args instead of page.goto; passing a profile/data file as a positional arg.","solutions":["Remove the positional URL/path from args.","Open the page after launch with await page.goto(url).","If you need to pass a file, use the appropriate --flag (e.g. --user-data-dir, which itself has a separate guard)."],"exampleFix":"// before\nconst b = await webkit.launch({ args: ['https://example.com'] });\n\n// after\nconst b = await webkit.launch({ args: ['--disable-hardware-overlays'] });\nconst p = await b.newPage();\nawait p.goto('https://example.com');","handlingStrategy":"validation","validationCode":"function sanitizeArgs(args) {\n  const bad = (args || []).find(a => !String(a).startsWith('-'));\n  if (bad) throw new Error(`WebKit launch args must be flags; got positional: ${bad}`);\n}\nsanitizeArgs(launchOptions.args);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep launch args to --flag style only; never put a URL in args.","Open startup pages with page.goto after launch.","Don't reuse chromium's URL-in-args pattern with webkit."],"tags":["webkit","launch","args","validation"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}