dgodriver

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: AGPL-3.0 Imports: 31 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

dgodriver

Go Reference Build

A Go library for controlling Chromium-based browsers directly through the Chrome DevTools Protocol (CDP). dgodriver brings the browser automation capabilities of nodriver and zendriver to Go, with context-aware operations and typed CDP APIs. It does not require Selenium or ChromeDriver.

The project is at an early stage (v0.1.0); APIs and browser compatibility may change as it develops.

Use cases

dgodriver is intended for legitimate browser automation, especially:

  • End-to-end and regression testing of web applications you own or are authorized to test.
  • Reproducing browser bugs and debugging web applications with a real Chromium engine.
  • Testing network behavior, including observing requests and mocking responses in controlled environments.
  • Automating internal workflows on systems where you have permission.
  • Learning and experimenting with CDP.

It is a general-purpose browser control library. It does not grant access to any website or account, and it cannot guarantee that a site will allow automation.

Requirements

  • Go 1.24 or later.
  • Google Chrome, Chromium, Microsoft Edge, or Brave.

The library launches a local browser or connects to an existing Chromium browser over its CDP endpoint. Supported behavior can vary by browser and browser version.

Install

go get github.com/aijiesd520/dgodriver

Quick start

package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/aijiesd520/dgodriver"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
	defer cancel()

	browser, err := dgodriver.Start(ctx, dgodriver.Config{Headless: true})
	if err != nil {
		log.Fatal(err)
	}
	defer browser.Close()

	tab, err := browser.Get(ctx, "https://example.com")
	if err != nil {
		log.Fatal(err)
	}

	var title string
	if err := tab.Evaluate(ctx, "document.title", &title); err != nil {
		log.Fatal(err)
	}
	fmt.Println(title)
}

Run the included examples from a checkout:

go run ./examples/basic
go run ./examples/network

Capabilities

  • Launch or attach to Chromium-based browsers, use temporary or persistent profiles, and manage tabs, windows, browser contexts, permissions, and extensions.
  • Typed CDP commands, events, parameters, and results. The checked-in CDP snapshot contains 56 domains generated from the protocol bindings in zendriver 0.17.1.
  • Navigate pages; query by CSS, XPath, or text; evaluate JavaScript; interact with DOM elements, Shadow DOM, and frames.
  • Dispatch keyboard and mouse input, upload files, and work with form controls.
  • Subscribe to browser events, wait for requests and responses, and intercept or fulfill network requests.
  • Configure authenticated HTTP, HTTPS, and SOCKS5 proxies for isolated browser contexts.
  • Manage cookies and local storage, and set a User-Agent.
  • Capture screenshots, print pages to PDF, save MHTML snapshots, download files, and record WebM video where the browser and platform permit it.
  • Locate and attempt the supported interactive Cloudflare checkbox flow in authorized testing environments. Provider behavior can change, success is not guaranteed, and the helper does not grant permission to evade site access policies.

See API_PARITY.md for a detailed mapping from zendriver APIs to their Go counterparts.

Browser configuration notes

Config{Headless: true} launches Chromium in headless mode. In headless mode, dgodriver removes the Headless token from the User-Agent it reads from the browser unless you provide a custom User-Agent.

Config{Expert: true} injects a script that makes newly created Shadow DOM roots open, so automation code can inspect them. These options are convenience and debugging features, not a comprehensive stealth or fingerprint-masking system. Websites may still identify automation or restrict access.

Responsible use and disclaimer

You are responsible for how you use this software. Before automating a third-party site, review and follow that site's Terms of Service, automation and access policies, and rate limits. Obtain permission when required. Comply with all applicable local, national, and international laws, including laws concerning computer access, privacy, personal data, and intellectual property.

Use dgodriver only with systems, accounts, and data that you own or are authorized to access. Do not use it to bypass authentication, access controls, paywalls, rate limits, CAPTCHAs, anti-bot protections, or other security measures, or to collect data without the required rights or legal basis. The presence of an API or example in this project is not authorization to use it against a service.

This software is provided "AS IS", without warranties of any kind, express or implied. To the extent permitted by law, the authors and maintainers disclaim liability for claims, damages, or other consequences arising from its use or misuse. This notice is not legal advice and does not replace your responsibility to assess whether a particular use is lawful and permitted.

Development

go test ./...
go vet ./...
go generate ./cdp

