Skip to content

BrowserAction

Perform an interaction on the current browser page.

Package: @agentrail/capabilities (sandbox-only)

This tool is available only when the sandboxed capability set is active.

Parameters

NameTypeRequiredDescription
type"click" | "fill" | "select" | "hover" | "press" | "evaluate"YesThe type of action to perform.
selectorstringNoCSS selector of the target element. Required for click, fill, select, hover, and press.
valuestringNoValue to fill/select, or key to press (e.g. "Enter", "Escape", "Tab"). Required for fill, select, and press.
scriptstringNoJavaScript to evaluate. Required for the evaluate action.

Action types

TypeDescription
clickClick the element identified by selector.
fillClear and set the value of an input or textarea.
selectSelect an option in a <select> element by value or label.
hoverHover over an element to trigger tooltips or dropdown menus.
pressPress a keyboard key, optionally on a focused element.
evaluateRun arbitrary JavaScript and return the result as a string.

Result

Returns a text description of the outcome. The details field:

ts
{ type: string; result?: unknown }

Usage notes

  • Always read the page with BrowserContent before interacting so you know which selectors exist.
  • After a click that triggers navigation, call BrowserContent again to get the new page state.
  • Use evaluate for actions that cannot be expressed with the other types (e.g. programmatic form submission, reading computed styles).

Example

ts
// Click a submit button
{ type: "click", selector: "#submit-btn" }

// Fill a search input and press Enter
{ type: "fill", selector: "input[name=q]", value: "agentrail docs" }
{ type: "press", selector: "input[name=q]", value: "Enter" }

// Select a dropdown option
{ type: "select", selector: "#country-select", value: "US" }

// Evaluate JavaScript
{ type: "evaluate", script: "document.title" }

Released under the Apache 2.0 License.