Skip to content

fix: _open_chrome_inspect() fails on Windows — webbrowser.open() can't handle chrome:// protocol #290

@Wievondii

Description

@Wievondii

Bug

_open_chrome_inspect() in admin.py uses webbrowser.open(url, new=2) on Windows to open chrome://inspect/#remote-debugging. Windows does not support the chrome:// protocol via webbrowser.open() — it triggers a "Get an app to open this" Microsoft Store dialog instead of opening the URL in Chrome.

macOS correctly uses AppleScript to tell Chrome to open the URL, but Windows has no equivalent handling.

Steps to reproduce

  1. On Windows, run browser-harness --setup when Chrome is running but remote debugging is not enabled on the current profile
  2. The setup flow calls _open_chrome_inspect() to open chrome://inspect/#remote-debugging
  3. Windows shows "Get an app to open this chrome link" dialog instead of opening the page in Chrome

Expected behavior

chrome://inspect/#remote-debugging should open in the running Chrome instance.

Fix

Add Windows-specific handling that directly invokes the Chrome executable with the URL as an argument, similar to the macOS AppleScript approach:

elif platform.system() == "Windows":
    for candidate in (
        Path(os.environ.get("PROGRAMFILES", "")) / "Google/Chrome/Application/chrome.exe",
        Path(os.environ.get("PROGRAMFILES(X86)", "")) / "Google/Chrome/Application/chrome.exe",
        Path(os.environ.get("LOCALAPPDATA", "")) / "Google/Chrome/Application/chrome.exe",
    ):
        if candidate.exists():
            try:
                subprocess.Popen([str(candidate), url])
                return
            except Exception:
                pass

Environment

  • OS: Windows 11
  • Chrome: latest
  • browser-harness: 0.1.0 (git)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions