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
- Variables
- func Circle(x, y, radius float64, num int, clockwise bool) [][2]float64
- func CompareTargetInfo(a, b cdp.TargetTargetInfo) map[string][2]any
- func FilterNodes(root cdp.DOMNode, predicate func(cdp.DOMNode) bool) []cdp.DOMNode
- func FindExecutable(browser string) (string, error)
- func FlattenFrameTree(tree cdp.PageFrameTree) []cdp.PageFrameTree
- func MergeDisableFeaturesArgs(args []string) []string
- func Sleep(ctx context.Context, duration time.Duration) error
- func WalkNodes(root cdp.DOMNode, fn func(cdp.DOMNode))
- type Browser
- func (b *Browser) Close() error
- func (b *Browser) Contexts() []*BrowserContext
- func (b *Browser) Cookies() *CookieJar
- func (b *Browser) CreateContext(ctx context.Context, options ...ContextOptions) (*BrowserContext, error)
- func (b *Browser) Get(ctx context.Context, url string, options ...NavigationOptions) (*Tab, error)
- func (b *Browser) GetTab(ctx context.Context, text string) (*Tab, error)
- func (b *Browser) GrantAllPermissions(ctx context.Context) error
- func (b *Browser) GrantPermissions(ctx context.Context, permissions []cdp.BrowserPermissionType, origin string, ...) error
- func (b *Browser) HTTPGet(ctx context.Context, endpoint string, out any) error
- func (b *Browser) MainTab() *Tab
- func (b *Browser) NewTab(ctx context.Context, url string, newWindow ...bool) (*Tab, error)
- func (b *Browser) Sleep(ctx context.Context, d time.Duration) error
- func (b *Browser) Stop(ctx context.Context) error
- func (b *Browser) Stopped() bool
- func (b *Browser) Tab(ctx context.Context, id string) (*Tab, error)
- func (b *Browser) Tabs() []*Tab
- func (b *Browser) Targets() []*Tab
- func (b *Browser) TestConnection(ctx context.Context) error
- func (b *Browser) TileWindows(ctx context.Context, width, height, columns int) ([]WindowBounds, error)
- func (b *Browser) UpdateTargets(ctx context.Context) error
- func (b *Browser) WebSocketURL() string
- type BrowserContext
- type BrowserInfo
- type CloudflareChallenge
- type CloudflareOptions
- type Config
- type Connection
- func (c *Connection) AddHandler(ctx context.Context, method string, fn func(Event)) *Subscription
- func (c *Connection) Call(ctx context.Context, method string, params any) (json.RawMessage, error)
- func (c *Connection) Close() error
- func (c *Connection) Closed() bool
- func (c *Connection) Disable(ctx context.Context, domain string) error
- func (c *Connection) Done() <-chan struct{}
- func (c *Connection) Enable(ctx context.Context, domain string) error
- func (c *Connection) On(ctx context.Context, method string, fn func(Event)) (*Subscription, error)
- func (c *Connection) RemoveHandlers(method string)
- func (c *Connection) Send(ctx context.Context, method string, params, out any) error
- func (c *Connection) SessionID() string
- func (c *Connection) Wait(ctx context.Context, idle time.Duration) error
- type ContextOptions
- type CookieJar
- func (j *CookieJar) Clear(ctx context.Context) error
- func (j *CookieJar) GetAll(ctx context.Context) ([]cdp.NetworkCookie, error)
- func (j *CookieJar) HTTPCookies(ctx context.Context) ([]*http.Cookie, error)
- func (j *CookieJar) Load(ctx context.Context, path string, pattern ...string) error
- func (j *CookieJar) Save(ctx context.Context, path string, pattern ...string) error
- func (j *CookieJar) SetAll(ctx context.Context, cookies []cdp.NetworkCookieParam) error
- type DownloadExpectation
- type DownloadInfo
- type Element
- func (e *Element) Apply(ctx context.Context, jsFunction string, out any, options ...EvaluateOptions) error
- func (e *Element) Attributes() map[string]string
- func (e *Element) Children() []*Element
- func (e *Element) ClearInput(ctx context.Context) error
- func (e *Element) ClearInputByDeleting(ctx context.Context) error
- func (e *Element) Click(ctx context.Context) error
- func (e *Element) ContentDocument() *Element
- func (e *Element) Flash(ctx context.Context, duration ...time.Duration) error
- func (e *Element) Focus(ctx context.Context) error
- func (e *Element) Get(name string) string
- func (e *Element) GetFrame(ctx context.Context) (*Tab, error)
- func (e *Element) GetHTML(ctx context.Context) (string, error)
- func (e *Element) GetJSAttributes(ctx context.Context) (map[string]any, error)
- func (e *Element) GetPosition(ctx context.Context, absolute ...bool) (Position, error)
- func (e *Element) HighlightOverlay(ctx context.Context) error
- func (e *Element) IsRecording() bool
- func (e *Element) MouseClick(ctx context.Context, options ...MouseOptions) error
- func (e *Element) MouseDrag(ctx context.Context, destination *Element, steps ...int) error
- func (e *Element) MouseMove(ctx context.Context) error
- func (e *Element) Node() cdp.DOMNode
- func (e *Element) ObjectID(ctx context.Context) (cdp.RuntimeRemoteObjectID, error)
- func (e *Element) Parent(ctx context.Context) (*Element, error)
- func (e *Element) PressKey(ctx context.Context, key string, modifiers ...KeyModifiers) error
- func (e *Element) QuerySelector(ctx context.Context, selector string) (*Element, error)
- func (e *Element) QuerySelectorAll(ctx context.Context, selector string) ([]*Element, error)
- func (e *Element) RecordVideo(ctx context.Context, path string) (*VideoRecording, error)
- func (e *Element) RemoteObject(ctx context.Context) (cdp.RuntimeRemoteObject, error)
- func (e *Element) RemoveAttribute(ctx context.Context, name string) error
- func (e *Element) RemoveFromDOM(ctx context.Context) error
- func (e *Element) SaveScreenshot(ctx context.Context, path string, options ...ScreenshotOptions) error
- func (e *Element) SaveToDOM(ctx context.Context, attributes ...map[string]string) error
- func (e *Element) Screenshot(ctx context.Context, options ...ScreenshotOptions) ([]byte, error)
- func (e *Element) ScreenshotBase64(ctx context.Context, options ...ScreenshotOptions) (string, error)
- func (e *Element) ScrollIntoView(ctx context.Context) error
- func (e *Element) SelectOption(ctx context.Context, values ...string) error
- func (e *Element) SendFile(ctx context.Context, paths ...string) error
- func (e *Element) SendKeys(ctx context.Context, text string) error
- func (e *Element) SetAttribute(ctx context.Context, name, value string) error
- func (e *Element) SetText(ctx context.Context, value string) error
- func (e *Element) SetValue(ctx context.Context, value string) error
- func (e *Element) ShadowChildren() []*Element
- func (e *Element) ShadowRoots() []*Element
- func (e *Element) Tab() *Tab
- func (e *Element) TagName() string
- func (e *Element) Text(ctx context.Context) (string, error)
- func (e *Element) TextAll(ctx context.Context) (string, error)
- func (e *Element) Update(ctx context.Context) error
- type EvaluateOptions
- type Event
- type InterceptedRequest
- func (r *InterceptedRequest) Body(ctx context.Context) ([]byte, error)
- func (r *InterceptedRequest) Continue(ctx context.Context, options ...cdp.FetchContinueRequestParams) error
- func (r *InterceptedRequest) ContinueResponse(ctx context.Context, options ...cdp.FetchContinueResponseParams) error
- func (r *InterceptedRequest) Fail(ctx context.Context, reason cdp.NetworkErrorReason) error
- func (r *InterceptedRequest) Fulfill(ctx context.Context, status int, body []byte, headers ...cdp.FetchHeaderEntry) error
- type Interceptor
- type JavaScriptError
- type KeyInput
- type KeyModifiers
- type MouseOptions
- type NavigationOptions
- type Position
- type ProtocolError
- type ProxyForwarder
- type QueryOptions
- type RequestExpectation
- func (e *RequestExpectation) Body(ctx context.Context) ([]byte, error)
- func (e *RequestExpectation) Close() error
- func (e *RequestExpectation) Reset(ctx context.Context) (*RequestExpectation, error)
- func (e *RequestExpectation) WaitRequest(ctx context.Context) (cdp.NetworkRequestWillBeSent, error)
- func (e *RequestExpectation) WaitResponse(ctx context.Context) (cdp.NetworkResponseReceived, error)
- type ScreenshotOptions
- type Subscription
- type Tab
- func (t *Tab) Activate(ctx context.Context) error
- func (t *Tab) Back(ctx context.Context) error
- func (t *Tab) BringToFront(ctx context.Context) error
- func (t *Tab) Browser() *Browser
- func (t *Tab) BypassInsecureConnectionWarning(ctx context.Context) error
- func (t *Tab) Call(ctx context.Context, method string, params any) (json.RawMessage, error)
- func (t *Tab) Close() error
- func (t *Tab) CloseContext(ctx context.Context) error
- func (t *Tab) Connection(ctx context.Context) (*Connection, error)
- func (t *Tab) DisableDOMAgent(ctx context.Context) error
- func (t *Tab) DispatchKeyEvents(ctx context.Context, events ...cdp.InputDispatchKeyEventParams) error
- func (t *Tab) DownloadFile(ctx context.Context, address, path string) error
- func (t *Tab) Enable(ctx context.Context, domain string) error
- func (t *Tab) Evaluate(ctx context.Context, expression string, out any, options ...EvaluateOptions) error
- func (t *Tab) ExpectDownload(ctx context.Context) (*DownloadExpectation, error)
- func (t *Tab) ExpectRequest(ctx context.Context, urlPattern string) (*RequestExpectation, error)
- func (t *Tab) ExpectResponse(ctx context.Context, urlPattern string) (*RequestExpectation, error)
- func (t *Tab) Find(ctx context.Context, text string, options ...QueryOptions) (*Element, error)
- func (t *Tab) FindAll(ctx context.Context, text string, options ...QueryOptions) (result []*Element, err error)
- func (t *Tab) FindCloudflareChallenge(ctx context.Context) (*CloudflareChallenge, error)
- func (t *Tab) FindElementByText(ctx context.Context, text string, bestMatch ...bool) (*Element, error)
- func (t *Tab) FindElementsByText(ctx context.Context, text string, options ...QueryOptions) ([]*Element, error)
- func (t *Tab) FlashPoint(ctx context.Context, x, y float64, duration ...float64) error
- func (t *Tab) Forward(ctx context.Context) error
- func (t *Tab) Fullscreen(ctx context.Context) error
- func (t *Tab) Get(ctx context.Context, address string, options ...NavigationOptions) (*Tab, error)
- func (t *Tab) GetAllLinkedSources(ctx context.Context) ([]*Element, error)
- func (t *Tab) GetAllURLs(ctx context.Context, absolute ...bool) ([]string, error)
- func (t *Tab) GetContent(ctx context.Context) (string, error)
- func (t *Tab) GetFrames(ctx context.Context) ([]*Tab, error)
- func (t *Tab) GetLocalStorage(ctx context.Context) (map[string]string, error)
- func (t *Tab) GetWindow(ctx context.Context) (int, WindowBounds, error)
- func (t *Tab) InsertText(ctx context.Context, text string) error
- func (t *Tab) InspectorURL() string
- func (t *Tab) Intercept(ctx context.Context, patterns ...cdp.FetchRequestPattern) (*Interceptor, error)
- func (t *Tab) IsCloudflareChallengePresent(ctx context.Context) (bool, error)
- func (t *Tab) IsScrolledToBottom(ctx context.Context) (bool, error)
- func (t *Tab) JSDumps(ctx context.Context, expression string) (json.RawMessage, error)
- func (t *Tab) Maximize(ctx context.Context) error
- func (t *Tab) Medimize(ctx context.Context) error
- func (t *Tab) Minimize(ctx context.Context) error
- func (t *Tab) MouseClick(ctx context.Context, x, y float64, options ...MouseOptions) error
- func (t *Tab) MouseDown(ctx context.Context, x, y float64, options ...MouseOptions) error
- func (t *Tab) MouseDrag(ctx context.Context, fromX, fromY, toX, toY float64, steps ...int) error
- func (t *Tab) MouseMove(ctx context.Context, x, y float64, steps ...int) error
- func (t *Tab) MouseUp(ctx context.Context, x, y float64, options ...MouseOptions) error
- func (t *Tab) Navigate(ctx context.Context, address string) error
- func (t *Tab) On(ctx context.Context, method string, fn func(Event)) (*Subscription, error)
- func (t *Tab) OpenExternalInspector() error
- func (t *Tab) PressKey(ctx context.Context, key string, modifiers ...KeyModifiers) error
- func (t *Tab) PrintToPDF(ctx context.Context, path string, options ...cdp.PagePrintToPDFParams) error
- func (t *Tab) QuerySelector(ctx context.Context, selector string, options ...QueryOptions) (*Element, error)
- func (t *Tab) QuerySelectorAll(ctx context.Context, selector string, options ...QueryOptions) ([]*Element, error)
- func (t *Tab) Reload(ctx context.Context, ignoreCache ...bool) error
- func (t *Tab) SaveScreenshot(ctx context.Context, path string, options ...ScreenshotOptions) error
- func (t *Tab) SaveSnapshot(ctx context.Context, path string) error
- func (t *Tab) Screenshot(ctx context.Context, options ...ScreenshotOptions) ([]byte, error)
- func (t *Tab) ScreenshotBase64(ctx context.Context, options ...ScreenshotOptions) (string, error)
- func (t *Tab) ScrollDown(ctx context.Context, amount int, speed ...int) error
- func (t *Tab) ScrollUp(ctx context.Context, amount int, speed ...int) error
- func (t *Tab) Select(ctx context.Context, selector string, options ...QueryOptions) (*Element, error)
- func (t *Tab) SelectAll(ctx context.Context, selector string, options ...QueryOptions) (result []*Element, err error)
- func (t *Tab) Send(ctx context.Context, method string, params, out any) error
- func (t *Tab) SendKeys(ctx context.Context, inputs ...KeyInput) error
- func (t *Tab) SetDownloadPath(ctx context.Context, path string) error
- func (t *Tab) SetLocalStorage(ctx context.Context, items map[string]string) error
- func (t *Tab) SetUserAgent(ctx context.Context, userAgent string, languagePlatform ...string) error
- func (t *Tab) SetWindowSize(ctx context.Context, left, top, width, height int) error
- func (t *Tab) SetWindowState(ctx context.Context, state string) error
- func (t *Tab) Sleep(ctx context.Context, d time.Duration) error
- func (t *Tab) Target() cdp.TargetTargetInfo
- func (t *Tab) TargetID() string
- func (t *Tab) Title() string
- func (t *Tab) TypeText(ctx context.Context, text string) error
- func (t *Tab) URL() string
- func (t *Tab) UpdateTarget(ctx context.Context) error
- func (t *Tab) VerifyCF(ctx context.Context, options ...CloudflareOptions) error
- func (t *Tab) Wait(ctx context.Context, idle ...time.Duration) error
- func (t *Tab) WaitFor(ctx context.Context, selector, text string, options ...QueryOptions) (*Element, error)
- func (t *Tab) WaitForCloudflareChallenge(ctx context.Context) (*CloudflareChallenge, error)
- func (t *Tab) WaitForReadyState(ctx context.Context, state string) error
- func (t *Tab) XPath(ctx context.Context, xpath string, options ...QueryOptions) ([]*Element, error)
- type VideoRecording
- type WindowBounds
Constants ¶
const Version = "0.1.0"
const ZendriverVersion = "0.17.1"
Variables ¶
var ErrClosed = errors.New("dgodriver: connection closed")
var ErrNotFound = errors.New("dgodriver: element not found")
Functions ¶
func CompareTargetInfo ¶
func CompareTargetInfo(a, b cdp.TargetTargetInfo) map[string][2]any
func FilterNodes ¶
func FindExecutable ¶
func FlattenFrameTree ¶
func FlattenFrameTree(tree cdp.PageFrameTree) []cdp.PageFrameTree
Types ¶
type Browser ¶
type Browser struct {
*Connection
Config Config
Info BrowserInfo
// contains filtered or unexported fields
}
func Start ¶
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) Contexts ¶
func (b *Browser) Contexts() []*BrowserContext
func (*Browser) CreateContext ¶
func (b *Browser) CreateContext(ctx context.Context, options ...ContextOptions) (*BrowserContext, error)
func (*Browser) GrantAllPermissions ¶
func (*Browser) GrantPermissions ¶
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) WebSocketURL ¶
type BrowserContext ¶
func (*BrowserContext) Close ¶
func (bc *BrowserContext) Close() error
func (*BrowserContext) Cookies ¶
func (bc *BrowserContext) Cookies() *CookieJar
type BrowserInfo ¶
type CloudflareChallenge ¶
type CloudflareChallenge struct{ Host, ShadowRoot, IFrame *Element }
type CloudflareOptions ¶
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 (*Config) AddExtension ¶
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 (*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) Done ¶
func (c *Connection) Done() <-chan struct{}
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) SessionID ¶
func (c *Connection) SessionID() string
type ContextOptions ¶
type CookieJar ¶
type CookieJar struct {
// contains filtered or unexported fields
}
func (*CookieJar) HTTPCookies ¶
type DownloadExpectation ¶
type DownloadExpectation struct {
// contains filtered or unexported fields
}
func (*DownloadExpectation) Close ¶
func (e *DownloadExpectation) Close() error
func (*DownloadExpectation) Wait ¶
func (e *DownloadExpectation) Wait(ctx context.Context) (DownloadInfo, error)
func (*DownloadExpectation) WaitBegin ¶
func (e *DownloadExpectation) WaitBegin(ctx context.Context) (DownloadInfo, error)
type DownloadInfo ¶
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) Attributes ¶
func (*Element) ClearInputByDeleting ¶
func (*Element) ContentDocument ¶
func (*Element) GetJSAttributes ¶
func (*Element) GetPosition ¶
func (*Element) IsRecording ¶
func (*Element) MouseClick ¶
func (e *Element) MouseClick(ctx context.Context, options ...MouseOptions) error
func (*Element) QuerySelector ¶
func (*Element) QuerySelectorAll ¶
func (*Element) RecordVideo ¶
func (*Element) RemoteObject ¶
func (*Element) RemoveAttribute ¶
func (*Element) SaveScreenshot ¶
func (*Element) Screenshot ¶
func (*Element) ScreenshotBase64 ¶
func (*Element) SelectOption ¶
func (*Element) SetAttribute ¶
func (*Element) SetValue ¶
SetValue uses the native setter so React/Vue controlled inputs see input events.
func (*Element) ShadowChildren ¶
func (*Element) ShadowRoots ¶
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"`
}
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 (r *InterceptedRequest) Continue(ctx context.Context, options ...cdp.FetchContinueRequestParams) error
func (*InterceptedRequest) ContinueResponse ¶
func (r *InterceptedRequest) ContinueResponse(ctx context.Context, options ...cdp.FetchContinueResponseParams) error
func (*InterceptedRequest) Fail ¶
func (r *InterceptedRequest) Fail(ctx context.Context, reason cdp.NetworkErrorReason) error
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 ¶
func (i *Interceptor) Next(ctx context.Context) (*InterceptedRequest, error)
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 ¶
type Position ¶
type Position struct {
X, Y, Width, Height float64
Left, Top, Right, Bottom float64
AbsX, AbsY 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 (*ProxyForwarder) Close ¶
func (p *ProxyForwarder) Close() error
func (*ProxyForwarder) ProxyServer ¶
func (p *ProxyForwarder) ProxyServer() string
type QueryOptions ¶
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 ¶
func (e *RequestExpectation) Reset(ctx context.Context) (*RequestExpectation, error)
Reset returns a fresh expectation; existing waiters are released by Close.
func (*RequestExpectation) WaitRequest ¶
func (e *RequestExpectation) WaitRequest(ctx context.Context) (cdp.NetworkRequestWillBeSent, error)
func (*RequestExpectation) WaitResponse ¶
func (e *RequestExpectation) WaitResponse(ctx context.Context) (cdp.NetworkResponseReceived, error)
type ScreenshotOptions ¶
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) BypassInsecureConnectionWarning ¶
func (*Tab) Connection ¶
func (t *Tab) Connection(ctx context.Context) (*Connection, error)
func (*Tab) DispatchKeyEvents ¶
func (*Tab) DownloadFile ¶
DownloadFile fetches within the page, preserving browser cookies and proxy. The browser's same-origin/CORS rules apply to the requested URL.
func (*Tab) ExpectDownload ¶
func (t *Tab) ExpectDownload(ctx context.Context) (*DownloadExpectation, error)
func (*Tab) ExpectRequest ¶
func (*Tab) ExpectResponse ¶
func (*Tab) FindCloudflareChallenge ¶
func (t *Tab) FindCloudflareChallenge(ctx context.Context) (*CloudflareChallenge, error)
func (*Tab) FindElementByText ¶
func (*Tab) FindElementsByText ¶
func (*Tab) FlashPoint ¶
func (*Tab) GetAllLinkedSources ¶
func (*Tab) GetAllURLs ¶
func (*Tab) GetLocalStorage ¶
func (*Tab) InspectorURL ¶
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 (*Tab) IsScrolledToBottom ¶
func (*Tab) MouseClick ¶
func (*Tab) OpenExternalInspector ¶
func (*Tab) PrintToPDF ¶
func (*Tab) QuerySelector ¶
func (*Tab) QuerySelectorAll ¶
func (*Tab) SaveScreenshot ¶
func (*Tab) Screenshot ¶
func (*Tab) ScreenshotBase64 ¶
func (*Tab) ScrollDown ¶
func (*Tab) SetLocalStorage ¶
func (*Tab) SetUserAgent ¶
func (*Tab) SetWindowSize ¶
func (*Tab) Target ¶
func (t *Tab) Target() cdp.TargetTargetInfo
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) WaitForCloudflareChallenge ¶
func (t *Tab) WaitForCloudflareChallenge(ctx context.Context) (*CloudflareChallenge, error)
func (*Tab) WaitForReadyState ¶
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
type WindowBounds ¶
Source Files
¶
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. |