Documentation
¶
Index ¶
- Constants
- func FindChromeBinary() (string, error)
- type Browser
- type Client
- func (c *Client) CapturePNGScreenshot(ctx context.Context) ([]byte, error)
- func (c *Client) Close() error
- func (c *Client) Evaluate(ctx context.Context, expression string, awaitPromise bool, out any) error
- func (c *Client) Navigate(ctx context.Context, url string) error
- func (c *Client) SetViewportSize(ctx context.Context, width, height int) error
- type TransportError
Constants ¶
const DefaultStartTimeout = 30 * time.Second
DefaultStartTimeout is the default timeout for launching the headless Chrome process.
Variables ¶
This section is empty.
Functions ¶
func FindChromeBinary ¶
FindChromeBinary locates a Chrome or Chromium executable from CHROME_BIN or standard PATH names.
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser manages a headless Chrome process and its Chrome DevTools Protocol page endpoint.
func NewBrowserFromPageWSURL ¶
NewBrowserFromPageWSURL creates a Browser targeting an existing CDP page WebSocket endpoint without managing a process.
func StartBrowser ¶
StartBrowser launches a headless Chrome process immediately and resolves its initial page WebSocket URL.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages a single Chrome DevTools Protocol WebSocket connection.
func (*Client) CapturePNGScreenshot ¶
CapturePNGScreenshot captures a PNG screenshot of the current page and returns the decoded PNG bytes.
func (*Client) Evaluate ¶
Evaluate executes a JavaScript expression via Runtime.evaluate and decodes the returned value into out.
type TransportError ¶
type TransportError struct {
// Err is the underlying WebSocket transport error.
Err error
}
TransportError wraps WebSocket send and receive failures so callers can distinguish unrecoverable connection errors from transient CDP protocol or JavaScript evaluation errors.
func (*TransportError) Error ¶
func (e *TransportError) Error() string
Error returns the string representation of the underlying transport error.
func (*TransportError) Unwrap ¶
func (e *TransportError) Unwrap() error
Unwrap returns the underlying transport error for errors.Is and errors.As checks.