Fix browser get selector examples (#976)

* Fix browser get selector examples

* Add docs regression test for browser get selector examples
This commit is contained in:
Lawrence Chen 2026-03-05 20:51:30 -08:00 committed by GitHub
parent b848d60b0d
commit f3f17cfc38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 42 additions and 2 deletions

View file

@ -11,7 +11,7 @@ This maps common `agent-browser` usage to `cmux browser` usage.
- `agent-browser fill <ref> <text>` -> `cmux browser <surface> fill <ref> <text>`
- `agent-browser type <ref> <text>` -> `cmux browser <surface> type <ref> <text>`
- `agent-browser select <ref> <value>` -> `cmux browser <surface> select <ref> <value>`
- `agent-browser get text <ref>` -> `cmux browser <surface> get text <ref>`
- `agent-browser get text <ref>` -> `cmux browser <surface> get text <ref-or-selector>`
- `agent-browser get url` -> `cmux browser <surface> get url`
- `agent-browser get title` -> `cmux browser <surface> get title`
@ -34,7 +34,13 @@ cmux browser <surface> get url|title
```bash
cmux browser <surface> snapshot --interactive
cmux browser <surface> snapshot --interactive --compact --max-depth 3
cmux browser <surface> get text|html|value|attr|count|box|styles ...
cmux browser <surface> get text body
cmux browser <surface> get html body
cmux browser <surface> get value "#email"
cmux browser <surface> get attr "#email" --attr placeholder
cmux browser <surface> get count ".row"
cmux browser <surface> get box "#submit"
cmux browser <surface> get styles "#submit" --property color
cmux browser <surface> eval '<js>'
```

View file

@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""Regression checks for cmux-browser get selector examples."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from cmux import cmuxError
ROOT = Path(__file__).resolve().parents[1]
COMMANDS = ROOT / "skills/cmux-browser/references/commands.md"
def _must(cond: bool, msg: str) -> None:
if not cond:
raise cmuxError(msg)
def main() -> int:
commands = COMMANDS.read_text(encoding="utf-8")
_must("`agent-browser get text <ref>` -> `cmux browser <surface> get text <ref-or-selector>`" in commands, "Expected get text mapping to mention selector support")
_must("cmux browser <surface> get text body" in commands, "Expected get text body example")
_must("cmux browser <surface> get html body" in commands, "Expected get html body example")
_must('cmux browser <surface> get value "#email"' in commands, "Expected get value selector example")
_must('cmux browser <surface> get attr "#email" --attr placeholder' in commands, "Expected get attr selector example")
_must("cmux browser <surface> get text|html|value|attr|count|box|styles ..." not in commands, "Unexpected bare get example block")
return 0
if __name__ == "__main__":
raise SystemExit(main())