Some browser integration checks require a Chromium installation. The GitHub Actions workflow runs the test suite and checks that generated CDP bindings are reproducible.

License and acknowledgements

This project is distributed under the GNU Affero General Public License, version 3 (AGPL-3.0). See LICENSE and NOTICE for license and attribution details.

dgodriver is based on the work of the nodriver and zendriver projects. The CDP bindings are generated from a checked-in protocol snapshot and reference declarations from zendriver 0.17.1. github.com/gorilla/websocket is used for WebSocket transport.

Star history

Star History Chart

Documentation

Overview

Package dgodriver controls Chromium browsers directly over Chrome DevTools Protocol, without WebDriver. It ports the browser automation features of zendriver 0.17.1 to Go. Use Start to launch, Browser.Get to navigate, and Tab.Select to obtain an Element. All I/O accepts context.Context. Close the browser, event subscriptions, expectations and interceptors when finished.

Index

Constants

View Source
const Version = "0.1.0"
View Source
const ZendriverVersion = "0.17.1"

Variables

View Source
var ErrClosed = errors.New("dgodriver: connection closed")
View Source
var ErrNotFound = errors.New("dgodriver: element not found")

Functions

func Circle

func Circle(x, y, radius float64, num int, clockwise bool) [][2]float64

func CompareTargetInfo

func CompareTargetInfo(a, b cdp.TargetTargetInfo) map[string][2]any

func FilterNodes

func FilterNodes(root cdp.DOMNode, predicate func(cdp.DOMNode) bool) []cdp.DOMNode

func FindExecutable

func FindExecutable(browser string) (string, error)

func FlattenFrameTree

func FlattenFrameTree(tree cdp.PageFrameTree) []cdp.PageFrameTree

func MergeDisableFeaturesArgs

func MergeDisableFeaturesArgs(args []string) []string

func Sleep

func Sleep(ctx context.Context, duration time.Duration) error

func WalkNodes

func WalkNodes(root cdp.DOMNode, fn func(cdp.DOMNode))

Types

type Browser

type Browser struct {
	*Connection
	Config Config
	Info   BrowserInfo
	// contains filtered or unexported fields
}

func Connect

func Connect(ctx context.Context, websocketURL string) (*Browser, error)

func Start

func Start(ctx context.Context, configs ...Config) (_ *Browser, err error)

Start launches Chromium, or attaches when Config has Host+Port or WebSocketURL. ctx bounds startup; browser lifetime is explicitly managed by Close/Stop.

func (*Browser) Close

func (b *Browser) Close() error

func (*Browser) Contexts

func (b *Browser) Contexts() []*BrowserContext

func (*Browser) Cookies

func (b *Browser) Cookies() *CookieJar

func (*Browser) CreateContext

func (b *Browser) CreateContext(ctx context.Context, options ...ContextOptions) (*BrowserContext, error)

func (*Browser) Get

func (b *Browser) Get(ctx context.Context, url string, options ...NavigationOptions) (*Tab, error)

func (*Browser) GetTab

func (b *Browser) GetTab(ctx context.Context, text string) (*Tab, error)

func (*Browser) GrantAllPermissions

func (b *Browser) GrantAllPermissions(ctx context.Context) error

func (*Browser) GrantPermissions

func (b *Browser) GrantPermissions(ctx context.Context, permissions []cdp.BrowserPermissionType, origin string, contextID string) error

func (*Browser) HTTPGet

func (b *Browser) HTTPGet(ctx context.Context, endpoint string, out any) error

func (*Browser) MainTab

func (b *Browser) MainTab() *Tab

func (*Browser) NewTab

func (b *Browser) NewTab(ctx context.Context, url string, newWindow ...bool) (*Tab, error)

func (*Browser) Sleep

func (b *Browser) Sleep(ctx context.Context, d time.Duration) error

func (*Browser) Stop

func (b *Browser) Stop(ctx context.Context) error

func (*Browser) Stopped

func (b *Browser) Stopped() bool

func (*Browser) Tab

func (b *Browser) Tab(ctx context.Context, id string) (*Tab, error)

func (*Browser) Tabs

func (b *Browser) Tabs() []*Tab

func (*Browser) Targets

func (b *Browser) Targets() []*Tab

func (*Browser) TestConnection

func (b *Browser) TestConnection(ctx context.Context) error

