fix(browser): accept statement evaluate bodies

This commit is contained in:
Vincent Koc
2026-06-09 04:42:02 +09:00
parent 46f4db6bbd
commit b0998f7d15
11 changed files with 231 additions and 20 deletions

View File

@@ -194,11 +194,14 @@ openclaw browser select <ref> OptionA OptionB
openclaw browser fill --fields '[{"ref":"1","value":"Ada"}]'
openclaw browser wait --text "Done"
openclaw browser evaluate --fn '(el) => el.textContent' --ref <ref>
openclaw browser evaluate --fn 'const title = document.title; return title;'
openclaw browser evaluate --timeout-ms 30000 --fn 'async () => { await window.ready; return true; }'
```
Use `evaluate --timeout-ms <ms>` when the page-side function may need longer
than the default evaluate timeout.
`evaluate --fn` accepts a function source, an expression, or a statement body.
Statement bodies are wrapped as async functions, so use `return` for the value
you want back. Use `evaluate --timeout-ms <ms>` when the page-side function may
need longer than the default evaluate timeout.
Action responses return the current raw `targetId` after action-triggered page
replacement when OpenClaw can prove the replacement tab. Scripts should still