Expand description
LLM-driven browser test framework.
Provides reusable building blocks for browser-based test scenarios:
- Browser client via Chrome
DevToolsProtocol (headless) - LLM client for natural language element targeting and assertions
- A2A agent integration for agent-to-agent communication
- MCP client/server integration for tool-calling
- Cost tracking, token counting, and budget enforcement
- Declarative TOML scenario runner
#[browser_test]macros forcargo testintegration
Re-exports§
pub use costs::LlmResponse;pub use costs::LlmUsage;pub use scenario::AuthConfig;pub use scenario::AuthMode;pub use scenario::AwsConfig;pub use scenario::Provider;
Modules§
- a2a
- A2A agent protocol client. A2A (Agent-to-Agent) protocol client.
- budgets
- Budget tracking and enforcement. Budget tracking and enforcement.
- costs
- Cost calculation, usage tracking, and pricing. Cost calculation, usage tracking, and pricing logic.
- diagnostics
- Failure diagnostics — page-state capture and artifact writing. Failure diagnostics — page-state capture and artifact writing.
- endpoints
- Endpoint registry and routing resolver. Endpoint registry — resolves named endpoints and task-type routing.
- events
- Typed run events emitted by the runner. Typed run events emitted by the runner.
- mcp_
client - MCP client for connecting to external MCP servers. MCP (Model Context Protocol) client.
- mcp_
server - MCP server for exposing the framework as an MCP server. MCP server exposure — exposes the framework as an MCP server.
- redact
- Secret redaction for every report sink. Secret redaction for every report sink.
- reporting
- Run reporting: console, NDJSON, JUnit, GitHub and Perfetto sinks. Report sinks: console, NDJSON, JUnit XML, GitHub annotations, Perfetto trace.
- runner
- Step-by-step scenario executor (navigate, click, type, wait, assert).
- scenario
- Declarative TOML-based test scenario types. Scenario types for human-readable browser test case definitions.
- selectors
- CSS selector sanitization for LLM-generated selectors. CSS selector sanitization and validation for LLM-generated selectors.
- vision
- Vision support — screenshot capture/downscale/encode for visual asserts. Vision support — screenshot capture, tiling, downscaling, and JPEG encoding for LLM visual assertions.
Structs§
- LlmConfig
- Configuration for the LLM client — bundles URL, model, auth, timeouts, and provider-specific options into a single struct passed everywhere.
Constants§
- DEFAULT_
AZURE_ API_ VERSION - Default
AzureOpenAIAPI version used when an endpoint does not setapi_version. - DOM_
EXTRACT_ JS - JavaScript to extract interactive elements from the current page. Returns a JSON array of objects with tag, selector, and label.
Functions§
- base_
url - Returns the target base URL from
HARNESS_BROWSER_BASE_URLenv, defaulting tohttp://localhost:4200. - browser_
headless - Returns whether to run the browser in headless mode from
HARNESS_BROWSER_HEADLESSenv, defaulting totrue. - build_
azure_ url - Builds the
AzureOpenAIchat completions URL: the resource endpoint (without/openai), the deployment name, and the API version. - default_
llm_ attempts - Reads
HARNESS_LLM_CALL_ATTEMPTS(default 3) — how many times a single chat completion is retried before the endpoint is considered failed. - http_
client - Builds a
reqwest::Clientwith the given timeout. - llm_
base_ url - Returns the LLM server base URL from
HARNESS_LLM_TEST_URLenv, defaulting tohttp://localhost:8080. - llm_
chat - Sends a chat completion request to the LLM.
- llm_
chat_ vision_ with_ usage - Sends a vision-enabled chat completion request.
- llm_
chat_ vision_ with_ usage_ chain - Vision variant of
llm_chat_with_usage_chain. - llm_
chat_ with_ usage - Sends a chat completion request to the LLM and returns both the content and token usage from the API response.
- llm_
chat_ with_ usage_ chain - Calls a chain of endpoints: the primary
LlmConfigfirst, then each fallback in order. Every endpoint gets its ownmax_attemptsretry budget; the first endpoint that answers wins. - llm_
model - Returns the LLM model name from
HARNESS_LLM_TEST_MODELenv, defaulting todeepseek. - parse_
headers_ env - Parses
HARNESS_LLM_HEADERSenv var (JSON object) into a header map. - truncate
- Truncates a string to the given maximum length, appending a marker with the number of omitted characters if truncation occurred.