Documentation
¶
Overview ¶
Package webpilot provides a Go client for the WebPilot browser automation platform.
WebPilot 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()
pilot, err := webpilot.Launch(ctx)
if err != nil {
log.Fatal(err)
}
defer pilot.Quit(ctx)
if err := pilot.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 := pilot.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 := pilot.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 := pilot.Screenshot(ctx)
if err != nil {
log.Fatal(err)
}
os.WriteFile("screenshot.png", data, 0644)
Headless Mode ¶
Launch in headless mode for CI/server environments:
pilot, err := webpilot.LaunchHeadless(ctx)
Or with explicit options:
pilot, err := webpilot.Browser.Launch(ctx, &webpilot.LaunchOptions{
Headless: true,
Port: 9515,
})
Requirements ¶
This client requires Chrome or Chromium. If Chrome is not found on your system, it will automatically download Chrome for Testing from Google's official API.
You can also specify a custom Chrome path via the CHROME_PATH environment variable or the ExecutablePath option in LaunchOptions.
Package webpilot provides a Go client for browser automation using the WebDriver BiDi protocol. It launches Chrome with BiDi support and communicates over WebSocket.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/plexusone/webpilot"
)
func main() {
ctx := context.Background()
// Launch browser
pilot, err := webpilot.Launch(ctx)
if err != nil {
log.Fatal(err)
}
defer func() { _ = pilot.Quit(ctx) }()
// Navigate to a page
if err := pilot.Go(ctx, "https://example.com"); err != nil {
log.Fatal(err)
}
// Find and click a link
link, err := pilot.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 := pilot.Title(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println("Page title:", title)
}
Output:
Example (FormInteraction) ¶
package main
import (
"context"
"log"
"github.com/plexusone/webpilot"
)
func main() {
ctx := context.Background()
pilot, err := webpilot.Browser.Launch(ctx, &webpilot.LaunchOptions{
Headless: true,
})
if err != nil {
log.Fatal(err)
}
defer func() { _ = pilot.Quit(ctx) }()
// Navigate to a form page
if err := pilot.Go(ctx, "https://example.com/login"); err != nil {
log.Fatal(err)
}
// Fill in username
username, err := pilot.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 := pilot.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 := pilot.Find(ctx, "button[type='submit']", nil)
if err != nil {
log.Fatal(err)
}
if err := submit.Click(ctx, nil); err != nil {
log.Fatal(err)
}
}
Output:
Example (Headless) ¶
package main
import (
"context"
"log"
"os"
"github.com/plexusone/webpilot"
)
func main() {
ctx := context.Background()
// Launch headless browser
pilot, err := webpilot.LaunchHeadless(ctx)
if err != nil {
log.Fatal(err)
}
defer func() { _ = pilot.Quit(ctx) }()
// Navigate
if err := pilot.Go(ctx, "https://example.com"); err != nil {
log.Fatal(err)
}
// Take screenshot
data, err := pilot.Screenshot(ctx)
if err != nil {
log.Fatal(err)
}
// Save to file
if err := os.WriteFile("screenshot.png", data, 0600); err != nil {
log.Fatal(err)
}
}
Output:
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 A11yTreeOptions
- type ActionOptions
- type BiDiClient
- func (c *BiDiClient) Close() error
- func (c *BiDiClient) Connect(ctx context.Context, url string) error
- func (c *BiDiClient) OnEvent(method string, handler EventHandler)
- func (c *BiDiClient) RemoveEventHandlers(method string)
- func (c *BiDiClient) Send(ctx context.Context, method string, params interface{}) (json.RawMessage, error)
- type BiDiCommand
- type BiDiError
- type BiDiEvent
- 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) DeleteCookie(ctx context.Context, name string, domain string, path string) error
- func (c *BrowserContext) GrantPermissions(ctx context.Context, permissions []string, origin string) error
- func (c *BrowserContext) NewPage(ctx context.Context) (*Pilot, 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 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) Highlight(ctx context.Context, opts *HighlightOptions) 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 EventHandler
- type FindOptions
- type FrameInfo
- type FulfillOptions
- type Geolocation
- type HighlightOptions
- 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 PageError
- type PageErrorHandler
- type PageHandler
- type Pilot
- func (p *Pilot) A11yTree(ctx context.Context, opts *A11yTreeOptions) (interface{}, error)
- func (p *Pilot) AddInitScript(ctx context.Context, script string) error
- func (p *Pilot) AddScript(ctx context.Context, source string) error
- func (p *Pilot) AddStyle(ctx context.Context, source string) error
- func (p *Pilot) Back(ctx context.Context) error
- func (p *Pilot) BringToFront(ctx context.Context) error
- func (p *Pilot) BrowserVersion(ctx context.Context) (string, error)
- func (p *Pilot) BrowsingContext() string
- func (p *Pilot) ClearConsoleMessages(ctx context.Context) error
- func (p *Pilot) ClearErrors(ctx context.Context) error
- func (p *Pilot) ClearNetworkRequests(ctx context.Context) error
- func (p *Pilot) ClearStorage(ctx context.Context) error
- func (p *Pilot) Clock(ctx context.Context) (*Clock, error)
- func (p *Pilot) Close(ctx context.Context) error
- func (p *Pilot) CollectConsole(ctx context.Context) error
- func (p *Pilot) CollectErrors(ctx context.Context) error
- func (p *Pilot) ConsoleMessages(ctx context.Context, level string) ([]ConsoleMessage, error)
- func (p *Pilot) Content(ctx context.Context) (string, error)
- func (p *Pilot) Context() *BrowserContext
- func (p *Pilot) EmulateMedia(ctx context.Context, opts EmulateMediaOptions) error
- func (p *Pilot) Errors(ctx context.Context) ([]PageError, error)
- func (p *Pilot) Evaluate(ctx context.Context, script string) (interface{}, error)
- func (p *Pilot) Expose(ctx context.Context, name string) error
- func (p *Pilot) Find(ctx context.Context, selector string, opts *FindOptions) (*Element, error)
- func (p *Pilot) FindAll(ctx context.Context, selector string, opts *FindOptions) ([]*Element, error)
- func (p *Pilot) Forward(ctx context.Context) error
- func (p *Pilot) Frame(ctx context.Context, nameOrURL string) (*Pilot, error)
- func (p *Pilot) Frames(ctx context.Context) ([]FrameInfo, error)
- func (p *Pilot) GetDialog(ctx context.Context) (DialogInfo, error)
- func (p *Pilot) GetViewport(ctx context.Context) (Viewport, error)
- func (p *Pilot) GetWindow(ctx context.Context) (WindowState, error)
- func (p *Pilot) Go(ctx context.Context, url string) error
- func (p *Pilot) HandleDialog(ctx context.Context, accept bool, promptText string) error
- func (p *Pilot) IsClosed() bool
- func (p *Pilot) Keyboard(ctx context.Context) (*Keyboard, error)
- func (p *Pilot) ListRoutes(ctx context.Context) ([]RouteInfo, error)
- func (p *Pilot) MainFrame() *Pilot
- func (p *Pilot) MockRoute(ctx context.Context, pattern string, opts MockRouteOptions) error
- func (p *Pilot) Mouse(ctx context.Context) (*Mouse, error)
- func (p *Pilot) MustFind(ctx context.Context, selector string) *Element
- func (p *Pilot) NetworkRequests(ctx context.Context, opts *NetworkRequestsOptions) ([]NetworkRequest, error)
- func (p *Pilot) NewContext(ctx context.Context) (*BrowserContext, error)
- func (p *Pilot) NewPage(ctx context.Context) (*Pilot, error)
- func (p *Pilot) OnConsole(ctx context.Context, handler ConsoleHandler) error
- func (p *Pilot) OnDialog(ctx context.Context, handler DialogHandler) error
- func (p *Pilot) OnDownload(ctx context.Context, handler DownloadHandler) error
- func (p *Pilot) OnError(ctx context.Context, handler PageErrorHandler) error
- func (p *Pilot) OnPage(ctx context.Context, handler PageHandler) error
- func (p *Pilot) OnPopup(ctx context.Context, handler PopupHandler) error
- func (p *Pilot) OnRequest(ctx context.Context, handler RequestHandler) error
- func (p *Pilot) OnResponse(ctx context.Context, handler ResponseHandler) error
- func (p *Pilot) OnWebSocket(ctx context.Context, handler WebSocketHandler) error
- func (p *Pilot) PDF(ctx context.Context, opts *PDFOptions) ([]byte, error)
- func (p *Pilot) Pages(ctx context.Context) ([]*Pilot, error)
- func (p *Pilot) Quit(ctx context.Context) error
- func (p *Pilot) Reload(ctx context.Context) error
- func (p *Pilot) RemoveAllListeners()
- func (p *Pilot) Route(ctx context.Context, pattern string, handler RouteHandler) error
- func (p *Pilot) Screenshot(ctx context.Context) ([]byte, error)
- func (p *Pilot) Scroll(ctx context.Context, direction string, amount int, opts *ScrollOptions) error
- func (p *Pilot) SetContent(ctx context.Context, html string) error
- func (p *Pilot) SetExtraHTTPHeaders(ctx context.Context, headers map[string]string) error
- func (p *Pilot) SetGeolocation(ctx context.Context, coords Geolocation) error
- func (p *Pilot) SetOffline(ctx context.Context, offline bool) error
- func (p *Pilot) SetStorageState(ctx context.Context, state *StorageState) error
- func (p *Pilot) SetViewport(ctx context.Context, viewport Viewport) error
- func (p *Pilot) SetWindow(ctx context.Context, opts SetWindowOptions) error
- func (p *Pilot) StartVideo(ctx context.Context, opts *VideoOptions) (*Video, error)
- func (p *Pilot) StopVideo(ctx context.Context) (string, error)
- func (p *Pilot) StorageState(ctx context.Context) (*StorageState, error)
- func (p *Pilot) Title(ctx context.Context) (string, error)
- func (p *Pilot) Touch(ctx context.Context) (*Touch, error)
- func (p *Pilot) Tracing() *Tracing
- func (p *Pilot) URL(ctx context.Context) (string, error)
- func (p *Pilot) Unroute(ctx context.Context, pattern string) error
- func (p *Pilot) WaitForFunction(ctx context.Context, fn string, timeout time.Duration) error
- func (p *Pilot) WaitForLoad(ctx context.Context, state string, timeout time.Duration) error
- func (p *Pilot) WaitForNavigation(ctx context.Context, timeout time.Duration) error
- func (p *Pilot) WaitForURL(ctx context.Context, pattern string, timeout time.Duration) error
- type PopupHandler
- 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 Video
- type VideoOptions
- type VideoSize
- type Viewport
- type WebSocketCloseHandler
- type WebSocketHandler
- type WebSocketInfo
- type WebSocketMessage
- type WebSocketMessageHandler
- 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 browser") // 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") // ErrBrowserNotFound is returned when Chrome cannot be found. ErrBrowserNotFound = errors.New("Chrome not found") // ErrClickerNotFound is deprecated: use ErrBrowserNotFound instead. // Deprecated: This error is no longer used. Use ErrBrowserNotFound. ErrClickerNotFound = ErrBrowserNotFound // 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 WEBPILOT_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 A11yTreeOptions ¶
type A11yTreeOptions struct {
// InterestingOnly filters the tree to only include interesting nodes.
// Interesting nodes are those with semantic meaning (roles, names, states).
// Default is true.
InterestingOnly *bool
// Root specifies a CSS selector for the root element.
// If specified, only the subtree under this element is returned.
Root string
}
A11yTreeOptions configures accessibility tree retrieval.
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 Chrome's BiDi 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 Chrome's BiDi server.
func (*BiDiClient) OnEvent ¶
func (c *BiDiClient) OnEvent(method string, handler EventHandler)
OnEvent registers a handler for events matching the given method pattern. The method can be an exact match (e.g., "log.entryAdded") or a prefix (e.g., "log." to match all log events).
func (*BiDiClient) RemoveEventHandlers ¶
func (c *BiDiClient) RemoveEventHandlers(method string)
RemoveEventHandlers removes all handlers for the given method.
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 BiDiEvent ¶
type BiDiEvent struct {
Method string `json:"method"`
Params json.RawMessage `json:"params"`
}
BiDiEvent represents a WebDriver BiDi event.
type BiDiResponse ¶
type BiDiResponse struct {
ID int64 `json:"id"`
Type string `json:"type"`
Method string `json:"method,omitempty"` // For events
Result json.RawMessage `json:"result,omitempty"`
Params json.RawMessage `json:"params,omitempty"` // For events
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) DeleteCookie ¶
func (c *BrowserContext) DeleteCookie(ctx context.Context, name string, domain string, path string) error
DeleteCookie deletes a specific cookie by name. Optional domain and path can be specified to target a specific cookie.
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) (*Pilot, 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 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 ¶
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 ¶
Find finds a child element within this element by CSS selector or semantic options.
func (*Element) FindAll ¶
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) Highlight ¶
func (e *Element) Highlight(ctx context.Context, opts *HighlightOptions) error
Highlight draws a visual overlay on the element for debugging. The highlight is displayed for the specified duration (default 2 seconds). This is useful for visual debugging to see which element is being targeted.
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 EventHandler ¶
type EventHandler func(event *BiDiEvent)
EventHandler is a callback for handling BiDi events.
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 HighlightOptions ¶
type HighlightOptions struct {
// Color is the highlight border color (CSS color value).
// Default is "red".
Color string
// Duration is how long to show the highlight in milliseconds.
// Default is 2000 (2 seconds). Use 0 for persistent highlight.
Duration int
}
HighlightOptions configures element highlighting.
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 debugging port. If 0, an available port is auto-selected.
Port int
// ExecutablePath specifies a custom Chrome executable path.
ExecutablePath string
// UserDataDir specifies a custom user data directory.
// If empty, a temporary directory is used.
UserDataDir string
// Args specifies additional command-line arguments for Chrome.
Args []string
// AutoInstall automatically downloads Chrome for Testing if not found.
// Defaults to true (nil means true).
AutoInstall *bool
}
LaunchOptions configures browser launch behavior.
type MockRouteOptions ¶
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 ¶
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 ¶
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 PageError ¶
type PageError struct {
Message string `json:"message"`
Stack string `json:"stack,omitempty"`
URL string `json:"url,omitempty"`
Line int `json:"line,omitempty"`
Column int `json:"column,omitempty"`
}
PageError represents a JavaScript error that occurred on the page.
type PageErrorHandler ¶
type PageErrorHandler func(*PageError)
PageErrorHandler is called when a JavaScript error occurs on the page.
type Pilot ¶
type Pilot struct {
// contains filtered or unexported fields
}
Pilot is the main browser control interface.
func LaunchHeadless ¶
LaunchHeadless is a convenience function that launches a headless browser.
func (*Pilot) A11yTree ¶
func (p *Pilot) A11yTree(ctx context.Context, opts *A11yTreeOptions) (interface{}, error)
A11yTree returns the accessibility tree for the page. Options can filter the tree to only interesting nodes or specify a root element.
func (*Pilot) AddInitScript ¶
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 (*Pilot) BringToFront ¶
BringToFront activates the page (brings the browser tab to front).
func (*Pilot) BrowserVersion ¶
BrowserVersion returns the browser version string.
func (*Pilot) BrowsingContext ¶
BrowsingContext returns the browsing context ID for this page.
func (*Pilot) ClearConsoleMessages ¶
ClearConsoleMessages clears the buffered console messages.
func (*Pilot) ClearErrors ¶
ClearErrors clears the buffered page errors.
func (*Pilot) ClearNetworkRequests ¶
ClearNetworkRequests clears the buffered network requests.
func (*Pilot) ClearStorage ¶
ClearStorage clears all cookies, localStorage, and sessionStorage.
func (*Pilot) CollectConsole ¶
CollectConsole enables buffered console message collection. Messages can be retrieved with ConsoleMessages() and cleared with ClearConsoleMessages().
func (*Pilot) CollectErrors ¶
CollectErrors enables buffered page error collection. Errors can be retrieved with Errors() and cleared with ClearErrors().
func (*Pilot) ConsoleMessages ¶
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 (*Pilot) Context ¶
func (p *Pilot) Context() *BrowserContext
Context returns the browser context for this page. Returns nil if this is the default context.
func (*Pilot) EmulateMedia ¶
func (p *Pilot) EmulateMedia(ctx context.Context, opts EmulateMediaOptions) error
EmulateMedia sets the media emulation options.
func (*Pilot) Errors ¶
Errors retrieves buffered page errors. Call CollectErrors() first to enable error collection.
func (*Pilot) Expose ¶
Expose exposes a function that can be called from JavaScript in the page. Note: The handler function must be registered separately.
func (*Pilot) FindAll ¶
func (p *Pilot) FindAll(ctx context.Context, selector string, opts *FindOptions) ([]*Element, error)
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 (*Pilot) GetDialog ¶
func (p *Pilot) GetDialog(ctx context.Context) (DialogInfo, error)
GetDialog returns information about the current dialog, if any.
func (*Pilot) GetViewport ¶
GetViewport returns the current viewport dimensions.
func (*Pilot) GetWindow ¶
func (p *Pilot) GetWindow(ctx context.Context) (WindowState, error)
GetWindow returns the browser window state.
func (*Pilot) HandleDialog ¶
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 (*Pilot) ListRoutes ¶
ListRoutes returns all active route handlers.
func (*Pilot) MainFrame ¶
MainFrame returns the main frame of the page. Since Pilot represents both page and frame in this SDK, it returns itself. This method exists for API compatibility with other WebPilot clients.
func (*Pilot) MockRoute ¶
MockRoute registers a route that returns a static mock response. This is useful for MCP tools and testing without callbacks.
func (*Pilot) NetworkRequests ¶
func (p *Pilot) 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 (*Pilot) NewContext ¶
func (p *Pilot) NewContext(ctx context.Context) (*BrowserContext, error)
NewContext creates a new isolated browser context.
func (*Pilot) OnConsole ¶
func (p *Pilot) OnConsole(ctx context.Context, handler ConsoleHandler) error
OnConsole registers a handler for console messages.
func (*Pilot) OnDialog ¶
func (p *Pilot) OnDialog(ctx context.Context, handler DialogHandler) error
OnDialog registers a handler for dialogs (alert, confirm, prompt).
func (*Pilot) OnDownload ¶
func (p *Pilot) OnDownload(ctx context.Context, handler DownloadHandler) error
OnDownload registers a handler for downloads.
func (*Pilot) OnError ¶
func (p *Pilot) OnError(ctx context.Context, handler PageErrorHandler) error
OnError registers a handler for JavaScript errors on the page.
func (*Pilot) OnPage ¶
func (p *Pilot) OnPage(ctx context.Context, handler PageHandler) error
OnPage registers a handler that is called when a new page is created in the browser. This includes pages created via NewPage(), window.open(), or clicking links with target="_blank".
func (*Pilot) OnPopup ¶
func (p *Pilot) OnPopup(ctx context.Context, handler PopupHandler) error
OnPopup registers a handler that is called when a popup window is opened. Popups are typically created via window.open() with specific features.
func (*Pilot) OnRequest ¶
func (p *Pilot) 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 (*Pilot) OnResponse ¶
func (p *Pilot) OnResponse(ctx context.Context, handler ResponseHandler) error
OnResponse registers a handler for network responses.
func (*Pilot) OnWebSocket ¶
func (p *Pilot) OnWebSocket(ctx context.Context, handler WebSocketHandler) error
OnWebSocket registers a handler that is called when the page opens a WebSocket connection.
func (*Pilot) RemoveAllListeners ¶
func (p *Pilot) RemoveAllListeners()
RemoveAllListeners removes all registered event listeners. This is useful for cleanup when you no longer need to receive events.
func (*Pilot) 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 (*Pilot) Screenshot ¶
Screenshot captures a screenshot of the current page and returns PNG data.
func (*Pilot) Scroll ¶
func (p *Pilot) Scroll(ctx context.Context, direction string, amount int, opts *ScrollOptions) error
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 (*Pilot) SetContent ¶
SetContent sets the HTML content of the page.
func (*Pilot) SetExtraHTTPHeaders ¶
SetExtraHTTPHeaders sets extra HTTP headers that will be sent with every request.
func (*Pilot) SetGeolocation ¶
func (p *Pilot) SetGeolocation(ctx context.Context, coords Geolocation) error
SetGeolocation overrides the browser's geolocation.
func (*Pilot) SetOffline ¶
SetOffline sets the browser's offline mode.
func (*Pilot) SetStorageState ¶
func (p *Pilot) 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 (*Pilot) SetViewport ¶
SetViewport sets the viewport dimensions.
func (*Pilot) SetWindow ¶
func (p *Pilot) SetWindow(ctx context.Context, opts SetWindowOptions) error
SetWindow sets the browser window state.
func (*Pilot) StartVideo ¶
StartVideo starts recording video of the page. The video is saved when StopVideo is called or the browser closes.
func (*Pilot) StorageState ¶
func (p *Pilot) 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 (*Pilot) Tracing ¶
Tracing returns a tracing controller for the default browser context. Use this to record traces for debugging and analysis.
func (*Pilot) WaitForFunction ¶
WaitForFunction waits for a JavaScript function to return a truthy value.
func (*Pilot) WaitForLoad ¶
WaitForLoad waits for the page to reach the specified load state. State can be: "load", "domcontentloaded", "networkidle".
func (*Pilot) WaitForNavigation ¶
WaitForNavigation waits for a navigation to complete.
type PopupHandler ¶
type PopupHandler func(*Pilot)
PopupHandler is called when a popup window opens.
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 ¶
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 ¶
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 Video ¶
type Video struct {
// FilePath is the file path where the video will be saved.
FilePath string `json:"path,omitempty"`
// contains filtered or unexported fields
}
Video represents an ongoing or completed video recording.
type VideoOptions ¶
type VideoOptions struct {
// Dir is the directory to save videos to. Defaults to a temp directory.
Dir string `json:"dir,omitempty"`
// Size specifies the video dimensions. Defaults to viewport size.
Size *VideoSize `json:"size,omitempty"`
}
VideoOptions configures video recording.
type WebSocketCloseHandler ¶
WebSocketCloseHandler is called when a WebSocket connection is closed.
type WebSocketHandler ¶
type WebSocketHandler func(*WebSocketInfo)
WebSocketHandler is called when a new WebSocket connection is opened.
type WebSocketInfo ¶
type WebSocketInfo struct {
URL string `json:"url"`
IsClosed bool `json:"isClosed"`
// contains filtered or unexported fields
}
WebSocketInfo represents a WebSocket connection made by the page.
func (*WebSocketInfo) OnClose ¶
func (ws *WebSocketInfo) OnClose(handler WebSocketCloseHandler)
OnClose registers a handler for when the WebSocket closes.
func (*WebSocketInfo) OnMessage ¶
func (ws *WebSocketInfo) OnMessage(handler WebSocketMessageHandler)
OnMessage registers a handler for WebSocket messages.
type WebSocketMessage ¶
type WebSocketMessage struct {
SocketID string `json:"socketId"`
Data string `json:"data"`
IsBinary bool `json:"isBinary"`
Direction string `json:"direction"` // "sent" or "received"
}
WebSocketMessage represents a message sent or received on a WebSocket.
type WebSocketMessageHandler ¶
type WebSocketMessageHandler func(*WebSocketMessage)
WebSocketMessageHandler is called when a WebSocket message is sent or received.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
genscriptschema
command
Command genscriptschema generates JSON Schema from Go types.
|
Command genscriptschema generates JSON Schema from Go types. |
|
webpilot
command
Command webpilot provides a CLI for browser automation.
|
Command webpilot provides a CLI for browser automation. |
|
webpilot-mcp
command
Command webpilot-mcp provides an MCP server for browser automation.
|
Command webpilot-mcp provides an MCP server for browser automation. |
|
webpilot-rpa
command
|
|
|
Package launcher provides Chrome browser launching and installation.
|
Package launcher provides Chrome browser launching and installation. |
|
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. |