func (*Browser) TileWindows

func (b *Browser) TileWindows(ctx context.Context, width, height, columns int) ([]WindowBounds, error)

TileWindows uses explicit screen bounds so it also works on remote/headless hosts.

func (*Browser) UpdateTargets

func (b *Browser) UpdateTargets(ctx context.Context) error

func (*Browser) WebSocketURL

func (b *Browser) WebSocketURL() string

type BrowserContext

type BrowserContext struct {
	ID      string
	Browser *Browser
	// contains filtered or unexported fields
}

func (*BrowserContext) Close

func (bc *BrowserContext) Close() error

func (*BrowserContext) Cookies

func (bc *BrowserContext) Cookies() *CookieJar

func (*BrowserContext) Dispose

func (bc *BrowserContext) Dispose(ctx context.Context) error

func (*BrowserContext) NewTab

func (bc *BrowserContext) NewTab(ctx context.Context, url string, newWindow ...bool) (*Tab, error)

type BrowserInfo

type BrowserInfo struct {
	Browser              string `json:"Browser"`
	ProtocolVersion      string `json:"Protocol-Version"`
	UserAgent            string `json:"User-Agent"`
	WebSocketDebuggerURL string `json:"webSocketDebuggerUrl"`
}

type CloudflareChallenge

type CloudflareChallenge struct{ Host, ShadowRoot, IFrame *Element }

type CloudflareOptions

type CloudflareOptions struct {
	Timeout, ClickDelay time.Duration
	ChallengeSelector   string
	FlashCorners        bool
}

type Config

type Config struct {
	BrowserExecutablePath string
	Browser               string // auto, chrome, brave, msedge, chromium
	UserDataDir           string
	Headless              bool
	NoSandbox             bool
	Expert                bool
	EnableWebRTC          bool
	DisableWebGL          bool
	UserAgent             string
	Lang                  string
	BrowserArgs           []string
	Extensions            []string
	Host                  string
	Port                  int
	WebSocketURL          string
	StartupTimeout        time.Duration
	HTTPTimeout           time.Duration
}

Config's zero value launches a visible Chromium browser with a temporary profile. Host and Port together attach to an existing browser; WebSocketURL attaches directly.

func (*Config) AddArgument

func (c *Config) AddArgument(arg string) error

func (*Config) AddExtension

func (c *Config) AddExtension(path string) error

func (Config) Arguments

func (c Config) Arguments() []string

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection is a browser connection or a flattened CDP target session. Concurrent Send calls are safe. Callbacks execute outside the WebSocket reader.

func Dial

func Dial(ctx context.Context, websocketURL string) (*Connection, error)

func (*Connection) AddHandler

func (c *Connection) AddHandler(ctx context.Context, method string, fn func(Event)) *Subscription

AddHandler registers without enabling a domain. Use On for automatic enable.

func (*Connection) Call

func (c *Connection) Call(ctx context.Context, method string, params any) (json.RawMessage, error)

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Closed

func (c *Connection) Closed() bool

func (*Connection) Disable

func (c *Connection) Disable(ctx context.Context, domain string) error

func (*Connection) Done

func (c *Connection) Done() <-chan struct{}

func (*Connection) Enable

func (c *Connection) Enable(ctx context.Context, domain string) error

func (*Connection) On

func (c *Connection) On(ctx context.Context, method string, fn func(Event)) (*Subscription, error)

func (*Connection) RemoveHandlers

func (c *Connection) RemoveHandlers(method string)

func (*Connection) Send

func (c *Connection) Send(ctx context.Context, method string, params, out any) error

func (*Connection) SessionID

func (c *Connection) SessionID() string

func (*Connection) Wait

func (c *Connection) Wait(ctx context.Context, idle time.Duration) error

type ContextOptions

type ContextOptions struct {
	ProxyServer                       string
	ProxyBypassList                   string
	ProxyTLSConfig                    *tls.Config
	OriginsWithUniversalNetworkAccess []string
	KeepOnDetach                      bool
}

type CookieJar

type CookieJar struct {
	// contains filtered or unexported fields
}

func (*CookieJar) Clear

func (j *CookieJar) Clear(ctx context.Context) error

func (*CookieJar) GetAll

func (j *CookieJar) GetAll(ctx context.Context) ([]cdp.NetworkCookie, error)

func (*CookieJar) HTTPCookies

