Browser act 兼容写法:顶层 ref/targetId 也能被正确执行
问题/场景:代理把 `ref` 写在 act 顶层而非 `request.ref` 时,旧行为会报“ref is required”导致点击/输入失败。前置条件:使用 browser snapshot + act 自动化页面。实施步骤:升级到包含 PR #23075 的版本,并统一在自动化流程中保留 `targetId` 传递。关键命令/配置:`browser snapshot` 获取 ref/targetId,`browser act` 执行动作。验证:example.com 等简单页面点击输入不再因 ref 丢失失败。风险与边界:仍建议显式在 request 内带 ref,跨版本脚本兼容性更高。来源:PR #23075 + Browser docs。
GITHUBDiscovered 2026-02-22Author Remixer33
Prerequisites
- Browser tool is enabled and you are using snapshot→act interaction flow.
- Your deployment can upgrade OpenClaw to a build containing PR #23075.
Steps
- Capture a page snapshot and record both `ref` and `targetId` from the same tab context.
- Run one act click/type call using your existing script style (top-level or nested ref).
- If previously failing with `ref is required`, re-test after upgrade and compare logs.
- Normalize future scripts to pass stable refs + targetId explicitly for long flows.
Commands
openclaw browser --browser-profile openclaw snapshotopenclaw browser --browser-profile openclaw act --request '{"kind":"click","ref":"<ref>"}'openclaw gateway statusVerify
Act interactions succeed without `ref is required` rejection, and UI changes are visible in follow-up snapshot.
Caveats
- Mixed old/new nodes may behave differently; pin runtime version in distributed setups(需验证).
- Top-level merge is compatibility aid, not a replacement for clean request schema discipline.
Source attribution
This tip is aggregated from community/public sources and preserved with attribution.
Open original source ↗