Return INVALID_ARGUMENT for unknown --screenshot-format values instead
of silently coercing to PNG, preventing mismatched artifacts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Hidden elements should still report their text content (e.g. "Item Hidden").
Removes the isVisible guard on text extraction so all matched elements
include their text regardless of visibility state.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Let querySelectorAll exceptions propagate to Runtime.evaluate's
exceptionDetails so the Rust-level JS_EXCEPTION guard fires correctly.
Fixes P1 blocker from Chopper review.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds observation/query.rs with 4 subcommand modes per §10.7:
- one: exactly 1 match or ELEMENT_NOT_FOUND/MULTIPLE_MATCHES
- all: returns all matches (0+ is success)
- nth: 1-based index or INDEX_OUT_OF_RANGE
- count: returns match count only (0+ is success)
Extended CSS selectors: :visible, :contains(), :has(), :enabled,
:disabled, :checked. Real nth-of-type DOM position computation.
Registered in cli.rs, action.rs, router.rs, output.rs, mod.rs.
Added fatal_with_details() helper to ActionResult.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: add agent-friendly help messages with examples to all CLI commands
Add after_help with usage examples and contextual notes to all 35 browser
commands, plus top-level help and browser group help screens. Follows
progressive disclosure: top-level → browser group → per-command --help.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Add observation commands for element description (role, name, tag,
attributes, state, nearby context) and element state (visible, enabled,
checked, focused, editable, selected). Both commands follow the
established observation pattern with CDP Runtime.callFunctionOn,
exceptionDetails → JS_EXCEPTION handling, and proper error envelopes.
All 17 E2E tests in describe_state.rs pass.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Drive-by fixes for lint issues inherited from release/1.0.0 base branch:
- scroll.rs: cargo fmt formatting
- hover.rs: collapse nested if-let (clippy collapsible_if)
Unblocks CI lint check for PR #360.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add monkeypatch-based E2E tests for all three observation commands
(attrs, box, styles) to verify that when Runtime.callFunctionOn returns
exceptionDetails, the CLI surfaces ok=false / error.code=JS_EXCEPTION
instead of silently returning empty {}.
- styles_js_exception_propagated: patches window.getComputedStyle to throw
- box_js_exception_propagated: patches element.getBoundingClientRect to throw
- attrs_js_exception_propagated: patches element.attributes getter to throw
E2E suite now 13/13 green.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verifies browser box on off-screen element returns coordinates
without changing window.scrollY (read command must be stateless).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
P1: attrs.rs, box.rs, styles.rs now check CDP exceptionDetails after
Runtime.callFunctionOn — JS exceptions return JS_EXCEPTION error
instead of being silently swallowed as empty success.
P2: box.rs removes scroll_into_view before getBoundingClientRect —
read commands must be stateless with no viewport side-effects.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add full implementation of `browser screenshot <path>` (§10.2) including:
- Core viewport screenshot via CDP Page.captureScreenshot
- --full flag for full-page capture using Page.getLayoutMetrics
- --selector flag to clip to a specific CSS element region
- --screenshot-format (png/jpeg) with extension inference
- --screenshot-quality for JPEG compression control
- --annotate flag that overlays numbered labels on interactive elements
and returns annotations metadata (ref, number, role, name, box)
Expand RefCache to store role/name (RefEntry) so annotate can build
complete annotation metadata without re-fetching the AX tree.
Includes 11 unit tests and 12 E2E tests covering happy paths
(json/text/jpeg/full/selector/annotate) and error paths
(invalid path, session/tab not found, missing args).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: add hover command cases
* test: add hover text error coverage
* feat: implement browser hover command
Add the `browser hover <selector>` command. Resolves the selector to a
DOM node via the shared element module, then dispatches mouseenter,
mouseover, and mousemove events via Runtime.callFunctionOn for reliable
hover semantics in headless Chrome. Wired up across CLI parsing, action
enum, router, and output formatting.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add focus command cases
* feat: implement browser focus command
Add the `browser focus <selector>` command. Resolves the selector via
the shared element module, uses DOM.focus to set focus on the target,
and compares pre/post active element by JS reference identity (===) to
correctly report focus_changed even for anonymous elements. Wired up
across CLI parsing, action enum, router, and output formatting.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add press command cases
* feat: implement browser press command
Add the `browser press <key-or-chord>` command. Parses single keys and
chord combinations (e.g. Control+A, Shift+Tab), validates modifier
segments, and dispatches keyDown/keyUp via CDP Input.dispatchKeyEvent
with the appropriate modifiers bitmask. Wired up across CLI parsing,
action enum, router, and output formatting.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add drag command cases
* feat: implement browser drag command
Adds drag-and-drop via CDP Input.dispatchMouseEvent sequence:
mousePressed at source → mouseMoved along path → mouseReleased at
destination. Destination accepts either a selector or x,y coordinates.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: drag dispatch via viewport resize + CDP Input events
CDP Input.dispatchMouseEvent requires elements to be within the visible
viewport. The drag fixture positions elements at top:780px which exceeds
the default headless Chrome viewport (~469px). Fix by temporarily
enlarging the viewport via Emulation.setDeviceMetricsOverride before
the drag sequence, then clearing the override after completion.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: resize viewport before resolving drag coordinates
Move Emulation.setDeviceMetricsOverride before element resolution so
coordinates are captured under the final viewport. Avoids stale
coordinates on responsive pages where a post-resolution resize could
shift element positions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: preserve viewport width during drag, only expand height if needed
Read the current viewport dimensions and only override if the height is
too short for the drag endpoints. Width is preserved to avoid flipping
responsive breakpoints or triggering resize handlers. The override is
skipped entirely when the viewport is already tall enough.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add upload command cases
* feat: implement browser upload command
Adds `browser upload <selector> <file...> --session --tab` which sets
files on a file input via CDP DOM.setFileInputFiles. Validates that all
paths are absolute, resolves the target node, and returns a value_summary
with file list and count. All 10 e2e tests pass.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: require at least one file path in browser upload
Adds `#[arg(required = true, num_args = 1..)]` to the `files` field so
Clap rejects invocations with zero files at parse time, matching the
spec's `<file...>` contract. Adds a unit test for the missing-files case.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add eval command cases
* fix: update browser eval to return typed value, type, and preview per spec
- Return `data.value` as typed JSON (number/bool/string) instead of
always stringifying
- Add `data.type` (JS type from CDP) and `data.preview` (string repr)
- Return null context for SESSION_NOT_FOUND
- Extract exception description for better EVAL_FAILED error messages
- Update cloud eval tests to assert typed values
All 11 eval tests pass (8 interaction + 3 cloud).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add eval context coverage
* fix: include tab URL and title in browser eval context
Fetches the current page URL and title after eval execution and returns
them in the response context, matching the spec contract for tab-scoped
commands. Tests now assert context.url and context.title are present.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add mouse-move command cases
* feat: implement browser mouse-move command
Adds `browser mouse-move <x,y> --session --tab` which dispatches a CDP
Input.dispatchMouseEvent (mouseMoved) at the given coordinates. Parses
and validates x,y format, tracks url/focus changes, returns context with
tab URL and title. All 8 e2e tests pass.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add cursor-position command cases
* test: add cursor-position text status check
* feat: implement browser cursor-position command
Adds cursor-position command that returns the last known cursor position
for a tab. Position is stored in SessionRegistry when mouse-move is
executed, using the existing session_id\0tab_id composite key pattern.
Wired in all 6 registration points: mod.rs, action.rs, cli.rs (enum +
to_action + command_name + context), router.rs, output.rs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: track cursor position in click, drag, and hover commands
cursor-position was only updated by mouse-move. Now click, drag, and
hover also store the final pointer coordinates in SessionRegistry so
that cursor-position reflects the true position after any mouse action.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add regression test for click -> cursor-position tracking
Verifies that cursor-position reflects coordinates from a click action,
not just mouse-move. Covers the contract gap identified in review.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add scroll command cases
* test: add scroll changed field checks
* feat: implement browser scroll commands
Adds scroll command with three subcommand forms:
- Directional: scroll up|down|left|right <pixels>
- Edge: scroll top|bottom
- Into-view: scroll into-view <selector> [--align start|center|end|nearest]
All forms support --container for scrolling within a specific element.
Tracks scroll_changed, url_changed, focus_changed in response data.
Wired in all 6 registration points.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add scroll xpath selector coverage
* fix: use resolved CDP nodes for scroll selectors instead of querySelector
Refactored scroll to resolve selectors via element::resolve_node +
DOM.resolveNode → objectId, then use Runtime.callFunctionOn for all
scroll operations. This correctly supports CSS, XPath, and @eN selectors
per the API contract, instead of raw querySelector which only handles CSS.
Added DOM.getDocument init call to ensure XPath DOM.requestNode works.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
cdp_navigate now checks both CDP-level errors (response.error) and
Page.navigate-level errors (result.errorText). Previously it returned
Ok(()) for any response with matching id, silently ignoring navigation
failures like invalid schemes or net errors.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Migrate from old SessionGuard::new() (kill-daemon) to new
SessionGuard::new(&sid) (per-session cleanup). Error-path tests
that don't create sessions no longer need a guard.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- SoloEnv::Drop: wait for daemon exit + clean up daemon.sock/ready/pid
files (SIGKILL prevents daemon's own cleanup)
- cloud_crash_recovery_endpoint_gone: add real assertions to all branches
(was a no-op test that could never fail)
- Restore cloud_crash_recovery_reconnect test (was deleted in refactor)
- Add SessionGuard to lifecycle_close_s1t2 and lifecycle_double_close
tests (prevent session leak on panic)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract common helpers to harness.rs (assert_meta, assert_error_envelope,
assert_tab_id, start_session, close_session, new_tab_json, etc.)
- Add local HTTP server to eliminate external network dependency
- Introduce SoloEnv for tests needing isolated ACTIONBOOK_HOME
- Replace fixed sleep(500ms) with per-test session isolation
- Fix TempDir leak in cloud_mode (ChromeGuard now owns TempDir)
- Add PID to unique_session IDs to prevent cross-run collisions
- HTTP server: thread-per-connection + Connection: close header
- Restore all cloud_mode tests (groups 5b-15) that were missing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Switch collect_parents() from DOM.getAncestors/DOM.describeNode
(unreliable across Chrome versions) to Accessibility.getPartialAXTree
with fetchRelatives:true — single CDP call, proven to work, no DOM
tree tracking dependency
- Add allow_hyphen_values=true to coordinates positional so negative
coordinates like -9999,-9999 parse correctly instead of being treated
as flags
- All 10 inspect_point E2E tests now pass locally
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DOM.describeNode only returns parentId when the DOM tree is tracked.
Call DOM.getDocument upfront and use nodeId (from getNodeForLocation)
instead of backendNodeId for reliable parent chain traversal.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace DOM.getAncestors with iterative DOM.describeNode for broader
Chrome version support in collect_parents()
- Add allow_hyphen_values for negative coordinates
- Fix rustfmt in click.rs (from PR #351 merge)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
B1 (context.url + text header URL not pinned):
Already present in current head — context.url is_string() asserted in
JSON happy-path; header contains "about:blank" asserted in text happy-path.
B2 (parent ordering not verifiable):
- Add aria-label="Inner Container" and aria-label="Outer Container" to
fixture divs so parents are distinguishable in the AX tree
- Replace weak "refs must be distinct" assertion with exact name checks:
parents[0].name == "Inner Container" (nearest parent)
parents[1].name == "Outer Container" (grandparent)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CDP flow:
1. DOM.getNodeForLocation(x, y) → backendNodeId of hit element
2. Accessibility.getPartialAXTree(backendNodeId) → role + name
3. RefCache.get_or_assign(backendNodeId) → stable selector ref (e1, e2...)
4. When no element at coords → data.element = null
5. --parent-depth N: DOM.describeNode → DOM.getAncestors → collect first N
element ancestors, each with role/name/selector ref
data contract:
- data.point: {x, y} (echoes requested coordinates)
- data.element: {role, name, selector} or null
- data.parents: [{role, name, selector}] nearest-first, up to parent_depth
- context.url populated via __ctx_url sideband
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Session/tab error-path tests need get_cdp_and_target to run before
the NOT_IMPLEMENTED return, otherwise they get NOT_IMPLEMENTED instead
of SESSION_NOT_FOUND / TAB_NOT_FOUND.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address Robin-Cx review (#116):
- Replace actionbook.dev with about:blank + injected DOM fixture
- Pin exact role/name/selector assertions on known button element
- Strengthen text happy-path: assert role "name", selector:, point: lines
- Assert exact parent count (2) and distinct refs for --parent-depth
- Pin INVALID_ARGUMENT error code for invalid coordinates
- Validate coordinates in stub execute() so error test passes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add browser click interaction tests
* Expand browser click interaction coverage
* [packages/cli-v2]feat: implement browser click command with shared element resolution
Add full browser click implementation with CDP mouse event dispatch,
selector/coordinate parsing, --button/--count/--new-tab flags, navigation
detection, and XPath support. Extract element resolution into a shared
browser::element utility for reuse by future interaction commands.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [packages/cli-v2]fix: use shared resolver for --new-tab href check and add click to help
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add browser type interaction tests
* [packages/cli-v2]feat: implement browser type command
Keystroke-by-keystroke text input via CDP Input.dispatchKeyEvent.
Resolves element through shared element utility, focuses and positions
cursor at end before typing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [packages/cli-v2]fix: populate context URL/title and use char count in browser type
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add browser fill interaction tests
* [packages/cli-v2]feat: implement browser fill command
Direct value setting via native input setter with synthetic input event
dispatch. No keystroke simulation — replaces existing value entirely.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [packages/cli-v2]fix: pick native value setter based on element type in browser fill
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Add textarea fill regression test
* Add browser select interaction tests
* [packages/cli-v2]feat: implement browser select command
Select dropdown options by value or visible text (--by-text flag).
Dispatches input and change events after selection.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* [packages/cli-v2]fix: use resolved node for select instead of re-querying with querySelector
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Format interaction files for lint
* [packages/cli-v2]fix: scroll into view before click and replace fixed navigation delay
Scroll elements into the viewport via DOM.scrollIntoViewIfNeeded before
computing bounding-box coordinates, so clicks on off-screen elements
land correctly. Replace the hardcoded 500ms post-click sleep with a
polling loop that detects URL changes at 50ms intervals (2s timeout),
avoiding unnecessary delays for non-navigating clicks and catching
slow SPA transitions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>