func (j *CookieJar) HTTPCookies(ctx context.Context) ([]*http.Cookie, error)

func (*CookieJar) Load

func (j *CookieJar) Load(ctx context.Context, path string, pattern ...string) error

func (*CookieJar) Save

func (j *CookieJar) Save(ctx context.Context, path string, pattern ...string) error

func (*CookieJar) SetAll

func (j *CookieJar) SetAll(ctx context.Context, cookies []cdp.NetworkCookieParam) error

type DownloadExpectation

type DownloadExpectation struct {
	// contains filtered or unexported fields
}

func (*DownloadExpectation) Close

func (e *DownloadExpectation) Close() error

func (*DownloadExpectation) Wait

func (*DownloadExpectation) WaitBegin

func (e *DownloadExpectation) WaitBegin(ctx context.Context) (DownloadInfo, error)

type DownloadInfo

type DownloadInfo struct {
	GUID, URL, SuggestedFilename, Path string
	ReceivedBytes, TotalBytes          float64
}

type Element

type Element struct {
	// contains filtered or unexported fields
}

Element retains a backend node ID across DOM agent refreshes. Node() exposes all protocol metadata, including closed shadow roots and content documents.

func (*Element) Apply

func (e *Element) Apply(ctx context.Context, jsFunction string, out any, options ...EvaluateOptions) error

func (*Element) Attributes

func (e *Element) Attributes() map[string]string

func (*Element) Children

func (e *Element) Children() []*Element

func (*Element) ClearInput

func (e *Element) ClearInput(ctx context.Context) error

func (*Element) ClearInputByDeleting

func (e *Element) ClearInputByDeleting(ctx context.Context) error

func (*Element) Click

func (e *Element) Click(ctx context.Context) error

func (*Element) ContentDocument

func (e *Element) ContentDocument() *Element

func (*Element) Flash

func (e *Element) Flash(ctx context.Context, duration ...time.Duration) error

func (*Element) Focus

func (e *Element) Focus(ctx context.Context) error

func (*Element) Get

func (e *Element) Get(name string) string

func (*Element) GetFrame

func (e *Element) GetFrame(ctx context.Context) (*Tab, error)

func (*Element) GetHTML

func (e *Element) GetHTML(ctx context.Context) (string, error)

func (*Element) GetJSAttributes

func (e *Element) GetJSAttributes(ctx context.Context) (map[string]any, error)

func (*Element) GetPosition

func (e *Element) GetPosition(ctx context.Context, absolute ...bool) (Position, error)

func (*Element) HighlightOverlay

func (e *Element) HighlightOverlay(ctx context.Context) error

func (*Element) IsRecording

func (e *Element) IsRecording() bool

func (*Element) MouseClick

func (e *Element) MouseClick(ctx context.Context, options ...MouseOptions) error

func (*Element) MouseDrag

func (e *Element) MouseDrag(ctx context.Context, destination *Element, steps ...int) error

func (*Element) MouseMove

func (e *Element) MouseMove(ctx context.Context) error

func (*Element) Node

func (e *Element) Node() cdp.DOMNode

func (*Element) ObjectID

func (e *Element) ObjectID(ctx context.Context) (cdp.RuntimeRemoteObjectID, error)

func (*Element) Parent

func (e *Element) Parent(ctx context.Context) (*Element, error)

func (*Element) PressKey

func (e *Element) PressKey(ctx context.Context, key string, modifiers ...KeyModifiers) error

func (*Element) QuerySelector

func (e *Element) QuerySelector(ctx context.Context, selector string) (*Element, error)

func (*Element) QuerySelectorAll

func (e *Element) QuerySelectorAll(ctx context.Context, selector string) ([]*Element, error)

func (*Element) RecordVideo

func (e *Element) RecordVideo(ctx context.Context, path string) (*VideoRecording, error)

func (*Element) RemoteObject

func (e *Element) RemoteObject(ctx context.Context) (cdp.RuntimeRemoteObject, error)

func (*Element) RemoveAttribute

func (e *Element) RemoveAttribute(ctx context.Context, name string) error

func (*Element) RemoveFromDOM

func (e *Element) RemoveFromDOM(ctx context.Context) error

func (*Element) SaveScreenshot

func (e *Element) SaveScreenshot(ctx context.Context, path string, options ...ScreenshotOptions) error

