hero_browser MCP — bugs and improvements from real-world SPA testing #86
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Used hero_browser MCP extensively for automated testing of a Dioxus WASM SPA (25+ page smoke test, API verification, auth flow testing). Found several bugs and missing features.
Bugs
1.
element_set_valuereuses variable nameelCalling
element_set_valuetwice on the same page throws:The injected JS declares
const el = ...— calling it twice redeclares in the same scope. Fix: wrap in IIFE or use unique variable names.2.
network_install/console_installreturn empty arraysInstalled both interceptors before navigation, waited 10+ seconds, but
network_requestsandconsole_messagesboth returned[]. WASM-generatedfetch()calls were not captured. This was the most limiting issue — had to work around with manualjs_evaluate+fetch()calls.Possible causes:
fetch()calls bypass the interceptor layer3.
page_screenshotreturns base64 inline (219K+ chars)Exceeds token limits for LLM context. The tool should either:
page_screenshot_save)page_screenshot_saveshould be preferredMissing Features
4. No
page_wait_for_idleorpage_wait_for_network_idleWASM SPAs need time to load (5-15s). Currently must use manual
sleepbetween every navigation. A "wait for network idle" or "wait for DOM to stabilize" primitive would be the single most impactful addition for SPA testing workflows.element_waitexists but doesn't help when you need to wait for the entire app to initialize.5. No top-level
awaitinjs_evaluateHad to use Promise chains with
window.__resultglobals, then a separatejs_evaluatecall to read results. Either support top-level await or addjs_evaluate_asyncthat returns the resolved Promise value.Skill Doc Recommendations
6. Pattern: WASM SPA automated testing
Document the pattern we developed:
fetch()injs_evaluate, store token inlocalStoragepage_navigate(full reload) orhistory.pushState+popstate(SPA routing)sleep(until #4 is fixed)js_evaluate(querySelector for errors, cards, content)7. Pattern: Framework-reactive input handling
element_set_valuedoesn't trigger Dioxus/React signal updates. Must use:This should be documented or handled automatically by
element_set_value.Priority
Signed-off-by: mik-tf
Implementation Summary — commit
88e2c4bAll 5 technical items from this issue have been addressed in a single squash commit on
developmentinhero_browser_mcp.Bug #1: Variable Name Collision in
element_set_value— FIXEDconst elredeclaration across multiple callsObject.getOwnPropertyDescriptorfor React/Dioxus signal compatibilityinputandchangeevents for framework reactivityBug #3: Screenshot Size Limitations — FIXED
page_screenshotnow auto-saves to/tmp/hero_browser-{timestamp}.pngwhen base64 exceeds 100KBFeature #5: Async JavaScript Evaluation — ADDED
js_evaluate_asynctool wraps expression in async IIFE with CDPawaitPromise: trueawait— e.g.return await fetch('/api/health').then(r => r.json())Feature #4: Network Idle Waiting — ADDED
page_wait_for_network_idletool — the single most impactful addition for SPA testingfetchandXMLHttpRequestcallsidle_ms(default: 500ms)Bug #2: Interceptor Navigation Loss — DOCUMENTED
window.__hero*) are destroyed on full page navigationnetwork_installandconsole_installmust be re-installed after full page navigationsFetch.enable/Runtime.consoleAPICalledevents) is a larger architectural change for a follow-upFiles Changed
crates/hero_browser_core/src/browser/page.rs— core fixes + new methodscrates/hero_browser_server/src/rpc_handler.rs— JSON-RPC handlerscrates/hero_browser_server/src/server.rs— MCP tool definitionscrates/hero_browser_server/src/openrpc.rs— OpenRPC specBrowse:
lhumina_code/hero_browser_mcp@88e2c4bClosing Summary
All items from this issue have been resolved in two commits on
developmentin hero_browser_mcp:Commit 1:
88e2c4b— Bug fixes + new featureselement_set_valuevariable collision/tmpwhen base64 > 100KBpage_wait_for_network_idlejs_evaluate_asyncwith CDPawaitPromiseawait fetch(), promises, complex returns all workCommit 2:
2d7c57c— Doctest fixeshero_browser_sdk→hero_browser_core)hero_browser_core/Makefilereferencing wrong crateTesting performed
cargo check— clean buildcargo test— 36/36 pass (0 failures)hero_browser_serverwith headless Chromium:element_set_valuecalled twice on same page (Bug #1 regression test)js_evaluate_asyncwith fetch, Promise, and complex returns (Feature #5)page_wait_for_network_idleafter navigation and fetch (Feature #4)page_screenshotauto-save on large page (Bug #3)Remaining for follow-up
Fetch.enableandRuntime.consoleAPICalledevents would survive page navigations but requires a larger architectural change to hero_browser_core.docs/once patterns are validated in more real-world usage.