{"record":{"id":"8c13c05194c61aea","repo":"jackwener/OpenCLI","slug":"this-browser-session-does-not-support-javascript-d","errorCode":null,"errorMessage":"This browser session does not support JavaScript dialog handling","messagePattern":"This browser session does not support JavaScript dialog handling","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli.ts","lineNumber":2361,"sourceCode":"    }));\n\n  addBrowserTabOption(browser.command('keys').argument('<key>', 'Key to press (Enter, Escape, Tab, Control+a)'))\n    .description('Press keyboard key')\n    .action(browserAction(async (page, key) => {\n      await page.pressKey(key);\n      console.log(`Pressed: ${key}`);\n    }));\n\n  const browserDialog = browser\n    .command('dialog')\n    .description('Handle a blocking JavaScript alert/confirm/prompt dialog');\n\n  addBrowserTabOption(browserDialog.command('accept')\n    .option('--text <text>', 'Prompt text to submit for prompt() dialogs')\n    .description('Accept the currently open JavaScript dialog'))\n    .action(browserAction(async (page, opts?: { text?: string }) => {\n      if (!page.handleJavaScriptDialog) {\n        throw new Error('This browser session does not support JavaScript dialog handling');\n      }\n      try {\n        await page.handleJavaScriptDialog(true, opts?.text);\n      } catch (err) {\n        const message = getErrorMessage(err);\n        if (message.toLowerCase().includes('no dialog')) {\n          console.log(JSON.stringify({\n            error: {\n              code: 'no_javascript_dialog',\n              message: 'No JavaScript dialog is currently open.',\n            },\n          }, null, 2));\n          process.exitCode = EXIT_CODES.USAGE_ERROR;\n          return;\n        }\n        throw err;\n      }\n      console.log(JSON.stringify({ handled: true, action: 'accept', ...(opts?.text !== undefined && { text: opts.text }) }, null, 2));","sourceCodeStart":2343,"sourceCodeEnd":2379,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/src/cli.ts#L2343-L2379","documentation":"The `browser dialog accept` command requires `page.handleJavaScriptDialog`; the active browser session does not expose dialog handling, so the command throws this capability error. Native dialog interception needs protocol-level support not present in every backend.","triggerScenarios":"Running `browser dialog accept` (with optional `--text`) on a session whose page object lacks `handleJavaScriptDialog`.","commonSituations":"Backends without dialog auto-handling hooks (no Page.javascriptDialogOpening-style support); remote or restricted sessions where dialogs are auto-dismissed by the driver.","solutions":["Use a backend that supports dialog handling (Playwright/Puppeteer-based).","Configure the driver to auto-accept dialogs if manual handling is unsupported.","Avoid triggering dialogs (alert/confirm/prompt) in the page under test, or stub them via `browser eval` overriding window.alert/confirm/prompt."],"exampleFix":"// before\nbrowser --backend minimal dialog accept --text yes\n// after\nbrowser --backend playwright dialog accept --text yes","handlingStrategy":"type-guard","validationCode":"const page = await getBrowserPage();\nif (typeof page.handleJavaScriptDialog !== 'function') {\n  throw new Error('Session cannot handle dialogs; use a dialog-capable backend');\n}","typeGuard":"function supportsDialogs(page) {\n  return typeof page?.handleJavaScriptDialog === 'function';\n}","tryCatchPattern":"try {\n  await run(['browser', 'dialog', 'accept']);\n} catch (err) {\n  if (String(err.message).includes('does not support JavaScript dialog handling')) {\n    await run(['browser', 'eval', \"window.confirm=()=>true; window.prompt=()=>'yes'; window.alert=()=>{}\"]);\n  } else throw err;\n}","preventionTips":["Check handleJavaScriptDialog before dialog commands.","Stub alert/confirm/prompt in-page when the backend lacks dialog APIs.","Enable driver auto-accept where available.","Avoid pages with native dialogs on minimal backends."],"tags":["browser","cli","capability","dialogs"],"backgroundTag":"unsupported-browser-capability","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}