Documentation
¶
Overview ¶
Package vibium provides a Go client for the Vibium browser automation platform.
Vibium is a browser automation platform built for AI agents that uses the WebDriver BiDi protocol for bidirectional communication with the browser.
Quick Start ¶
Launch a browser and navigate to a page:
ctx := context.Background()
vibe, err := vibium.Launch(ctx)
if err != nil {
log.Fatal(err)
}
defer vibe.Quit(ctx)
if err := vibe.Go(ctx, "https://example.com"); err != nil {
log.Fatal(err)
}
Finding and Interacting with Elements ¶
Find elements using CSS selectors and interact with them:
link, err := vibe.Find(ctx, "a.my-link", nil)
if err != nil {
log.Fatal(err)
}
if err := link.Click(ctx, nil); err != nil {
log.Fatal(err)
}
Type text into input fields:
input, err := vibe.Find(ctx, "input[name='search']", nil)
if err != nil {
log.Fatal(err)
}
if err := input.Type(ctx, "search query", nil); err != nil {
log.Fatal(err)
}
Screenshots ¶
Capture screenshots as PNG data:
data, err := vibe.Screenshot(ctx)
if err != nil {
log.Fatal(err)
}
os.WriteFile("screenshot.png", data, 0644)
Headless Mode ¶
Launch in headless mode for CI/server environments:
vibe, err := vibium.LaunchHeadless(ctx)
Or with explicit options:
vibe, err := vibium.Browser.Launch(ctx, &vibium.LaunchOptions{
Headless: true,
Port: 9515,
})
Requirements ¶
This client requires the Vibium clicker binary to be available. Install it via:
npm install -g vibium
Or set the VIBIUM_CLICKER_PATH environment variable to point to the binary.
Package vibium provides a Go client for browser automation via the Vibium platform. It communicates with the Vibium clicker binary over WebSocket using the WebDriver BiDi protocol.
Example ¶
ctx := context.Background()
// Launch browser
vibe, err := vibium.Launch(ctx)
if err != nil {
log.Fatal(err)
}
defer func() { _ = vibe.Quit(ctx) }()
// Navigate to a page
if err := vibe.Go(ctx, "https://example.com"); err != nil {
log.Fatal(err)
}
// Find and click a link
link, err := vibe.Find(ctx, "a", nil)
if err != nil {
log.Fatal(err)
}
if err := link.Click(ctx, nil); err != nil {
log.Fatal(err)
}
// Get page title
title, err := vibe.Title(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println("Page title:", title)
Example (FormInteraction) ¶
ctx := context.Background()
vibe, err := vibium.Browser.Launch(ctx, &vibium.LaunchOptions{
Headless: true,
})
if err != nil {
log.Fatal(err)
}
defer func() { _ = vibe.Quit(ctx) }()
// Navigate to a form page
if err := vibe.Go(ctx, "https://example.com/login"); err != nil {
log.Fatal(err)
}
// Fill in username
username, err := vibe.Find(ctx, "input[name='username']", nil)
if err != nil {
log.Fatal(err)
}
if err := username.Type(ctx, "myuser", nil); err != nil {
log.Fatal(err)
}
// Fill in password
password, err := vibe.Find(ctx, "input[name='password']", nil)
if err != nil {
log.Fatal(err)
}
if err := password.Type(ctx, "mypassword", nil); err != nil {
log.Fatal(err)
}
// Click submit
submit, err := vibe.Find(ctx, "button[type='submit']", nil)
if err != nil {
log.Fatal(err)
}
if err := submit.Click(ctx, nil); err != nil {
log.Fatal(err)
}
Example (Headless) ¶
ctx := context.Background()
// Launch headless browser
vibe, err := vibium.LaunchHeadless(ctx)
if err != nil {
log.Fatal(err)
}
defer func() { _ = vibe.Quit(ctx) }()
// Navigate
if err := vibe.Go(ctx, "https://example.com"); err != nil {
log.Fatal(err)
}
// Take screenshot
data, err := vibe.Screenshot(ctx)
if err != nil {
log.Fatal(err)
}
// Save to file
if err := os.WriteFile("screenshot.png", data, 0600); err != nil {
log.Fatal(err)
}
Index ¶
- Constants
- Variables
- func ContextWithLogger(ctx context.Context, logger *slog.Logger) context.Context
- func Debug() bool
- func LoggerFromContext(ctx context.Context) *slog.Logger
- func NewDebugLogger() *slog.Logger
- type ActionOptions
- type BiDiClient
- type BiDiCommand
- type BiDiError
- type BiDiResponse
- type BoundingBox
- type BrowserContext
- func (c *BrowserContext) AddInitScript(ctx context.Context, script string) error
- func (c *BrowserContext) ClearCookies(ctx context.Context) error
- func (c *BrowserContext) ClearPermissions(ctx context.Context) error
- func (c *BrowserContext) Close(ctx context.Context) error
- func (c *BrowserContext) Cookies(ctx context.Context, urls ...string) ([]Cookie, error)
- func (c *BrowserContext) GrantPermissions(ctx context.Context, permissions []string, origin string) error
- func (c *BrowserContext) NewPage(ctx context.Context) (*Vibe, error)
- func (c *BrowserContext) SetCookies(ctx context.Context, cookies []SetCookieParam) error
- func (c *BrowserContext) StorageState(ctx context.Context) (*StorageState, error)
- func (c *BrowserContext) Tracing() *Tracing
- type BrowserCrashedError
- type ClickOptions
- type ClickerProcess
- type Clock
- func (c *Clock) FastForward(ctx context.Context, ticks int64) error
- func (c *Clock) Install(ctx context.Context, opts *ClockInstallOptions) error
- func (c *Clock) PauseAt(ctx context.Context, t interface{}) error
- func (c *Clock) Resume(ctx context.Context) error
- func (c *Clock) RunFor(ctx context.Context, ticks int64) error
- func (c *Clock) SetFixedTime(ctx context.Context, t interface{}) error
- func (c *Clock) SetSystemTime(ctx context.Context, t interface{}) error
- func (c *Clock) SetTimezone(ctx context.Context, tz string) error
- type ClockInstallOptions
- type ConnectionError
- type ConsoleHandler
- type ConsoleMessage
- type ContinueOptions
- type Cookie
- type Dialog
- type DialogHandler
- type DialogInfo
- type Download
- type DownloadHandler
- type Element
- func (e *Element) BoundingBox(ctx context.Context) (BoundingBox, error)
- func (e *Element) Center() (x, y float64)
- func (e *Element) Check(ctx context.Context, opts *ActionOptions) error
- func (e *Element) Clear(ctx context.Context, opts *ActionOptions) error
- func (e *Element) Click(ctx context.Context, opts *ActionOptions) error
- func (e *Element) DblClick(ctx context.Context, opts *ActionOptions) error
- func (e *Element) DispatchEvent(ctx context.Context, eventType string, eventInit map[string]interface{}) error
- func (e *Element) DragTo(ctx context.Context, target *Element, opts *ActionOptions) error
- func (e *Element) Eval(ctx context.Context, fn string, args ...interface{}) (interface{}, error)
- func (e *Element) Fill(ctx context.Context, value string, opts *ActionOptions) error
- func (e *Element) Find(ctx context.Context, selector string, opts *FindOptions) (*Element, error)
- func (e *Element) FindAll(ctx context.Context, selector string, opts *FindOptions) ([]*Element, error)
- func (e *Element) Focus(ctx context.Context, opts *ActionOptions) error
- func (e *Element) GetAttribute(ctx context.Context, name string) (string, error)
- func (e *Element) HTML(ctx context.Context) (string, error)
- func (e *Element) Hover(ctx context.Context, opts *ActionOptions) error
- func (e *Element) Info() ElementInfo
- func (e *Element) InnerHTML(ctx context.Context) (string, error)
- func (e *Element) InnerText(ctx context.Context) (string, error)
- func (e *Element) IsChecked(ctx context.Context) (bool, error)
- func (e *Element) IsEditable(ctx context.Context) (bool, error)
- func (e *Element) IsEnabled(ctx context.Context) (bool, error)
- func (e *Element) IsHidden(ctx context.Context) (bool, error)
- func (e *Element) IsVisible(ctx context.Context) (bool, error)
- func (e *Element) Label(ctx context.Context) (string, error)
- func (e *Element) Press(ctx context.Context, key string, opts *ActionOptions) error
- func (e *Element) Role(ctx context.Context) (string, error)
- func (e *Element) Screenshot(ctx context.Context) ([]byte, error)
- func (e *Element) ScrollIntoView(ctx context.Context, opts *ActionOptions) error
- func (e *Element) SelectOption(ctx context.Context, values SelectOptionValues, opts *ActionOptions) error
- func (e *Element) Selector() string
- func (e *Element) SetFiles(ctx context.Context, paths []string, opts *ActionOptions) error
- func (e *Element) Tap(ctx context.Context, opts *ActionOptions) error
- func (e *Element) Text(ctx context.Context) (string, error)
- func (e *Element) Type(ctx context.Context, text string, opts *ActionOptions) error
- func (e *Element) Uncheck(ctx context.Context, opts *ActionOptions) error
- func (e *Element) Value(ctx context.Context) (string, error)
- func (e *Element) WaitFor(ctx context.Context, timeout time.Duration) error
- func (e *Element) WaitUntil(ctx context.Context, state string, timeout time.Duration) error
- type ElementInfo
- type ElementNotFoundError
- type EmulateMediaOptions
- type FindOptions
- type FrameInfo
- type FulfillOptions
- type Geolocation
- type Keyboard
- func (k *Keyboard) Down(ctx context.Context, key string) error
- func (k *Keyboard) InsertText(ctx context.Context, text string) error
- func (k *Keyboard) Press(ctx context.Context, key string) error
- func (k *Keyboard) Type(ctx context.Context, text string) error
- func (k *Keyboard) Up(ctx context.Context, key string) error
- type LaunchOptions
- type MockRouteOptions
- type Mouse
- func (m *Mouse) Click(ctx context.Context, x, y float64, opts *ClickOptions) error
- func (m *Mouse) DblClick(ctx context.Context, x, y float64, opts *ClickOptions) error
- func (m *Mouse) Down(ctx context.Context, button MouseButton) error
- func (m *Mouse) Move(ctx context.Context, x, y float64) error
- func (m *Mouse) Up(ctx context.Context, button MouseButton) error
- func (m *Mouse) Wheel(ctx context.Context, deltaX, deltaY float64) error
- type MouseButton
- type NetworkRequest
- type NetworkRequestsOptions
- type PDFMargin
- type PDFOptions
- type Request
- type RequestHandler
- type Response
- type ResponseHandler
- type Route
- type RouteHandler
- type RouteInfo
- type ScrollOptions
- type SelectOptionValues
- type SetCookieParam
- type SetWindowOptions
- type StorageState
- type StorageStateOrigin
- type TimeoutError
- type Touch
- type Tracing
- func (t *Tracing) Start(ctx context.Context, opts *TracingStartOptions) error
- func (t *Tracing) StartChunk(ctx context.Context, opts *TracingChunkOptions) error
- func (t *Tracing) StartGroup(ctx context.Context, name string, opts *TracingGroupOptions) error
- func (t *Tracing) Stop(ctx context.Context, opts *TracingStopOptions) ([]byte, error)
- func (t *Tracing) StopChunk(ctx context.Context, opts *TracingChunkOptions) ([]byte, error)
- func (t *Tracing) StopGroup(ctx context.Context) error
- type TracingChunkOptions
- type TracingGroupOptions
- type TracingStartOptions
- type TracingStopOptions
- type Vibe
- func (v *Vibe) A11yTree(ctx context.Context) (interface{}, error)
- func (v *Vibe) AddInitScript(ctx context.Context, script string) error
- func (v *Vibe) AddScript(ctx context.Context, source string) error
- func (v *Vibe) AddStyle(ctx context.Context, source string) error
- func (v *Vibe) Back(ctx context.Context) error
- func (v *Vibe) BringToFront(ctx context.Context) error
- func (v *Vibe) BrowserVersion(ctx context.Context) (string, error)
- func (v *Vibe) BrowsingContext() string
- func (v *Vibe) ClearConsoleMessages(ctx context.Context) error
- func (v *Vibe) ClearNetworkRequests(ctx context.Context) error
- func (v *Vibe) ClearStorage(ctx context.Context) error
- func (v *Vibe) Clock(ctx context.Context) (*Clock, error)
- func (v *Vibe) Close(ctx context.Context) error
- func (v *Vibe) ConsoleMessages(ctx context.Context, level string) ([]ConsoleMessage, error)
- func (v *Vibe) Content(ctx context.Context) (string, error)
- func (v *Vibe) Context() *BrowserContext
- func (v *Vibe) EmulateMedia(ctx context.Context, opts EmulateMediaOptions) error
- func (v *Vibe) Evaluate(ctx context.Context, script string) (interface{}, error)
- func (v *Vibe) Expose(ctx context.Context, name string) error
- func (v *Vibe) Find(ctx context.Context, selector string, opts *FindOptions) (*Element, error)
- func (v *Vibe) FindAll(ctx context.Context, selector string, opts *FindOptions) ([]*Element, error)
- func (v *Vibe) Forward(ctx context.Context) error
- func (v *Vibe) Frame(ctx context.Context, nameOrURL string) (*Vibe, error)
- func (v *Vibe) Frames(ctx context.Context) ([]FrameInfo, error)
- func (v *Vibe) GetDialog(ctx context.Context) (DialogInfo, error)
- func (v *Vibe) GetViewport(ctx context.Context) (Viewport, error)
- func (v *Vibe) GetWindow(ctx context.Context) (WindowState, error)
- func (v *Vibe) Go(ctx context.Context, url string) error
- func (v *Vibe) HandleDialog(ctx context.Context, accept bool, promptText string) error
- func (v *Vibe) IsClosed() bool
- func (v *Vibe) Keyboard(ctx context.Context) (*Keyboard, error)
- func (v *Vibe) ListRoutes(ctx context.Context) ([]RouteInfo, error)
- func (v *Vibe) MockRoute(ctx context.Context, pattern string, opts MockRouteOptions) error
- func (v *Vibe) Mouse(ctx context.Context) (*Mouse, error)
- func (v *Vibe) MustFind(ctx context.Context, selector string) *Element
- func (v *Vibe) NetworkRequests(ctx context.Context, opts *NetworkRequestsOptions) ([]NetworkRequest, error)
- func (v *Vibe) NewContext(ctx context.Context) (*BrowserContext, error)
- func (v *Vibe) NewPage(ctx context.Context) (*Vibe, error)
- func (v *Vibe) OnConsole(ctx context.Context, handler ConsoleHandler) error
- func (v *Vibe) OnDialog(ctx context.Context, handler DialogHandler) error
- func (v *Vibe) OnDownload(ctx context.Context, handler DownloadHandler) error
- func (v *Vibe) OnRequest(ctx context.Context, handler RequestHandler) error
- func (v *Vibe) OnResponse(ctx context.Context, handler ResponseHandler) error
- func (v *Vibe) PDF(ctx context.Context, opts *PDFOptions) ([]byte, error)
- func (v *Vibe) Pages(ctx context.Context) ([]*Vibe, error)
- func (v *Vibe) Quit(ctx context.Context) error
- func (v *Vibe) Reload(ctx context.Context) error
- func (v *Vibe) Route(ctx context.Context, pattern string, handler RouteHandler) error
- func (v *Vibe) Screenshot(ctx context.Context) ([]byte, error)
- func (v *Vibe) Scroll(ctx context.Context, direction string, amount int, opts *ScrollOptions) error
- func (v *Vibe) SetContent(ctx context.Context, html string) error
- func (v *Vibe) SetExtraHTTPHeaders(ctx context.Context, headers map[string]string) error
- func (v *Vibe) SetGeolocation(ctx context.Context, coords Geolocation) error
- func (v *Vibe) SetOffline(ctx context.Context, offline bool) error
- func (v *Vibe) SetStorageState(ctx context.Context, state *StorageState) error
- func (v *Vibe) SetViewport(ctx context.Context, viewport Viewport) error
- func (v *Vibe) SetWindow(ctx context.Context, opts SetWindowOptions) error
- func (v *Vibe) StorageState(ctx context.Context) (*StorageState, error)
- func (v *Vibe) Title(ctx context.Context) (string, error)
- func (v *Vibe) Touch(ctx context.Context) (*Touch, error)
- func (v *Vibe) Tracing() *Tracing
- func (v *Vibe) URL(ctx context.Context) (string, error)
- func (v *Vibe) Unroute(ctx context.Context, pattern string) error
- func (v *Vibe) WaitForFunction(ctx context.Context, fn string, timeout time.Duration) error
- func (v *Vibe) WaitForLoad(ctx context.Context, state string, timeout time.Duration) error
- func (v *Vibe) WaitForNavigation(ctx context.Context, timeout time.Duration) error
- func (v *Vibe) WaitForURL(ctx context.Context, pattern string, timeout time.Duration) error
- type Viewport
- type WindowState
Examples ¶
Constants ¶
const DefaultTimeout = 30 * time.Second
DefaultTimeout is the default timeout for finding elements and waiting for actionability.
Variables ¶
var ( // ErrConnectionFailed is returned when WebSocket connection fails. ErrConnectionFailed = errors.New("failed to connect to clicker server") // ErrElementNotFound is returned when an element cannot be found. ErrElementNotFound = errors.New("element not found") // ErrBrowserCrashed is returned when the browser process exits unexpectedly. ErrBrowserCrashed = errors.New("browser crashed") // ErrClickerNotFound is returned when the clicker binary cannot be found. ErrClickerNotFound = errors.New("clicker binary not found") // ErrTimeout is returned when an operation times out. ErrTimeout = errors.New("operation timed out") // ErrConnectionClosed is returned when the WebSocket connection is closed. ErrConnectionClosed = errors.New("connection closed") )
var Browser = &browserLauncher{}
Browser provides browser launching capabilities.
Functions ¶
func ContextWithLogger ¶
ContextWithLogger returns a new context with the logger attached.
func Debug ¶
func Debug() bool
Debug returns true if debug logging is enabled via VIBIUM_DEBUG environment variable.
func LoggerFromContext ¶
LoggerFromContext returns the logger from the context, or nil if not present.
func NewDebugLogger ¶
NewDebugLogger creates a new debug logger that writes to stderr. Returns nil if debug logging is disabled.
Types ¶
type ActionOptions ¶
type ActionOptions struct {
// Timeout specifies how long to wait for actionability.
// Default is 30 seconds.
Timeout time.Duration
}
ActionOptions configures action behavior (click, type).
type BiDiClient ¶
type BiDiClient struct {
// contains filtered or unexported fields
}
BiDiClient manages WebSocket communication with the clicker server.
func (*BiDiClient) Close ¶
func (c *BiDiClient) Close() error
Close closes the WebSocket connection.
func (*BiDiClient) Connect ¶
func (c *BiDiClient) Connect(ctx context.Context, url string) error
Connect establishes a WebSocket connection to the clicker server.
func (*BiDiClient) Send ¶
func (c *BiDiClient) Send(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
Send sends a command and waits for the response.
type BiDiCommand ¶
type BiDiCommand struct {
ID int64 `json:"id"`
Method string `json:"method"`
Params interface{} `json:"params"`
}
BiDiCommand represents a WebDriver BiDi command.
type BiDiResponse ¶
type BiDiResponse struct {
ID int64 `json:"id"`
Type string `json:"type"`
Result json.RawMessage `json:"result,omitempty"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}
BiDiResponse represents a WebDriver BiDi response.
type BoundingBox ¶
type BoundingBox struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`
Height float64 `json:"height"`
}
BoundingBox represents the position and size of an element.
type BrowserContext ¶
type BrowserContext struct {
// contains filtered or unexported fields
}
BrowserContext represents an isolated browser context (like an incognito window). Each context has its own cookies, localStorage, and session storage.
func (*BrowserContext) AddInitScript ¶
func (c *BrowserContext) AddInitScript(ctx context.Context, script string) error
AddInitScript adds a script that will be evaluated in every page created in this context.
func (*BrowserContext) ClearCookies ¶
func (c *BrowserContext) ClearCookies(ctx context.Context) error
ClearCookies clears all cookies.
func (*BrowserContext) ClearPermissions ¶
func (c *BrowserContext) ClearPermissions(ctx context.Context) error
ClearPermissions clears all granted permissions.
func (*BrowserContext) Close ¶
func (c *BrowserContext) Close(ctx context.Context) error
Close closes the browser context and all pages within it.
func (*BrowserContext) Cookies ¶
Cookies returns cookies matching the specified URLs. If no URLs are specified, returns all cookies for the context.
func (*BrowserContext) GrantPermissions ¶
func (c *BrowserContext) GrantPermissions(ctx context.Context, permissions []string, origin string) error
GrantPermissions grants the specified permissions.
func (*BrowserContext) NewPage ¶
func (c *BrowserContext) NewPage(ctx context.Context) (*Vibe, error)
NewPage creates a new page in this browser context.
func (*BrowserContext) SetCookies ¶
func (c *BrowserContext) SetCookies(ctx context.Context, cookies []SetCookieParam) error
SetCookies sets cookies.
func (*BrowserContext) StorageState ¶
func (c *BrowserContext) StorageState(ctx context.Context) (*StorageState, error)
StorageState returns the storage state including cookies and localStorage.
func (*BrowserContext) Tracing ¶
func (c *BrowserContext) Tracing() *Tracing
Tracing returns the tracing controller for this context.
type BrowserCrashedError ¶
BrowserCrashedError represents an unexpected browser exit.
func (*BrowserCrashedError) Error ¶
func (e *BrowserCrashedError) Error() string
type ClickOptions ¶
type ClickOptions struct {
Button MouseButton
ClickCount int
Delay int // milliseconds between mousedown and mouseup
}
ClickOptions configures mouse click behavior.
type ClickerProcess ¶
type ClickerProcess struct {
// contains filtered or unexported fields
}
ClickerProcess manages the clicker binary subprocess.
func StartClicker ¶
func StartClicker(ctx context.Context, opts LaunchOptions) (*ClickerProcess, error)
StartClicker starts the clicker binary and returns a ClickerProcess.
func (*ClickerProcess) Port ¶
func (p *ClickerProcess) Port() int
Port returns the port the clicker is listening on.
func (*ClickerProcess) Stop ¶
func (p *ClickerProcess) Stop() error
Stop gracefully stops the clicker process.
func (*ClickerProcess) Wait ¶
func (p *ClickerProcess) Wait() error
Wait waits for the clicker process to exit.
func (*ClickerProcess) WebSocketURL ¶
func (p *ClickerProcess) WebSocketURL() string
WebSocketURL returns the WebSocket URL for connecting to the clicker.
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock provides control over time in the browser.
func NewClock ¶
func NewClock(client *BiDiClient, browsingContext string) *Clock
NewClock creates a new Clock controller.
func (*Clock) FastForward ¶
FastForward advances time by the specified number of milliseconds. Timers are not fired.
func (*Clock) Install ¶
func (c *Clock) Install(ctx context.Context, opts *ClockInstallOptions) error
Install installs fake timers in the browser. This replaces native time-related functions like Date, setTimeout, etc.
func (*Clock) RunFor ¶
RunFor advances time by the specified number of milliseconds, firing all pending timers.
func (*Clock) SetFixedTime ¶
SetFixedTime sets a fixed time that will be returned by Date.now() and new Date().
func (*Clock) SetSystemTime ¶
SetSystemTime sets the system time.
type ClockInstallOptions ¶
type ClockInstallOptions struct {
// Time to set as the current time (Unix timestamp in milliseconds or time.Time)
Time interface{}
}
ClockInstallOptions configures clock installation.
type ConnectionError ¶
ConnectionError represents a WebSocket connection failure.
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
func (*ConnectionError) Unwrap ¶
func (e *ConnectionError) Unwrap() error
type ConsoleHandler ¶
type ConsoleHandler func(*ConsoleMessage)
ConsoleHandler is called for each console message.
type ConsoleMessage ¶
type ConsoleMessage struct {
Type string `json:"type"`
Text string `json:"text"`
Args []string `json:"args,omitempty"`
URL string `json:"url,omitempty"`
Line int `json:"line,omitempty"`
}
ConsoleMessage represents a console message from the browser.
type ContinueOptions ¶
ContinueOptions configures how to continue a route.
type Cookie ¶
type Cookie struct {
Name string `json:"name"`
Value string `json:"value"`
Domain string `json:"domain"`
Path string `json:"path"`
Expires float64 `json:"expires"`
HTTPOnly bool `json:"httpOnly"`
Secure bool `json:"secure"`
SameSite string `json:"sameSite"`
PartitionKey string `json:"partitionKey,omitempty"`
}
Cookie represents a browser cookie.
type Dialog ¶
type Dialog struct {
Type string `json:"type"` // "alert", "confirm", "prompt", "beforeunload"
Message string `json:"message"`
Default string `json:"defaultValue,omitempty"` // For prompt dialogs
// contains filtered or unexported fields
}
Dialog represents a browser dialog (alert, confirm, prompt, beforeunload).
type DialogHandler ¶
type DialogHandler func(*Dialog)
DialogHandler is called when a dialog appears.
type DialogInfo ¶ added in v0.4.0
type DialogInfo struct {
HasDialog bool `json:"has_dialog"`
Type string `json:"type,omitempty"`
Message string `json:"message,omitempty"`
DefaultValue string `json:"default_value,omitempty"`
}
DialogInfo contains information about the current dialog.
type Download ¶
type Download struct {
URL string `json:"url"`
Name string `json:"suggestedFilename"`
// contains filtered or unexported fields
}
Download represents a file download.
type DownloadHandler ¶
type DownloadHandler func(*Download)
DownloadHandler is called when a download starts.
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element represents a DOM element that can be interacted with.
func NewElement ¶
func NewElement(client *BiDiClient, browsingContext, selector string, info ElementInfo) *Element
NewElement creates a new Element instance.
func (*Element) BoundingBox ¶
func (e *Element) BoundingBox(ctx context.Context) (BoundingBox, error)
BoundingBox returns the element's bounding box.
func (*Element) Check ¶
func (e *Element) Check(ctx context.Context, opts *ActionOptions) error
Check checks a checkbox element. It waits for the element to be visible, stable, and enabled.
func (*Element) Clear ¶
func (e *Element) Clear(ctx context.Context, opts *ActionOptions) error
Clear clears the text content of an input field.
func (*Element) Click ¶
func (e *Element) Click(ctx context.Context, opts *ActionOptions) error
Click clicks on the element. It waits for the element to be visible, stable, able to receive events, and enabled before clicking.
func (*Element) DblClick ¶
func (e *Element) DblClick(ctx context.Context, opts *ActionOptions) error
DblClick double-clicks on the element.
func (*Element) DispatchEvent ¶
func (e *Element) DispatchEvent(ctx context.Context, eventType string, eventInit map[string]interface{}) error
DispatchEvent dispatches a DOM event on the element.
func (*Element) Eval ¶
Eval evaluates a JavaScript function with this element as the argument. The function should accept the element as its first parameter.
func (*Element) Fill ¶
Fill clears the input and fills it with the specified value. It waits for the element to be visible, stable, enabled, and editable before filling.
func (*Element) Find ¶ added in v0.4.0
Find finds a child element within this element by CSS selector or semantic options.
func (*Element) FindAll ¶ added in v0.4.0
func (e *Element) FindAll(ctx context.Context, selector string, opts *FindOptions) ([]*Element, error)
FindAll finds all child elements within this element by CSS selector or semantic options.
func (*Element) Focus ¶
func (e *Element) Focus(ctx context.Context, opts *ActionOptions) error
Focus focuses the element.
func (*Element) GetAttribute ¶
GetAttribute returns the value of the specified attribute.
func (*Element) HTML ¶ added in v0.4.0
HTML returns the outerHTML of the element (including the element itself).
func (*Element) Hover ¶
func (e *Element) Hover(ctx context.Context, opts *ActionOptions) error
Hover moves the mouse over the element.
func (*Element) IsEditable ¶
IsEditable returns whether the element is editable.
func (*Element) Press ¶
Press presses a key on the element. It waits for the element to be visible, stable, and able to receive events.
func (*Element) Screenshot ¶
Screenshot captures a screenshot of just this element.
func (*Element) ScrollIntoView ¶
func (e *Element) ScrollIntoView(ctx context.Context, opts *ActionOptions) error
ScrollIntoView scrolls the element into the visible area of the viewport.
func (*Element) SelectOption ¶
func (e *Element) SelectOption(ctx context.Context, values SelectOptionValues, opts *ActionOptions) error
SelectOption selects an option in a <select> element by value, label, or index.
func (*Element) Tap ¶
func (e *Element) Tap(ctx context.Context, opts *ActionOptions) error
Tap performs a touch tap on the element.
func (*Element) Type ¶
Type types text into the element. It waits for the element to be visible, stable, able to receive events, enabled, and editable before typing.
func (*Element) Uncheck ¶
func (e *Element) Uncheck(ctx context.Context, opts *ActionOptions) error
Uncheck unchecks a checkbox element. It waits for the element to be visible, stable, and enabled.
type ElementInfo ¶
type ElementInfo struct {
Tag string `json:"tag"`
Text string `json:"text"`
Box BoundingBox `json:"box"`
}
ElementInfo contains metadata about a DOM element.
type ElementNotFoundError ¶
type ElementNotFoundError struct {
Selector string
}
ElementNotFoundError represents an element that could not be found.
func (*ElementNotFoundError) Error ¶
func (e *ElementNotFoundError) Error() string
type EmulateMediaOptions ¶
type EmulateMediaOptions struct {
Media string // "screen", "print", or ""
ColorScheme string // "light", "dark", "no-preference", or ""
ReducedMotion string // "reduce", "no-preference", or ""
ForcedColors string // "active", "none", or ""
Contrast string // "more", "less", "no-preference", or ""
}
EmulateMediaOptions configures media emulation for accessibility testing.
type FindOptions ¶
type FindOptions struct {
// Timeout specifies how long to wait for the element to appear.
// Default is 30 seconds.
Timeout time.Duration
// Role matches elements by ARIA role (e.g., "button", "textbox").
Role string
// Text matches elements containing the specified text.
Text string
// Label matches elements by their associated label text.
Label string
// Placeholder matches input elements by placeholder attribute.
Placeholder string
// TestID matches elements by data-testid attribute.
TestID string
// Alt matches image elements by alt attribute.
Alt string
// Title matches elements by title attribute.
Title string
// XPath matches elements using an XPath expression.
XPath string
// Near finds elements near another element specified by selector.
Near string
}
FindOptions configures element finding behavior.
type FulfillOptions ¶
type FulfillOptions struct {
Status int
Headers map[string]string
ContentType string
Body []byte
Path string // Path to file to serve
}
FulfillOptions configures how to fulfill a route.
type Geolocation ¶
Geolocation represents geographic coordinates.
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
Keyboard provides keyboard input control.
func NewKeyboard ¶
func NewKeyboard(client *BiDiClient, browsingContext string) *Keyboard
NewKeyboard creates a new Keyboard controller.
func (*Keyboard) InsertText ¶
InsertText inserts text directly without keypress events. This is faster than Type but doesn't trigger keyboard events.
func (*Keyboard) Press ¶
Press presses a key on the keyboard. Key names follow the Playwright key naming convention (e.g., "Enter", "Tab", "ArrowUp").
type LaunchOptions ¶
type LaunchOptions struct {
// Headless runs the browser without a visible window.
Headless bool
// Port specifies the WebSocket port. If 0, an available port is auto-selected.
Port int
// ExecutablePath specifies a custom path to the clicker binary.
ExecutablePath string
}
LaunchOptions configures browser launch behavior.
type MockRouteOptions ¶ added in v0.4.0
type MockRouteOptions struct {
Status int // HTTP status code (default: 200)
Body string // Response body
ContentType string // Content-Type header (default: application/json)
Headers map[string]string // Additional response headers
}
MockRouteOptions configures a static mock response for a route.
type Mouse ¶
type Mouse struct {
// contains filtered or unexported fields
}
Mouse provides mouse input control.
func NewMouse ¶
func NewMouse(client *BiDiClient, browsingContext string) *Mouse
NewMouse creates a new Mouse controller.
func (*Mouse) Down ¶
func (m *Mouse) Down(ctx context.Context, button MouseButton) error
Down presses the mouse button.
type MouseButton ¶
type MouseButton string
MouseButton represents a mouse button.
const ( MouseButtonLeft MouseButton = "left" MouseButtonRight MouseButton = "right" MouseButtonMiddle MouseButton = "middle" )
type NetworkRequest ¶ added in v0.4.0
type NetworkRequest struct {
URL string `json:"url"`
Method string `json:"method"`
Headers map[string]string `json:"headers,omitempty"`
PostData string `json:"postData,omitempty"`
ResourceType string `json:"resourceType"`
Status int `json:"status,omitempty"`
StatusText string `json:"statusText,omitempty"`
ResponseSize int64 `json:"responseSize,omitempty"`
Timestamp int64 `json:"timestamp,omitempty"`
}
NetworkRequest represents a captured network request with its response.
type NetworkRequestsOptions ¶ added in v0.4.0
type NetworkRequestsOptions struct {
URLPattern string // Glob or regex pattern to filter URLs
Method string // Filter by HTTP method (GET, POST, etc.)
ResourceType string // Filter by resource type (document, script, xhr, etc.)
}
NetworkRequestsOptions configures network request filtering.
type PDFOptions ¶
type PDFOptions struct {
Path string
Scale float64
DisplayHeader bool
PrintBackground bool
Landscape bool
PageRanges string
Format string // "Letter", "Legal", "Tabloid", "A0"-"A6"
Width string
Height string
Margin *PDFMargin
}
PDFOptions configures PDF generation.
type Request ¶
type Request struct {
URL string `json:"url"`
Method string `json:"method"`
Headers map[string]string `json:"headers"`
PostData string `json:"postData,omitempty"`
ResourceType string `json:"resourceType"`
}
Request represents a network request.
type RequestHandler ¶
type RequestHandler func(*Request)
RequestHandler is called for each network request.
type Response ¶
type Response struct {
URL string `json:"url"`
Status int `json:"status"`
StatusText string `json:"statusText"`
Headers map[string]string `json:"headers"`
Body []byte `json:"-"`
}
Response represents a network response.
type ResponseHandler ¶
type ResponseHandler func(*Response)
ResponseHandler is called for each network response.
type Route ¶
type Route struct {
Request *Request
// contains filtered or unexported fields
}
Route represents an intercepted network request.
type RouteHandler ¶
RouteHandler is called when a request matches a route pattern.
type RouteInfo ¶ added in v0.4.0
type RouteInfo struct {
Pattern string `json:"pattern"`
Status int `json:"status,omitempty"`
ContentType string `json:"contentType,omitempty"`
}
RouteInfo represents information about an active route.
type ScrollOptions ¶ added in v0.4.0
type ScrollOptions struct {
Selector string // Optional CSS selector to scroll within
}
ScrollOptions configures scroll behavior.
type SelectOptionValues ¶
type SelectOptionValues struct {
// Values selects options by their value attribute.
Values []string
// Labels selects options by their visible text.
Labels []string
// Indexes selects options by their zero-based index.
Indexes []int
}
SelectOptionValues specifies which options to select in a <select> element.
type SetCookieParam ¶
type SetCookieParam struct {
Name string `json:"name"`
Value string `json:"value"`
URL string `json:"url,omitempty"`
Domain string `json:"domain,omitempty"`
Path string `json:"path,omitempty"`
Expires float64 `json:"expires,omitempty"`
HTTPOnly bool `json:"httpOnly,omitempty"`
Secure bool `json:"secure,omitempty"`
SameSite string `json:"sameSite,omitempty"`
PartitionKey string `json:"partitionKey,omitempty"`
}
SetCookieParam represents parameters for setting a cookie.
type SetWindowOptions ¶
type SetWindowOptions struct {
X *int
Y *int
Width *int
Height *int
State string // "normal", "minimized", "maximized", "fullscreen"
}
SetWindowOptions configures window state.
type StorageState ¶
type StorageState struct {
Cookies []Cookie `json:"cookies"`
Origins []StorageStateOrigin `json:"origins"`
}
StorageState represents browser storage state including cookies, localStorage, and sessionStorage.
type StorageStateOrigin ¶
type StorageStateOrigin struct {
Origin string `json:"origin"`
LocalStorage map[string]string `json:"localStorage"`
SessionStorage map[string]string `json:"sessionStorage,omitempty"`
}
StorageStateOrigin represents storage for an origin.
type TimeoutError ¶
TimeoutError represents a timeout waiting for an element or action.
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
type Touch ¶
type Touch struct {
// contains filtered or unexported fields
}
Touch provides touch input control.
func NewTouch ¶
func NewTouch(client *BiDiClient, browsingContext string) *Touch
NewTouch creates a new Touch controller.
type Tracing ¶
type Tracing struct {
// contains filtered or unexported fields
}
Tracing provides control over trace recording.
func (*Tracing) Start ¶
func (t *Tracing) Start(ctx context.Context, opts *TracingStartOptions) error
Start starts trace recording.
func (*Tracing) StartChunk ¶
func (t *Tracing) StartChunk(ctx context.Context, opts *TracingChunkOptions) error
StartChunk starts a new trace chunk.
func (*Tracing) StartGroup ¶
StartGroup starts a new trace group.
type TracingChunkOptions ¶
type TracingChunkOptions struct {
// Name for the chunk.
Name string
// Title for the chunk.
Title string
}
TracingChunkOptions configures trace chunk recording.
type TracingGroupOptions ¶
type TracingGroupOptions struct {
// Location to associate with the group.
Location string
}
TracingGroupOptions configures trace groups.
type TracingStartOptions ¶
type TracingStartOptions struct {
// Name is the trace file name (optional).
Name string
// Screenshots includes screenshots in the trace.
Screenshots bool
// Snapshots includes DOM snapshots in the trace.
Snapshots bool
// Sources includes source files in the trace.
Sources bool
// Title is the trace title (shown in trace viewer).
Title string
// Categories specifies which trace categories to include.
Categories []string
}
TracingStartOptions configures trace recording.
type TracingStopOptions ¶
type TracingStopOptions struct {
// Path to save the trace file.
Path string
}
TracingStopOptions configures how to stop trace recording.
type Vibe ¶
type Vibe struct {
// contains filtered or unexported fields
}
Vibe is the main browser control interface.
func LaunchHeadless ¶
LaunchHeadless is a convenience function that launches a headless browser.
func (*Vibe) AddInitScript ¶ added in v0.4.0
AddInitScript adds a script that will be evaluated in every page before any page scripts. This is useful for mocking APIs, injecting test helpers, or setting up authentication.
func (*Vibe) BringToFront ¶
BringToFront activates the page (brings the browser tab to front).
func (*Vibe) BrowserVersion ¶
BrowserVersion returns the browser version string.
func (*Vibe) BrowsingContext ¶ added in v0.4.0
BrowsingContext returns the browsing context ID for this page.
func (*Vibe) ClearConsoleMessages ¶ added in v0.4.0
ClearConsoleMessages clears the buffered console messages.
func (*Vibe) ClearNetworkRequests ¶ added in v0.4.0
ClearNetworkRequests clears the buffered network requests.
func (*Vibe) ClearStorage ¶ added in v0.4.0
ClearStorage clears all cookies, localStorage, and sessionStorage.
func (*Vibe) ConsoleMessages ¶ added in v0.4.0
ConsoleMessages returns buffered console messages from the page. The level parameter filters messages by type (log, info, warn, error, debug). If level is empty, all messages are returned.
func (*Vibe) Context ¶
func (v *Vibe) Context() *BrowserContext
Context returns the browser context for this page. Returns nil if this is the default context.
func (*Vibe) EmulateMedia ¶
func (v *Vibe) EmulateMedia(ctx context.Context, opts EmulateMediaOptions) error
EmulateMedia sets the media emulation options.
func (*Vibe) Expose ¶
Expose exposes a function that can be called from JavaScript in the page. Note: The handler function must be registered separately.
func (*Vibe) FindAll ¶
FindAll finds all elements matching the selector and optional semantic options. If selector is empty but semantic options are provided, elements are found by those options.
func (*Vibe) GetDialog ¶ added in v0.4.0
func (v *Vibe) GetDialog(ctx context.Context) (DialogInfo, error)
GetDialog returns information about the current dialog, if any.
func (*Vibe) GetViewport ¶
GetViewport returns the current viewport dimensions.
func (*Vibe) GetWindow ¶
func (v *Vibe) GetWindow(ctx context.Context) (WindowState, error)
GetWindow returns the browser window state.
func (*Vibe) HandleDialog ¶ added in v0.4.0
HandleDialog handles the current dialog by accepting or dismissing it. If accept is true, the dialog is accepted. If promptText is provided (for prompt dialogs), it will be entered before accepting.
func (*Vibe) ListRoutes ¶ added in v0.4.0
ListRoutes returns all active route handlers.
func (*Vibe) MockRoute ¶ added in v0.4.0
MockRoute registers a route that returns a static mock response. This is useful for MCP tools and testing without callbacks.
func (*Vibe) NetworkRequests ¶ added in v0.4.0
func (v *Vibe) NetworkRequests(ctx context.Context, opts *NetworkRequestsOptions) ([]NetworkRequest, error)
NetworkRequests returns buffered network requests from the page. Options can filter by URL pattern, method, or resource type.
func (*Vibe) NewContext ¶
func (v *Vibe) NewContext(ctx context.Context) (*BrowserContext, error)
NewContext creates a new isolated browser context.
func (*Vibe) OnConsole ¶
func (v *Vibe) OnConsole(ctx context.Context, handler ConsoleHandler) error
OnConsole registers a handler for console messages.
func (*Vibe) OnDialog ¶
func (v *Vibe) OnDialog(ctx context.Context, handler DialogHandler) error
OnDialog registers a handler for dialogs (alert, confirm, prompt).
func (*Vibe) OnDownload ¶
func (v *Vibe) OnDownload(ctx context.Context, handler DownloadHandler) error
OnDownload registers a handler for downloads.
func (*Vibe) OnRequest ¶
func (v *Vibe) OnRequest(ctx context.Context, handler RequestHandler) error
OnRequest registers a handler for network requests. Note: This is a convenience method; for full control use Route().
func (*Vibe) OnResponse ¶
func (v *Vibe) OnResponse(ctx context.Context, handler ResponseHandler) error
OnResponse registers a handler for network responses.
func (*Vibe) Route ¶
Route registers a handler for requests matching the URL pattern. The pattern can be a glob pattern (e.g., "**/*.png") or regex (e.g., "/api/.*").
func (*Vibe) Screenshot ¶
Screenshot captures a screenshot of the current page and returns PNG data.
func (*Vibe) Scroll ¶ added in v0.4.0
Scroll scrolls the page or a specific element. direction can be "up", "down", "left", or "right". amount is the number of pixels to scroll (use 0 for full page).
func (*Vibe) SetContent ¶
SetContent sets the HTML content of the page.
func (*Vibe) SetExtraHTTPHeaders ¶
SetExtraHTTPHeaders sets extra HTTP headers that will be sent with every request.
func (*Vibe) SetGeolocation ¶
func (v *Vibe) SetGeolocation(ctx context.Context, coords Geolocation) error
SetGeolocation overrides the browser's geolocation.
func (*Vibe) SetOffline ¶ added in v0.4.0
SetOffline sets the browser's offline mode.
func (*Vibe) SetStorageState ¶ added in v0.4.0
func (v *Vibe) SetStorageState(ctx context.Context, state *StorageState) error
SetStorageState restores browser storage state from a previously saved StorageState. This includes cookies, localStorage, and sessionStorage. The browser should be on a page (or will be navigated to the first origin) for storage to be set correctly.
func (*Vibe) SetViewport ¶
SetViewport sets the viewport dimensions.
func (*Vibe) SetWindow ¶
func (v *Vibe) SetWindow(ctx context.Context, opts SetWindowOptions) error
SetWindow sets the browser window state.
func (*Vibe) StorageState ¶ added in v0.4.0
func (v *Vibe) StorageState(ctx context.Context) (*StorageState, error)
StorageState returns the complete browser storage state including cookies, localStorage, and sessionStorage for the current page's origin. This can be saved and later restored using SetStorageState to resume a session.
func (*Vibe) Tracing ¶ added in v0.4.0
Tracing returns a tracing controller for the default browser context. Use this to record traces for debugging and analysis.
func (*Vibe) WaitForFunction ¶
WaitForFunction waits for a JavaScript function to return a truthy value.
func (*Vibe) WaitForLoad ¶
WaitForLoad waits for the page to reach the specified load state. State can be: "load", "domcontentloaded", "networkidle".
func (*Vibe) WaitForNavigation ¶
WaitForNavigation waits for a navigation to complete.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
genscriptschema
command
Command genscriptschema generates JSON Schema from Go types.
|
Command genscriptschema generates JSON Schema from Go types. |
|
vibium
command
Command vibium provides a CLI for browser automation.
|
Command vibium provides a CLI for browser automation. |
|
vibium-mcp
command
Command vibium-mcp provides an MCP server for browser automation.
|
Command vibium-mcp provides an MCP server for browser automation. |
|
vibium-rpa
command
|
|
|
Package mcp provides an MCP (Model Context Protocol) server for browser automation.
|
Package mcp provides an MCP (Model Context Protocol) server for browser automation. |
|
report
Package report provides test result tracking and report generation.
|
Package report provides test result tracking and report generation. |
|
Package rpa provides a Robotic Process Automation platform for browser automation.
|
Package rpa provides a Robotic Process Automation platform for browser automation. |
|
activity
Package activity provides the activity system for RPA workflow execution.
|
Package activity provides the activity system for RPA workflow execution. |
|
Package script defines the test script format for Vibium automation.
|
Package script defines the test script format for Vibium automation. |