func (*Element) SaveToDOM

func (e *Element) SaveToDOM(ctx context.Context, attributes ...map[string]string) error

func (*Element) Screenshot

func (e *Element) Screenshot(ctx context.Context, options ...ScreenshotOptions) ([]byte, error)

func (*Element) ScreenshotBase64

func (e *Element) ScreenshotBase64(ctx context.Context, options ...ScreenshotOptions) (string, error)

func (*Element) ScrollIntoView

func (e *Element) ScrollIntoView(ctx context.Context) error

func (*Element) SelectOption

func (e *Element) SelectOption(ctx context.Context, values ...string) error

func (*Element) SendFile

func (e *Element) SendFile(ctx context.Context, paths ...string) error

func (*Element) SendKeys

func (e *Element) SendKeys(ctx context.Context, text string) error

func (*Element) SetAttribute

func (e *Element) SetAttribute(ctx context.Context, name, value string) error

func (*Element) SetText

func (e *Element) SetText(ctx context.Context, value string) error

func (*Element) SetValue

func (e *Element) SetValue(ctx context.Context, value string) error

SetValue uses the native setter so React/Vue controlled inputs see input events.

func (*Element) ShadowChildren

func (e *Element) ShadowChildren() []*Element

func (*Element) ShadowRoots

func (e *Element) ShadowRoots() []*Element

func (*Element) Tab

func (e *Element) Tab() *Tab

func (*Element) TagName

func (e *Element) TagName() string

func (*Element) Text

func (e *Element) Text(ctx context.Context) (string, error)

func (*Element) TextAll

func (e *Element) TextAll(ctx context.Context) (string, error)

func (*Element) Update

func (e *Element) Update(ctx context.Context) error

type EvaluateOptions

type EvaluateOptions struct {
	AwaitPromise bool
	RemoteObject bool
	ContextID    *cdp.RuntimeExecutionContextID
}

type Event

type Event struct {
	Method    string          `json:"method"`
	Params    json.RawMessage `json:"params"`
	SessionID string          `json:"sessionId,omitempty"`
}

func (Event) Decode

func (e Event) Decode(out any) error

type InterceptedRequest

type InterceptedRequest struct {
	Event cdp.FetchRequestPaused
	// contains filtered or unexported fields
}

func (*InterceptedRequest) Body

func (r *InterceptedRequest) Body(ctx context.Context) ([]byte, error)

func (*InterceptedRequest) Continue

func (*InterceptedRequest) ContinueResponse

func (r *InterceptedRequest) ContinueResponse(ctx context.Context, options ...cdp.FetchContinueResponseParams) error

func (*InterceptedRequest) Fail

func (*InterceptedRequest) Fulfill

func (r *InterceptedRequest) Fulfill(ctx context.Context, status int, body []byte, headers ...cdp.FetchHeaderEntry) error

type Interceptor

type Interceptor struct {
	// contains filtered or unexported fields
}

func (*Interceptor) Close

func (i *Interceptor) Close() error

func (*Interceptor) Next

type JavaScriptError

type JavaScriptError struct{ Details cdp.RuntimeExceptionDetails }

func (*JavaScriptError) Error

func (e *JavaScriptError) Error() string

type KeyInput

type KeyInput struct {
	Text      string
	Key       string
	Modifiers KeyModifiers
}

type KeyModifiers

type KeyModifiers int
const (
	Alt     KeyModifiers = 1
	Control KeyModifiers = 2
	Meta    KeyModifiers = 4
	Shift   KeyModifiers = 8
)

type MouseOptions

type MouseOptions struct {
	Button     string
	Modifiers  KeyModifiers
	ClickCount int
	Hold       bool
}
type NavigationOptions struct{ NewTab, NewWindow bool }

type Position

type Position struct {
	X, Y, Width, Height      float64
	Left, Top, Right, Bottom float64
	AbsX, AbsY               float64
}

func (Position) Center

func (p Position) Center() (float64, float64)

func (Position) ToViewport

func (p Position) ToViewport(scale float64) cdp.PageViewport

type ProtocolError

type ProtocolError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
	Method  string          `json:"-"`
}

func (*ProtocolError) Error

func (e *ProtocolError) Error() string

type ProxyForwarder

type ProxyForwarder struct {
	// contains filtered or unexported fields
}

ProxyForwarder adapts authenticated HTTP/HTTPS/SOCKS5 proxies to a local HTTP proxy Chromium can use. Close terminates active CONNECT tunnels too.

func NewProxyForwarder

func NewProxyForwarder(ctx context.Context, upstream string, tlsConfig *tls.Config) (*ProxyForwarder, error)

func (*ProxyForwarder) Close

func (p *ProxyForwarder) Close() error

func (*ProxyForwarder) ProxyServer

func (p *ProxyForwarder) ProxyServer() string

type QueryOptions

type QueryOptions struct {
	Timeout       time.Duration
	IncludeFrames bool
	Exact         bool
}

type RequestExpectation

type RequestExpectation struct {
	// contains filtered or unexported fields
}

RequestExpectation is installed before an action. WaitRequest waits for the request; WaitResponse waits for headers; Body waits for loadingFinished.

func (*RequestExpectation) Body

func (e *RequestExpectation) Body(ctx context.Context) ([]byte, error)

func (*RequestExpectation) Close

func (e *RequestExpectation) Close() error

func (*RequestExpectation) Reset

Reset returns a fresh expectation; existing waiters are released by Close.

func (*RequestExpectation) WaitRequest

func (*RequestExpectation) WaitResponse

type ScreenshotOptions

type ScreenshotOptions struct {
	Format   string
	FullPage bool
	Quality  *int
	Scale    float64
}

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

Subscription preserves event order per handler. Close is safe from its callback.

func OnEvent

func OnEvent[T cdp.Event](ctx context.Context, c *Connection, fn func(T)) (*Subscription, error)

OnEvent decodes generated CDP events before delivering them to the callback.

func (*Subscription) Close

func (s *Subscription) Close() error

type Tab

type Tab struct {
	// contains filtered or unexported fields
}

func (*Tab) Activate

func (t *Tab) Activate(ctx context.Context) error

func (*Tab) Back

func (t *Tab) Back(ctx context.Context) error

func (*Tab) BringToFront

func (t *Tab) BringToFront(ctx context.Context) error

func (*Tab) Browser

func (t *Tab) Browser() *Browser

func (*Tab) BypassInsecureConnectionWarning

func (t *Tab) BypassInsecureConnectionWarning(ctx context.Context) error

func (*Tab) Call

func (t *Tab) Call(ctx context.Context, method string, params any) (json.RawMessage, error)

func (*Tab) Close

func (t *Tab) Close() error

func (*Tab) CloseContext

func (t *Tab) CloseContext(ctx context.Context) error

func (*Tab) Connection

func (t *Tab) Connection(ctx context.Context) (*Connection, error)

func (*Tab) DisableDOMAgent

func (t *Tab) DisableDOMAgent(ctx context.Context) error

func (*Tab) DispatchKeyEvents

func (t *Tab) DispatchKeyEvents(ctx context.Context, events ...cdp.InputDispatchKeyEventParams) error

func (*Tab) DownloadFile

func (t *Tab) DownloadFile(ctx context.Context, address, path string) error

DownloadFile fetches within the page, preserving browser cookies and proxy. The browser's same-origin/CORS rules apply to the requested URL.

func (*Tab) Enable

func (t *Tab) Enable(ctx context.Context, domain string) error

func (*Tab) Evaluate

func (t *Tab) Evaluate(ctx context.Context, expression string, out any, options ...EvaluateOptions) error

func (*Tab) ExpectDownload

func (t *Tab) ExpectDownload(ctx context.Context) (*DownloadExpectation, error)

func (*Tab) ExpectRequest

func (t *Tab) ExpectRequest(ctx context.Context, urlPattern string) (*RequestExpectation, error)

func (*Tab) ExpectResponse

func (t *Tab) ExpectResponse(ctx context.Context, urlPattern string) (*RequestExpectation, error)

func (*Tab) Find

func (t *Tab) Find(ctx context.Context, text string, options ...QueryOptions) (*Element, error)

func (*Tab) FindAll

func (t *Tab) FindAll(ctx context.Context, text string, options ...QueryOptions) (result []*Element, err error)

func (*Tab) FindCloudflareChallenge

func (t *Tab) FindCloudflareChallenge(ctx context.Context) (*CloudflareChallenge, error)

func (*Tab) FindElementByText

func (t *Tab) FindElementByText(ctx context.Context, text string, bestMatch ...bool) (*Element, error)

