Skip to main content
The BrowserResource on client.browser gives you programmatic control over browser sessions in the Figranium Swift SDK. You can open headless or headful sessions, inspect the current headful state, highlight candidate selectors on a page, and stream live selector events during an active headful session.
BrowserResource.swift

Methods

Opens a browser session. You can run in headless mode, headful mode, scrape mode, or agent mode.
  • HTTP endpoint: POST /api/browser/open
  • Signature: open(_ input: JSONObject = [:], options: RequestOptions = .init()) async throws -> BrowserSession
  • Returns: BrowserSession with sessionId, status, and optionally wsEndpoint.
browser_open.swift
Highlights candidate selectors on a page and returns a DOM snapshot. Useful for building or debugging selector-based tasks.
  • HTTP endpoint: POST /api/inspector/highlight
  • Signature: highlight(_ input: JSONObject, options: RequestOptions = .init()) async throws -> JSONObject
  • Returns: A JSONObject with success, a list of SelectorCandidate objects (css, optional xpath and confidence), and a snapshot string.
browser_highlight.swift
Stops the active headful browser session.
  • HTTP endpoint: POST /headful/stop
  • Signature: stopHeadful(options: RequestOptions = .init()) async throws -> JSONObject
  • Returns: JSONObject
browser_stop_headful.swift
Checks whether the headful session is configured to use noVNC.
  • HTTP endpoint: GET /api/headful/status
  • Signature: headfulStatus(options: RequestOptions = .init()) async throws -> JSONObject
  • Returns: JSONObject containing useNovnc as a boolean.
browser_headful_status.swift
Inspects the current headful session and returns diagnostic information.
  • HTTP endpoint: POST /api/headful/inspect
  • Signature: inspect(options: RequestOptions = .init()) async throws -> JSONObject
  • Returns: JSONObject
browser_inspect.swift
Retrieves the VNC password for the current headful session.
  • HTTP endpoint: GET /api/headful/vnc-password
  • Signature: vncPassword(options: RequestOptions = .init()) async throws -> String
  • Returns: String containing the password.
browser_vnc_password.swift
Streams live selector events from the headful session as an AsyncThrowingStream.
  • HTTP endpoint: GET /api/headful/selector_stream
  • Signature: selectorStream(options: RequestOptions = .init()) -> AsyncThrowingStream<StreamEvent<JSONValue>, Error>
  • Returns: AsyncThrowingStream<StreamEvent<JSONValue>, Error>
This is a server-sent event stream. For details on iterating streams and handling timeouts, see Streaming.
browser_selector_stream.swift

Headful debugging workflow

A typical headful debugging session combines several BrowserResource methods to open a browser, inspect state, stream selector events, and clean up when finished.
browser_workflow.swift

Streaming

Details on AsyncThrowingStream<StreamEvent<JSONValue>, Error>.

Request options

Pass custom headers and per-request timeout overrides.

Errors

Handle FigraniumError responses.

Headful Browser

Learn about headful browser sessions in Figranium.

Highlight Tool

Use the highlight tool to build and debug selectors.