Documentation ¶
Overview ¶
Package chromedp is a high level Chrome Debugging Protocol domain manager that simplifies driving web browsers (Chrome, Safari, Edge, Android Web Views, and others) for scraping, unit testing, or profiling web pages.
chromedp requires no third-party dependencies (ie, Selenium), implementing the async Chrome Debugging Protocol natively.
Index ¶
- Constants
- Variables
- func ButtonLeft(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams
- func ButtonMiddle(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams
- func ButtonNone(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams
- func ButtonRight(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams
- func ByID(s *Selector)
- func ByNodeID(s *Selector)
- func ByQuery(s *Selector)
- func ByQueryAll(s *Selector)
- func BySearch(s *Selector)
- func EvalAsValue(p *rundom.EvaluateParams) *rundom.EvaluateParams
- func EvalIgnoreExceptions(p *rundom.EvaluateParams) *rundom.EvaluateParams
- func EvalWithCommandLineAPI(p *rundom.EvaluateParams) *rundom.EvaluateParams
- func NodeEnabled(s *Selector)
- func NodeNotPresent(s *Selector)
- func NodeNotVisible(s *Selector)
- func NodeReady(s *Selector)
- func NodeSelected(s *Selector)
- func NodeVisible(s *Selector)
- type Action
- func AddOnLoadScript(source string, id *page.ScriptIdentifier) Action
- func AttributeValue(sel interface{}, name string, value *string, ok *bool, opts ...QueryOption) Action
- func Attributes(sel interface{}, attributes *map[string]string, opts ...QueryOption) Action
- func Blur(sel interface{}, opts ...QueryOption) Action
- func CaptureScreenshot(res *[]byte) Action
- func Clear(sel interface{}, opts ...QueryOption) Action
- func Click(sel interface{}, opts ...QueryOption) Action
- func ComputedStyle(sel interface{}, style *[]*css.ComputedProperty, opts ...QueryOption) Action
- func Dimensions(sel interface{}, model **dom.BoxModel, opts ...QueryOption) Action
- func DoubleClick(sel interface{}, opts ...QueryOption) Action
- func Evaluate(expression string, res interface{}, opts ...EvaluateOption) Action
- func EvaluateAsDevTools(expression string, res interface{}, opts ...EvaluateOption) Action
- func Focus(sel interface{}, opts ...QueryOption) Action
- func InnerHTML(sel interface{}, html *string, opts ...QueryOption) Action
- func JavascriptAttribute(sel interface{}, name string, res interface{}, opts ...QueryOption) Action
- func KeyAction(keys string, opts ...KeyOption) Action
- func KeyActionNode(n *cdp.Node, keys string, opts ...KeyOption) Action
- func Location(urlstr *string) Action
- func MatchedStyle(sel interface{}, style **css.GetMatchedStylesForNodeReturns, ...) Action
- func MouseAction(typ input.MouseType, x, y int64, opts ...MouseOption) Action
- func MouseClickNode(n *cdp.Node, opts ...MouseOption) Action
- func MouseClickXY(x, y int64, opts ...MouseOption) Action
- func Navigate(urlstr string) Action
- func NavigateBack() Action
- func NavigateForward() Action
- func NavigateToHistoryEntry(entryID int64) Action
- func NavigationEntries(currentIndex *int64, entries *[]*page.NavigationEntry) Action
- func NodeIDs(sel interface{}, ids *[]cdp.NodeID, opts ...QueryOption) Action
- func Nodes(sel interface{}, nodes *[]*cdp.Node, opts ...QueryOption) Action
- func OuterHTML(sel interface{}, html *string, opts ...QueryOption) Action
- func Query(sel interface{}, opts ...QueryOption) Action
- func QueryAfter(sel interface{}, f func(context.Context, cdp.Handler, ...*cdp.Node) error, ...) Action
- func Reload() Action
- func RemoveAttribute(sel interface{}, name string, opts ...QueryOption) Action
- func RemoveOnLoadScript(id page.ScriptIdentifier) Action
- func Reset(sel interface{}, opts ...QueryOption) Action
- func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) Action
- func ScrollIntoView(sel interface{}, opts ...QueryOption) Action
- func SendKeys(sel interface{}, v string, opts ...QueryOption) Action
- func SetAttributeValue(sel interface{}, name, value string, opts ...QueryOption) Action
- func SetAttributes(sel interface{}, attributes map[string]string, opts ...QueryOption) Action
- func SetJavascriptAttribute(sel interface{}, name, value string, opts ...QueryOption) Action
- func SetUploadFiles(sel interface{}, files []string, opts ...QueryOption) Action
- func SetValue(sel interface{}, value string, opts ...QueryOption) Action
- func Sleep(d time.Duration) Action
- func Stop() Action
- func Submit(sel interface{}, opts ...QueryOption) Action
- func Text(sel interface{}, text *string, opts ...QueryOption) Action
- func Title(title *string) Action
- func Value(sel interface{}, value *string, opts ...QueryOption) Action
- func WaitEnabled(sel interface{}, opts ...QueryOption) Action
- func WaitNotPresent(sel interface{}, opts ...QueryOption) Action
- func WaitNotVisible(sel interface{}, opts ...QueryOption) Action
- func WaitReady(sel interface{}, opts ...QueryOption) Action
- func WaitSelected(sel interface{}, opts ...QueryOption) Action
- func WaitVisible(sel interface{}, opts ...QueryOption) Action
- type ActionFunc
- type CDP
- func (c *CDP) AddTarget(ctxt context.Context, t client.Target)
- func (c *CDP) CloseByID(id string) Action
- func (c *CDP) CloseByIndex(i int) Action
- func (c *CDP) GetHandlerByID(id string) cdp.Handler
- func (c *CDP) GetHandlerByIndex(i int) cdp.Handler
- func (c *CDP) ListTargets() []string
- func (c *CDP) NewTarget(id *string, opts ...client.Option) Action
- func (c *CDP) Run(ctxt context.Context, a Action) error
- func (c *CDP) SetHandler(i int) error
- func (c *CDP) SetHandlerByID(id string) error
- func (c *CDP) SetTarget(i int) Action
- func (c *CDP) SetTargetByID(id string) Action
- func (c *CDP) Shutdown(ctxt context.Context, opts ...client.Option) error
- func (c *CDP) Wait() error
- type EvaluateOption
- type KeyOption
- type LogFunc
- type MouseOption
- type Option
- func WithConsolef(f LogFunc) Option
- func WithDebugf(f LogFunc) Option
- func WithErrorf(f LogFunc) Option
- func WithLog(f LogFunc) Option
- func WithLogf(f LogFunc) Option
- func WithRunner(r *runner.Runner) Option
- func WithRunnerOptions(opts ...runner.CommandLineOption) Option
- func WithTargets(watch <-chan client.Target) Option
- type Pool
- type PoolOption
- type QueryOption
- type Res
- type Selector
- type TargetHandler
- func (h *TargetHandler) Execute(ctxt context.Context, commandType cdp.MethodType, params easyjson.Marshaler, ...) error
- func (h *TargetHandler) GetRoot(ctxt context.Context) (*cdp.Node, error)
- func (h *TargetHandler) Listen(eventTypes ...cdp.MethodType) <-chan interface{}
- func (h *TargetHandler) Release(ch <-chan interface{})
- func (h *TargetHandler) Run(ctxt context.Context) error
- func (h *TargetHandler) SetActive(ctxt context.Context, id cdp.FrameID) error
- func (h *TargetHandler) WaitFrame(ctxt context.Context, id cdp.FrameID) (*cdp.Frame, error)
- func (h *TargetHandler) WaitNode(ctxt context.Context, f *cdp.Frame, id cdp.NodeID) (*cdp.Node, error)
- type Tasks
Constants ¶
const ( // DefaultNewTargetTimeout is the default time to wait for a new target to // be started. DefaultNewTargetTimeout = 3 * time.Second // DefaultCheckDuration is the default time to sleep between a check. DefaultCheckDuration = 50 * time.Millisecond // DefaultPoolStartPort is the default start port number. DefaultPoolStartPort = 9000 // DefaultPoolEndPort is the default end port number. DefaultPoolEndPort = 10000 )
Variables ¶
var ( // ErrInvalidDimensions is the error returned when the retrieved box model is // invalid. ErrInvalidDimensions = errors.New("invalid dimensions") // ErrNoResults is the error returned when there are no matching nodes. ErrNoResults = errors.New("no results") // ErrHasResults is the error returned when there should not be any // matching nodes. ErrHasResults = errors.New("has results") // ErrNotVisible is the error returned when a non-visible node should be // visible. ErrNotVisible = errors.New("not visible") // ErrVisible is the error returned when a visible node should be // non-visible. ErrVisible = errors.New("visible") // ErrDisabled is the error returned when a disabled node should be // enabled. ErrDisabled = errors.New("disabled") // ErrNotSelected is the error returned when a non-selected node should be // selected. ErrNotSelected = errors.New("not selected") // ErrInvalidBoxModel is the error returned when the retrieved box model // data is invalid. ErrInvalidBoxModel = errors.New("invalid box model") )
Error types.
Functions ¶
func ButtonLeft ¶
func ButtonLeft(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams
ButtonLeft is a mouse action option to set the button clicked as the left mouse button.
func ButtonMiddle ¶
func ButtonMiddle(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams
ButtonMiddle is a mouse action option to set the button clicked as the middle mouse button.
func ButtonNone ¶
func ButtonNone(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams
ButtonNone is a mouse action option to set the button clicked as none (used for mouse movements).
func ButtonRight ¶
func ButtonRight(p *input.DispatchMouseEventParams) *input.DispatchMouseEventParams
ButtonRight is a mouse action option to set the button clicked as the right mouse button.
func ByID ¶
func ByID(s *Selector)
ByID is a query option to select a single element by their CSS #id.
func ByNodeID ¶
func ByNodeID(s *Selector)
ByNodeID is a query option to select elements by their NodeIDs.
func ByQuery ¶
func ByQuery(s *Selector)
ByQuery is a query option to select a single element using DOM.querySelector.
func ByQueryAll ¶
func ByQueryAll(s *Selector)
ByQueryAll is a query option to select elements by DOM.querySelectorAll.
func BySearch ¶
func BySearch(s *Selector)
BySearch is a query option via DOM.performSearch (works with both CSS and XPath queries).
func EvalAsValue ¶
func EvalAsValue(p *rundom.EvaluateParams) *rundom.EvaluateParams
EvalAsValue is a evaluate option that will cause the evaluated script to encode the result of the expression as a JSON-encoded value.
func EvalIgnoreExceptions ¶
func EvalIgnoreExceptions(p *rundom.EvaluateParams) *rundom.EvaluateParams
EvalIgnoreExceptions is a evaluate option that will cause script evaluation to ignore exceptions.
func EvalWithCommandLineAPI ¶
func EvalWithCommandLineAPI(p *rundom.EvaluateParams) *rundom.EvaluateParams
EvalWithCommandLineAPI is an evaluate option to make the DevTools Command Line API available to the evaluated script.
Note: this should not be used with untrusted Javascript.
func NodeEnabled ¶
func NodeEnabled(s *Selector)
NodeEnabled is a query option to wait until the element is enabled.
func NodeNotPresent ¶
func NodeNotPresent(s *Selector)
NodeNotPresent is a query option to wait until no elements match are present matching the selector.
func NodeNotVisible ¶
func NodeNotVisible(s *Selector)
NodeNotVisible is a query option to wait until the element is not visible.
func NodeReady ¶
func NodeReady(s *Selector)
NodeReady is a query option to wait until the element is ready.
func NodeSelected ¶
func NodeSelected(s *Selector)
NodeSelected is a query option to wait until the element is selected.
func NodeVisible ¶
func NodeVisible(s *Selector)
NodeVisible is a query option to wait until the element is visible.
Types ¶
type Action ¶
type Action interface { // Do executes the action using the provided context and frame handler. Do(context.Context, cdp.Handler) error }
Action is the common interface for an action that will be executed against a context and frame handler.
func AddOnLoadScript ¶
func AddOnLoadScript(source string, id *page.ScriptIdentifier) Action
AddOnLoadScript adds a script to evaluate on page load.
func AttributeValue ¶
func AttributeValue(sel interface{}, name string, value *string, ok *bool, opts ...QueryOption) Action
AttributeValue retrieves the element attribute value for the first node matching the selector.
func Attributes ¶
func Attributes(sel interface{}, attributes *map[string]string, opts ...QueryOption) Action
Attributes retrieves the element attributes for the first node matching the selector.
func Blur ¶
func Blur(sel interface{}, opts ...QueryOption) Action
Blur unfocuses (blurs) the first node matching the selector.
func CaptureScreenshot ¶
CaptureScreenshot captures takes a full page screenshot.
func Clear ¶
func Clear(sel interface{}, opts ...QueryOption) Action
Clear clears the values of any input/textarea nodes matching the selector.
func Click ¶
func Click(sel interface{}, opts ...QueryOption) Action
Click sends a mouse click event to the first node matching the selector.
func ComputedStyle ¶
func ComputedStyle(sel interface{}, style *[]*css.ComputedProperty, opts ...QueryOption) Action
ComputedStyle retrieves the computed style of the first node matching the selector.
func Dimensions ¶
func Dimensions(sel interface{}, model **dom.BoxModel, opts ...QueryOption) Action
Dimensions retrieves the box model dimensions for the first node matching the selector.
func DoubleClick ¶
func DoubleClick(sel interface{}, opts ...QueryOption) Action
DoubleClick sends a mouse double click event to the first node matching the selector.
func Evaluate ¶
func Evaluate(expression string, res interface{}, opts ...EvaluateOption) Action
Evaluate is an action to evaluate the Javascript expression, unmarshaling the result of the script evaluation to res.
When res is a type other than *[]byte, or **chromedp/cdp/runtime.RemoteObject, then the result of the script evaluation will be returned "by value" (ie, JSON-encoded), and subsequently an attempt will be made to json.Unmarshal the script result to res.
Otherwise, when res is a *[]byte, the raw JSON-encoded value of the script result will be placed in res. Similarly, if res is a *runtime.RemoteObject, then res will be set to the low-level protocol type, and no attempt will be made to convert the result.
Note: any exception encountered will be returned as an error.
func EvaluateAsDevTools ¶
func EvaluateAsDevTools(expression string, res interface{}, opts ...EvaluateOption) Action
EvaluateAsDevTools is an action that evaluates a Javascript expression as Chrome DevTools would, evaluating the expression in the "console" context, and making the Command Line API available to the script.
Note: this should not be used with untrusted Javascript.
func Focus ¶
func Focus(sel interface{}, opts ...QueryOption) Action
Focus focuses the first node matching the selector.
func InnerHTML ¶
func InnerHTML(sel interface{}, html *string, opts ...QueryOption) Action
InnerHTML retrieves the inner html of the first node matching the selector.
func JavascriptAttribute ¶
func JavascriptAttribute(sel interface{}, name string, res interface{}, opts ...QueryOption) Action
JavascriptAttribute retrieves the Javascript attribute for the first node matching the selector.
func KeyAction ¶
KeyAction will synthesize a keyDown, char, and keyUp event for each rune contained in keys along with any supplied key options.
Only well-known, "printable" characters will have char events synthesized.
Please see the chromedp/kb package for implementation details and the list of well-known keys.
func KeyActionNode ¶
KeyActionNode dispatches a key event on a node.
func MatchedStyle ¶
func MatchedStyle(sel interface{}, style **css.GetMatchedStylesForNodeReturns, opts ...QueryOption) Action
MatchedStyle retrieves the matched style information for the first node matching the selector.
func MouseAction ¶
func MouseAction(typ input.MouseType, x, y int64, opts ...MouseOption) Action
MouseAction is a mouse action.
func MouseClickNode ¶
func MouseClickNode(n *cdp.Node, opts ...MouseOption) Action
MouseClickNode dispatches a mouse left button click event at the center of a specified node.
Note that the window will be scrolled if the node is not within the window's viewport.
func MouseClickXY ¶
func MouseClickXY(x, y int64, opts ...MouseOption) Action
MouseClickXY sends a left mouse button click (ie, mousePressed and mouseReleased event) at the X, Y location.
func NavigateBack ¶
func NavigateBack() Action
NavigateBack navigates the current frame backwards in its history.
func NavigateForward ¶
func NavigateForward() Action
NavigateForward navigates the current frame forwards in its history.
func NavigateToHistoryEntry ¶
NavigateToHistoryEntry is an action to navigate to the specified navigation entry.
func NavigationEntries ¶
func NavigationEntries(currentIndex *int64, entries *[]*page.NavigationEntry) Action
NavigationEntries is an action to retrieve the page's navigation history entries.
func NodeIDs ¶
func NodeIDs(sel interface{}, ids *[]cdp.NodeID, opts ...QueryOption) Action
NodeIDs retrieves the node IDs matching the selector.
func Nodes ¶
func Nodes(sel interface{}, nodes *[]*cdp.Node, opts ...QueryOption) Action
Nodes retrieves the document nodes matching the selector.
func OuterHTML ¶
func OuterHTML(sel interface{}, html *string, opts ...QueryOption) Action
OuterHTML retrieves the outer html of the first node matching the selector.
func Query ¶
func Query(sel interface{}, opts ...QueryOption) Action
Query is an action to query for document nodes match the specified sel and the supplied query options.
func QueryAfter ¶
func QueryAfter(sel interface{}, f func(context.Context, cdp.Handler, ...*cdp.Node) error, opts ...QueryOption) Action
QueryAfter is an action that will match the specified sel using the supplied query options, and after the visibility conditions of the query have been met, will execute f.
func RemoveAttribute ¶
func RemoveAttribute(sel interface{}, name string, opts ...QueryOption) Action
RemoveAttribute removes the element attribute with name from the first node matching the selector.
func RemoveOnLoadScript ¶
func RemoveOnLoadScript(id page.ScriptIdentifier) Action
RemoveOnLoadScript removes a script to evaluate on page load.
func Reset ¶
func Reset(sel interface{}, opts ...QueryOption) Action
Reset is an action that resets the form of the first node matching the selector belongs to.
func Screenshot ¶
func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) Action
Screenshot takes a screenshot of the first node matching the selector.
func ScrollIntoView ¶
func ScrollIntoView(sel interface{}, opts ...QueryOption) Action
ScrollIntoView scrolls the window to the first node matching the selector.
func SendKeys ¶
func SendKeys(sel interface{}, v string, opts ...QueryOption) Action
SendKeys synthesizes the key up, char, and down events as needed for the runes in v, sending them to the first node matching the selector.
Note: when selector matches a input[type="file"] node, then dom.SetFileInputFiles is used to set the upload path of the input node to v.
func SetAttributeValue ¶
func SetAttributeValue(sel interface{}, name, value string, opts ...QueryOption) Action
SetAttributeValue sets the element attribute with name to value for the first node matching the selector.
func SetAttributes ¶
func SetAttributes(sel interface{}, attributes map[string]string, opts ...QueryOption) Action
SetAttributes sets the element attributes for the first node matching the selector.
func SetJavascriptAttribute ¶
func SetJavascriptAttribute(sel interface{}, name, value string, opts ...QueryOption) Action
SetJavascriptAttribute sets the javascript attribute for the first node matching the selector.
func SetUploadFiles ¶
func SetUploadFiles(sel interface{}, files []string, opts ...QueryOption) Action
SetUploadFiles sets the files to upload (ie, for a input[type="file"] node) for the first node matching the selector.
func SetValue ¶
func SetValue(sel interface{}, value string, opts ...QueryOption) Action
SetValue sets the value of an element.
func Sleep ¶
Sleep is an empty action that calls time.Sleep with the specified duration.
Note: this is a temporary action definition for convenience, and will likely be marked for deprecation in the future, after the remaining Actions have been able to be written/tested.
func Submit ¶
func Submit(sel interface{}, opts ...QueryOption) Action
Submit is an action that submits the form of the first node matching the selector belongs to.
func Text ¶
func Text(sel interface{}, text *string, opts ...QueryOption) Action
Text retrieves the visible text of the first node matching the selector.
func Value ¶
func Value(sel interface{}, value *string, opts ...QueryOption) Action
Value retrieves the value of the first node matching the selector.
func WaitEnabled ¶
func WaitEnabled(sel interface{}, opts ...QueryOption) Action
WaitEnabled waits until the selected element is enabled (does not have attribute 'disabled').
func WaitNotPresent ¶
func WaitNotPresent(sel interface{}, opts ...QueryOption) Action
WaitNotPresent waits until no elements match the specified selector.
func WaitNotVisible ¶
func WaitNotVisible(sel interface{}, opts ...QueryOption) Action
WaitNotVisible waits until the selected element is not visible.
func WaitReady ¶
func WaitReady(sel interface{}, opts ...QueryOption) Action
WaitReady waits until the element is ready (ie, loaded by chromedp).
func WaitSelected ¶
func WaitSelected(sel interface{}, opts ...QueryOption) Action
WaitSelected waits until the element is selected (has attribute 'selected').
func WaitVisible ¶
func WaitVisible(sel interface{}, opts ...QueryOption) Action
WaitVisible waits until the selected element is visible.
type ActionFunc ¶
ActionFunc is a adapter to allow the use of ordinary func's as an Action.
type CDP ¶
CDP contains information for managing a Chrome process runner, low level JSON and websocket client, and associated network, page, and DOM handling.
func (*CDP) CloseByIndex ¶
CloseByIndex closes the Chrome target with specified index i.
func (*CDP) GetHandlerByID ¶
GetHandlerByID retrieves the domains manager for the specified target ID.
func (*CDP) GetHandlerByIndex ¶
GetHandlerByIndex retrieves the domains manager for the specified index.
func (*CDP) ListTargets ¶
ListTargets returns the target IDs of the managed targets.
func (*CDP) NewTarget ¶
NewTarget is an action that creates a new Chrome target, and sets it as the active target.
func (*CDP) SetHandler ¶
SetHandler sets the active handler to the target with the specified index.
func (*CDP) SetHandlerByID ¶
SetHandlerByID sets the active target to the target with the specified id.
func (*CDP) SetTarget ¶
SetTarget is an action that sets the active Chrome handler to the specified index i.
func (*CDP) SetTargetByID ¶
SetTargetByID is an action that sets the active Chrome handler to the handler associated with the specified id.
type EvaluateOption ¶
type EvaluateOption func(*rundom.EvaluateParams) *rundom.EvaluateParams
EvaluateOption is the type for script evaluation options.
func EvalObjectGroup ¶
func EvalObjectGroup(objectGroup string) EvaluateOption
EvalObjectGroup is a evaluate option to set the object group.
type KeyOption ¶
type KeyOption func(*input.DispatchKeyEventParams) *input.DispatchKeyEventParams
KeyOption is a key action option.
func KeyModifiers ¶
KeyModifiers is a key action option to add additional modifiers on the key press.
type MouseOption ¶
type MouseOption func(*input.DispatchMouseEventParams) *input.DispatchMouseEventParams
MouseOption is a mouse action option.
func Button ¶
func Button(btn string) MouseOption
Button is a mouse action option to set the button to click from a string.
func ButtonModifiers ¶
func ButtonModifiers(modifiers ...input.Modifier) MouseOption
ButtonModifiers is a mouse action option to add additional input modifiers for a button click.
func ButtonType ¶
func ButtonType(button input.ButtonType) MouseOption
ButtonType is a mouse action option to set the button to click.
func ClickCount ¶
func ClickCount(n int) MouseOption
ClickCount is a mouse action option to set the click count.
type Option ¶
Option is a Chrome Debugging Protocol option.
func WithConsolef ¶
WithConsolef is a CDP option to specify a func to receive chrome log events.
Note: NOT YET IMPLEMENTED.
func WithDebugf ¶
WithDebugf is a CDP option to specify a func to receive debug logging (ie, protocol information).
func WithErrorf ¶
WithErrorf is a CDP option to specify a func to receive error logging.
func WithRunner ¶
WithRunner is a CDP option to specify the underlying Chrome runner to monitor for page handlers.
func WithRunnerOptions ¶
func WithRunnerOptions(opts ...runner.CommandLineOption) Option
WithRunnerOptions is a CDP option to specify the options to pass to a newly created Chrome process runner.
func WithTargets ¶
WithTargets is a CDP option to specify the incoming targets to monitor for page handlers.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages a pool of running Chrome processes.
func NewPool ¶
func NewPool(opts ...PoolOption) (*Pool, error)
NewPool creates a new Chrome runner pool.
type PoolOption ¶
PoolOption is a pool option.
func PoolLog ¶
func PoolLog(logf, debugf, errorf LogFunc) PoolOption
PoolLog is a pool option to set the logging to use for the pool.
func PortRange ¶
func PortRange(start, end int) PoolOption
PortRange is a pool option to set the port range to use.
type QueryOption ¶
type QueryOption func(*Selector)
QueryOption is a element query selector option.
func After ¶
After is a query option to set a func that will be executed after the wait has succeeded.
func AtLeast ¶
func AtLeast(n int) QueryOption
AtLeast is a query option to wait until at least n elements are returned from the query selector.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector holds information pertaining to an element query select action.
type TargetHandler ¶
TargetHandler manages a Chrome Debugging Protocol target.
func NewTargetHandler ¶
func NewTargetHandler(t client.Target, logf, debugf, errorf LogFunc) (*TargetHandler, error)
NewTargetHandler creates a new handler for the specified client target.
func (*TargetHandler) Execute ¶
func (h *TargetHandler) Execute(ctxt context.Context, commandType cdp.MethodType, params easyjson.Marshaler, res easyjson.Unmarshaler) error
Execute executes commandType against the endpoint passed to Run, using the provided context and params, decoding the result of the command to res.
func (*TargetHandler) Listen ¶
func (h *TargetHandler) Listen(eventTypes ...cdp.MethodType) <-chan interface{}
Listen creates a listener for the specified event types.
func (*TargetHandler) Release ¶
func (h *TargetHandler) Release(ch <-chan interface{})
Release releases a channel returned from Listen.
func (*TargetHandler) Run ¶
func (h *TargetHandler) Run(ctxt context.Context) error
Run starts the processing of commands and events of the client target provided to NewTargetHandler.
Callers can stop Run by closing the passed context.
func (*TargetHandler) SetActive ¶
SetActive sets the currently active frame after a successful navigation.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
accessibility
Package accessibility provides the Chrome Debugging Protocol commands, types, and events for the Accessibility domain.
|
Package accessibility provides the Chrome Debugging Protocol commands, types, and events for the Accessibility domain. |
animation
Package animation provides the Chrome Debugging Protocol commands, types, and events for the Animation domain.
|
Package animation provides the Chrome Debugging Protocol commands, types, and events for the Animation domain. |
applicationcache
Package applicationcache provides the Chrome Debugging Protocol commands, types, and events for the ApplicationCache domain.
|
Package applicationcache provides the Chrome Debugging Protocol commands, types, and events for the ApplicationCache domain. |
browser
Package browser provides the Chrome Debugging Protocol commands, types, and events for the Browser domain.
|
Package browser provides the Chrome Debugging Protocol commands, types, and events for the Browser domain. |
cachestorage
Package cachestorage provides the Chrome Debugging Protocol commands, types, and events for the CacheStorage domain.
|
Package cachestorage provides the Chrome Debugging Protocol commands, types, and events for the CacheStorage domain. |
css
Package css provides the Chrome Debugging Protocol commands, types, and events for the CSS domain.
|
Package css provides the Chrome Debugging Protocol commands, types, and events for the CSS domain. |
database
Package database provides the Chrome Debugging Protocol commands, types, and events for the Database domain.
|
Package database provides the Chrome Debugging Protocol commands, types, and events for the Database domain. |
debugger
Package debugger provides the Chrome Debugging Protocol commands, types, and events for the Debugger domain.
|
Package debugger provides the Chrome Debugging Protocol commands, types, and events for the Debugger domain. |
deviceorientation
Package deviceorientation provides the Chrome Debugging Protocol commands, types, and events for the DeviceOrientation domain.
|
Package deviceorientation provides the Chrome Debugging Protocol commands, types, and events for the DeviceOrientation domain. |
dom
Package dom provides the Chrome Debugging Protocol commands, types, and events for the DOM domain.
|
Package dom provides the Chrome Debugging Protocol commands, types, and events for the DOM domain. |
domdebugger
Package domdebugger provides the Chrome Debugging Protocol commands, types, and events for the DOMDebugger domain.
|
Package domdebugger provides the Chrome Debugging Protocol commands, types, and events for the DOMDebugger domain. |
domsnapshot
Package domsnapshot provides the Chrome Debugging Protocol commands, types, and events for the DOMSnapshot domain.
|
Package domsnapshot provides the Chrome Debugging Protocol commands, types, and events for the DOMSnapshot domain. |
domstorage
Package domstorage provides the Chrome Debugging Protocol commands, types, and events for the DOMStorage domain.
|
Package domstorage provides the Chrome Debugging Protocol commands, types, and events for the DOMStorage domain. |
emulation
Package emulation provides the Chrome Debugging Protocol commands, types, and events for the Emulation domain.
|
Package emulation provides the Chrome Debugging Protocol commands, types, and events for the Emulation domain. |
har
Package har provides the Chrome Debugging Protocol commands, types, and events for the HAR domain.
|
Package har provides the Chrome Debugging Protocol commands, types, and events for the HAR domain. |
heapprofiler
Package heapprofiler provides the Chrome Debugging Protocol commands, types, and events for the HeapProfiler domain.
|
Package heapprofiler provides the Chrome Debugging Protocol commands, types, and events for the HeapProfiler domain. |
indexeddb
Package indexeddb provides the Chrome Debugging Protocol commands, types, and events for the IndexedDB domain.
|
Package indexeddb provides the Chrome Debugging Protocol commands, types, and events for the IndexedDB domain. |
input
Package input provides the Chrome Debugging Protocol commands, types, and events for the Input domain.
|
Package input provides the Chrome Debugging Protocol commands, types, and events for the Input domain. |
inspector
Package inspector provides the Chrome Debugging Protocol commands, types, and events for the Inspector domain.
|
Package inspector provides the Chrome Debugging Protocol commands, types, and events for the Inspector domain. |
io
Package io provides the Chrome Debugging Protocol commands, types, and events for the IO domain.
|
Package io provides the Chrome Debugging Protocol commands, types, and events for the IO domain. |
layertree
Package layertree provides the Chrome Debugging Protocol commands, types, and events for the LayerTree domain.
|
Package layertree provides the Chrome Debugging Protocol commands, types, and events for the LayerTree domain. |
log
Package log provides the Chrome Debugging Protocol commands, types, and events for the Log domain.
|
Package log provides the Chrome Debugging Protocol commands, types, and events for the Log domain. |
memory
Package memory provides the Chrome Debugging Protocol commands, types, and events for the Memory domain.
|
Package memory provides the Chrome Debugging Protocol commands, types, and events for the Memory domain. |
network
Package network provides the Chrome Debugging Protocol commands, types, and events for the Network domain.
|
Package network provides the Chrome Debugging Protocol commands, types, and events for the Network domain. |
overlay
Package overlay provides the Chrome Debugging Protocol commands, types, and events for the Overlay domain.
|
Package overlay provides the Chrome Debugging Protocol commands, types, and events for the Overlay domain. |
page
Package page provides the Chrome Debugging Protocol commands, types, and events for the Page domain.
|
Package page provides the Chrome Debugging Protocol commands, types, and events for the Page domain. |
profiler
Package profiler provides the Chrome Debugging Protocol commands, types, and events for the Profiler domain.
|
Package profiler provides the Chrome Debugging Protocol commands, types, and events for the Profiler domain. |
runtime
Package runtime provides the Chrome Debugging Protocol commands, types, and events for the Runtime domain.
|
Package runtime provides the Chrome Debugging Protocol commands, types, and events for the Runtime domain. |
schema
Package schema provides the Chrome Debugging Protocol commands, types, and events for the Schema domain.
|
Package schema provides the Chrome Debugging Protocol commands, types, and events for the Schema domain. |
security
Package security provides the Chrome Debugging Protocol commands, types, and events for the Security domain.
|
Package security provides the Chrome Debugging Protocol commands, types, and events for the Security domain. |
serviceworker
Package serviceworker provides the Chrome Debugging Protocol commands, types, and events for the ServiceWorker domain.
|
Package serviceworker provides the Chrome Debugging Protocol commands, types, and events for the ServiceWorker domain. |
storage
Package storage provides the Chrome Debugging Protocol commands, types, and events for the Storage domain.
|
Package storage provides the Chrome Debugging Protocol commands, types, and events for the Storage domain. |
systeminfo
Package systeminfo provides the Chrome Debugging Protocol commands, types, and events for the SystemInfo domain.
|
Package systeminfo provides the Chrome Debugging Protocol commands, types, and events for the SystemInfo domain. |
target
Package target provides the Chrome Debugging Protocol commands, types, and events for the Target domain.
|
Package target provides the Chrome Debugging Protocol commands, types, and events for the Target domain. |
tethering
Package tethering provides the Chrome Debugging Protocol commands, types, and events for the Tethering domain.
|
Package tethering provides the Chrome Debugging Protocol commands, types, and events for the Tethering domain. |
tracing
Package tracing provides the Chrome Debugging Protocol commands, types, and events for the Tracing domain.
|
Package tracing provides the Chrome Debugging Protocol commands, types, and events for the Tracing domain. |
Package client provides the low level Chrome Debugging Protocol JSON types and related funcs.
|
Package client provides the low level Chrome Debugging Protocol JSON types and related funcs. |
cmd
|
|
chromedp-gen
chromedp-gen is a tool to generate the low-level Chrome Debugging Protocol implementation types used by chromedp, based off Chrome's protocol.json.
|
chromedp-gen is a tool to generate the low-level Chrome Debugging Protocol implementation types used by chromedp, based off Chrome's protocol.json. |
chromedp-gen/fixup
Package fixup modifies/alters/fixes and adds to the low level type definitions for the Chrome Debugging Protocol domains, as generated from protocol.json.
|
Package fixup modifies/alters/fixes and adds to the low level type definitions for the Chrome Debugging Protocol domains, as generated from protocol.json. |
chromedp-gen/gen
Package gen takes the Chrome protocol domain definitions and applies the necessary code generation templates.
|
Package gen takes the Chrome protocol domain definitions and applies the necessary code generation templates. |
chromedp-gen/internal
Package internal contains the types and util funcs common to the chromedp-gen command.
|
Package internal contains the types and util funcs common to the chromedp-gen command. |
chromedp-gen/templates
Package templates contains the valyala/quicktemplate based code generation templates used by chromedp-gen.
|
Package templates contains the valyala/quicktemplate based code generation templates used by chromedp-gen. |
chromedp-proxy
chromedp-proxy provides a cli utility that will proxy requests from a Chrome Debugging Protocol client to a application instance.
|
chromedp-proxy provides a cli utility that will proxy requests from a Chrome Debugging Protocol client to a application instance. |
examples
|
|
Package kb provides keyboard mappings for Chrome DOM Keys for use with input events.
|
Package kb provides keyboard mappings for Chrome DOM Keys for use with input events. |
Package runner provides a Chrome process runner.
|
Package runner provides a Chrome process runner. |