func (*Tab) FindElementsByText

func (t *Tab) FindElementsByText(ctx context.Context, text string, options ...QueryOptions) ([]*Element, error)

func (*Tab) FlashPoint

func (t *Tab) FlashPoint(ctx context.Context, x, y float64, duration ...float64) error

func (*Tab) Forward

func (t *Tab) Forward(ctx context.Context) error

func (*Tab) Fullscreen

func (t *Tab) Fullscreen(ctx context.Context) error

func (*Tab) Get

func (t *Tab) Get(ctx context.Context, address string, options ...NavigationOptions) (*Tab, error)

func (*Tab) GetAllLinkedSources

func (t *Tab) GetAllLinkedSources(ctx context.Context) ([]*Element, error)

func (*Tab) GetAllURLs

func (t *Tab) GetAllURLs(ctx context.Context, absolute ...bool) ([]string, error)

func (*Tab) GetContent

func (t *Tab) GetContent(ctx context.Context) (string, error)

func (*Tab) GetFrames

func (t *Tab) GetFrames(ctx context.Context) ([]*Tab, error)

func (*Tab) GetLocalStorage

func (t *Tab) GetLocalStorage(ctx context.Context) (map[string]string, error)

func (*Tab) GetWindow

func (t *Tab) GetWindow(ctx context.Context) (int, WindowBounds, error)

func (*Tab) InsertText

func (t *Tab) InsertText(ctx context.Context, text string) error

func (*Tab) InspectorURL

func (t *Tab) InspectorURL() string

func (*Tab) Intercept

func (t *Tab) Intercept(ctx context.Context, patterns ...cdp.FetchRequestPattern) (*Interceptor, error)

Intercept intercepts every request matching CDP's wildcard patterns until Close. Only one Fetch interceptor can own a target at a time. Consume Next and Continue/Fail/Fulfill each request; an unresolved request remains paused.

func (*Tab) IsCloudflareChallengePresent

func (t *Tab) IsCloudflareChallengePresent(ctx context.Context) (bool, error)

func (*Tab) IsScrolledToBottom

func (t *Tab) IsScrolledToBottom(ctx context.Context) (bool, error)

func (*Tab) JSDumps

func (t *Tab) JSDumps(ctx context.Context, expression string) (json.RawMessage, error)

func (*Tab) Maximize

func (t *Tab) Maximize(ctx context.Context) error

func (*Tab) Medimize

func (t *Tab) Medimize(ctx context.Context) error

func (*Tab) Minimize

func (t *Tab) Minimize(ctx context.Context) error

func (*Tab) MouseClick

func (t *Tab) MouseClick(ctx context.Context, x, y float64, options ...MouseOptions) error

func (*Tab) MouseDown

func (t *Tab) MouseDown(ctx context.Context, x, y float64, options ...MouseOptions) error

func (*Tab) MouseDrag

func (t *Tab) MouseDrag(ctx context.Context, fromX, fromY, toX, toY float64, steps ...int) error

func (*Tab) MouseMove

func (t *Tab) MouseMove(ctx context.Context, x, y float64, steps ...int) error

func (*Tab) MouseUp

func (t *Tab) MouseUp(ctx context.Context, x, y float64, options ...MouseOptions) error

func (*Tab) Navigate

func (t *Tab) Navigate(ctx context.Context, address string) error

func (*Tab) On

func (t *Tab) On(ctx context.Context, method string, fn func(Event)) (*Subscription, error)

func (*Tab) OpenExternalInspector

func (t *Tab) OpenExternalInspector() error

func (*Tab) PressKey

func (t *Tab) PressKey(ctx context.Context, key string, modifiers ...KeyModifiers) error

func (*Tab) PrintToPDF

func (t *Tab) PrintToPDF(ctx context.Context, path string, options ...cdp.PagePrintToPDFParams) error

func (*Tab) QuerySelector

func (t *Tab) QuerySelector(ctx context.Context, selector string, options ...QueryOptions) (*Element, error)

func (*Tab) QuerySelectorAll

func (t *Tab) QuerySelectorAll(ctx context.Context, selector string, options ...QueryOptions) ([]*Element, error)

func (*Tab) Reload

func (t *Tab) Reload(ctx context.Context, ignoreCache ...bool) error

func (*Tab) SaveScreenshot

