Skip to content

Feature Request: Add alert dialog detection and handling capabilities #529

@wzrazsh

Description

@wzrazsh

Is your feature request related to a problem? Please describe.

I'm working on a web automation project using Chrome DevTools MCP and encountered a significant limitation when dealing with JavaScript alert dialogs. When my automation script encounters an alert() call in the target page, the entire automation process gets blocked because there's no way to detect or handle these dialogs programmatically.

This is particularly problematic when testing web applications that use alert dialogs for user notifications or error messages. The automation script hangs indefinitely waiting for user interaction that will never happen in an automated environment.

Describe the solution you'd like

I would like to see the Chrome DevTools MCP add the following capabilities:

  1. Dialog Detection API: A way to detect when JavaScript dialogs (alert, confirm, prompt) appear on the page
    1. Dialog Handling Methods: Functions to programmatically accept, dismiss, or interact with these dialogs
    1. Event-based Notification: An event system that notifies when dialogs appear, allowing for immediate response
      Proposed API additions:
  • handle_dialog(action, promptText?) - Handle the currently active dialog
    • wait_for_dialog(timeout?) - Wait for a dialog to appear
      • Dialog event listeners for real-time detection
        This would enable robust automation workflows that can handle unexpected dialog interruptions gracefully.

Describe alternatives you've considered

Alternative approaches I've considered:

  1. Page-level JavaScript injection: Overriding window.alert, window.confirm, and window.prompt functions to intercept calls. However, this approach has limitations:
    • Doesn't work for dialogs triggered by browser extensions or system-level alerts
    • May interfere with the application's intended behavior
    • Requires careful implementation to avoid breaking existing functionality
  2. Polling-based detection: Periodically checking for dialog presence using JavaScript. This is unreliable and inefficient:
    • High resource consumption due to constant polling
    • May miss dialogs that appear and disappear quickly
    • Not a real-time solution
  3. Using external automation tools: Integrating with other browser automation frameworks that have dialog handling capabilities. This adds complexity:
    • Requires maintaining multiple tool integrations
    • Increases the overall system complexity
    • May introduce compatibility issues
      The native Chrome DevTools MCP integration would be the most elegant and reliable solution.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions