Skip to content

UI Testing Tools

Three UI-testing tools are registered by default and use CDP directly rather than a Bridge method. fb2k_evaluate is a fourth, conditional tool registered only when FB2K_ENABLE_EVAL is 1 or true.

fb2k_screenshot

Captures the WebView2 page and returns MCP image content containing base64 PNG data.

  • Transport: Page.captureScreenshot (CDP)
ParameterTypeRequiredDescription
fullPagebooleanNoWhen true, temporarily sizes the viewport to the measured content before capture; omission captures the current viewport

Result: MCP image content with MIME type image/png.

Warm-up behavior

Every successful CDP connection attempts a best-effort 1×1 PNG capture before a real screenshot. Actual capture time depends on the host, page, and rendering state; no fixed latency is guaranteed.

fb2k_dom_snapshot

Gets a simplified DOM tree generated by evaluating a page-walking function.

  • Parameters: none
  • Transport: Runtime.evaluate (CDP)

Result format:

Each line contains tag#id.class "textContent"; indentation represents nesting. Text is included only for elements with a single text-node child and is truncated to 80 characters.

fb2k_evaluate

Executes a JavaScript expression in the WebView2 page.

  • Registration: conditional on FB2K_ENABLE_EVAL=1 or FB2K_ENABLE_EVAL=true
  • Transport: Runtime.evaluate (CDP)
ParameterTypeRequiredDescription
expressionstringYesJavaScript expression to evaluate

Security boundary

This tool is disabled by default because it can run arbitrary JavaScript in the page. Enable it only for a trusted development or debugging session.

fb2k_console_messages

Gets up to the last 100 entries from window.__fb2kMcpConsoleLogs.

  • Parameters: none
  • Transport: Runtime.evaluate (CDP)

Example result:

[info] Page loaded [warn] Missing artwork for track 3 [error] Failed to connect to lyrics server