func (t *Tab) SaveScreenshot(ctx context.Context, path string, options ...ScreenshotOptions) error

func (*Tab) SaveSnapshot

func (t *Tab) SaveSnapshot(ctx context.Context, path string) error

func (*Tab) Screenshot

func (t *Tab) Screenshot(ctx context.Context, options ...ScreenshotOptions) ([]byte, error)

func (*Tab) ScreenshotBase64

func (t *Tab) ScreenshotBase64(ctx context.Context, options ...ScreenshotOptions) (string, error)

func (*Tab) ScrollDown

func (t *Tab) ScrollDown(ctx context.Context, amount int, speed ...int) error

func (*Tab) ScrollUp

func (t *Tab) ScrollUp(ctx context.Context, amount int, speed ...int) error

func (*Tab) Select

func (t *Tab) Select(ctx context.Context, selector string, options ...QueryOptions) (*Element, error)

func (*Tab) SelectAll

func (t *Tab) SelectAll(ctx context.Context, selector string, options ...QueryOptions) (result []*Element, err error)

func (*Tab) Send

func (t *Tab) Send(ctx context.Context, method string, params, out any) error

func (*Tab) SendKeys

func (t *Tab) SendKeys(ctx context.Context, inputs ...KeyInput) error

func (*Tab) SetDownloadPath

func (t *Tab) SetDownloadPath(ctx context.Context, path string) error

func (*Tab) SetLocalStorage

func (t *Tab) SetLocalStorage(ctx context.Context, items map[string]string) error

func (*Tab) SetUserAgent

func (t *Tab) SetUserAgent(ctx context.Context, userAgent string, languagePlatform ...string) error

func (*Tab) SetWindowSize

func (t *Tab) SetWindowSize(ctx context.Context, left, top, width, height int) error

func (*Tab) SetWindowState

func (t *Tab) SetWindowState(ctx context.Context, state string) error

func (*Tab) Sleep

func (t *Tab) Sleep(ctx context.Context, d time.Duration) error

func (*Tab) Target

func (t *Tab) Target() cdp.TargetTargetInfo

func (*Tab) TargetID

func (t *Tab) TargetID() string

func (*Tab) Title

func (t *Tab) Title() string

func (*Tab) TypeText

func (t *Tab) TypeText(ctx context.Context, text string) error

TypeText emits down/press/up keyboard events, including Unicode text.

func (*Tab) URL

func (t *Tab) URL() string

func (*Tab) UpdateTarget

func (t *Tab) UpdateTarget(ctx context.Context) error

func (*Tab) VerifyCF

func (t *Tab) VerifyCF(ctx context.Context, options ...CloudflareOptions) error

VerifyCF ports zendriver's interactive checkbox helper. Success is observed through the response input receiving a value or disappearing after a click. Challenge provider behavior is external and can change independently.

func (*Tab) Wait

func (t *Tab) Wait(ctx context.Context, idle ...time.Duration) error

func (*Tab) WaitFor

func (t *Tab) WaitFor(ctx context.Context, selector, text string, options ...QueryOptions) (*Element, error)

func (*Tab) WaitForCloudflareChallenge

func (t *Tab) WaitForCloudflareChallenge(ctx context.Context) (*CloudflareChallenge, error)

func (*Tab) WaitForReadyState

func (t *Tab) WaitForReadyState(ctx context.Context, state string) error

func (*Tab) XPath

func (t *Tab) XPath(ctx context.Context, xpath string, options ...QueryOptions) ([]*Element, error)

type VideoRecording

type VideoRecording struct {
	// contains filtered or unexported fields
}

VideoRecording uses the browser's MediaRecorder. The resulting file is WebM. User activation and Chromium capture support are required, as in zendriver.

func (*VideoRecording) Close

func (v *VideoRecording) Close() error

func (*VideoRecording) Stop

func (v *VideoRecording) Stop(ctx context.Context) error

type WindowBounds

type WindowBounds struct {
	Left, Top, Width, Height int
	State                    string
}

Directories

Path Synopsis
Code generated by cdpgen from zendriver 0.17.1; DO NOT EDIT.
Code generated by cdpgen from zendriver 0.17.1; DO NOT EDIT.
examples
basic command
network command
internal
cdpgen command
Command cdpgen generates Go bindings from the checked-in protocol snapshot.
Command cdpgen generates Go bindings from the checked-in protocol snapshot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL