modulepackage
0.0.0-20200525081248-c579b4054dc3
Repository: https://github.com/bootgo/chromedp.git
Documentation: pkg.go.dev
# README
About chromedp

Package chromedp is a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go using the without external dependencies (ie, Selenium, PhantomJS, etc).
Installing
Install in the usual Go way:
go get -u github.com/chromedp/chromedp
Examples
Please see the examples project for more examples. Please refer to the GoDoc API listing for a summary of the API and Actions.
Resources
- chromedp: A New Way to Drive the Web - GopherCon SG 2017 talk
- Chrome DevTools Protocol - Chrome DevTools Protocol Domain documentation
- chromedp examples - various
chromedp
examples github.com/chromedp/cdproto
- GoDoc listing for the CDP domains used bychromedp
github.com/chromedp/cdproto-gen
- tool used to generatecdproto
github.com/chromedp/chromedp-proxy
- a simple CDP proxy for logging CDP clients and browsers
TODO
- Move timeouts to context (defaults)
- Implement more query selector options (allow over riding context timeouts)
- Contextual actions for "dry run" (or via an accumulator?)
- Network loader / manager
- Profiler
# Functions
After is a query option to set a func that will be executed after the wait has succeeded.
AtLeast is a query option to wait until at least n elements are returned from the query selector.
Attributes retrieves the element attributes for the first node matching the selector.
AttributesAll retrieves the element attributes for all nodes matching the selector.
AttributeValue retrieves the element attribute value for the first node matching the selector.
Blur unfocuses (blurs) the first node matching the selector.
Button is a mouse action option to set the button to click from a string.
ButtonLeft is a mouse action option to set the button clicked as the left mouse button.
ButtonMiddle is a mouse action option to set the button clicked as the middle mouse button.
ButtonModifiers is a mouse action option to add additional input modifiers for a button click.
ButtonNone is a mouse action option to set the button clicked as none (used for mouse movements).
ButtonRight is a mouse action option to set the button clicked as the right mouse button.
ButtonType is a mouse action option to set the button to click.
ByFunc is a query option to set the func used to select elements.
ByID is a query option to select a single element by their CSS #id.
ByNodeID is a query option to select elements by their NodeIDs.
ByQuery is a query option to select a single element using DOM.querySelector.
ByQueryAll is a query option to select elements by DOM.querySelectorAll.
BySearch is a query option via DOM.performSearch (works with both CSS and XPath queries).
CaptureScreenshot captures takes a screenshot of the current viewport.
Clear clears the values of any input/textarea nodes matching the selector.
Click sends a mouse click event to the first node matching the selector.
ClickCount is a mouse action option to set the click count.
ComputedStyle retrieves the computed style of the first node matching the selector.
Dimensions retrieves the box model dimensions for the first node matching the selector.
DoubleClick sends a mouse double click event to the first node matching the selector.
EvalAsValue is a evaluate option that will cause the evaluated script to encode the result of the expression as a JSON-encoded value.
EvalIgnoreExceptions is a evaluate option that will cause script evaluation to ignore exceptions.
EvalObjectGroup is a evaluate option to set the object group.
Evaluate is an action to evaluate the Javascript expression, unmarshaling the result of the script evaluation to res.
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.
EvalWithCommandLineAPI is an evaluate option to make the DevTools Command Line API available to the evaluated script.
Focus focuses the first node matching the selector.
InnerHTML retrieves the inner html of the first node matching the selector.
JavascriptAttribute retrieves the Javascript attribute for the first node matching the selector.
KeyAction will synthesize a keyDown, char, and keyUp event for each rune contained in keys along with any supplied key options.
KeyActionNode dispatches a key event on a node.
KeyModifiers is a key action option to add additional modifiers on the key press.
Location retrieves the document location.
MatchedStyle retrieves the matched style information for the first node matching the selector.
MouseAction is a mouse action.
MouseClickNode dispatches a mouse left button click event at the center of a specified node.
MouseClickXY sends a left mouse button click (ie, mousePressed and mouseReleased event) at the X, Y location.
Navigate navigates the current frame.
NavigateBack navigates the current frame backwards in its history.
NavigateForward navigates the current frame forwards in its history.
NavigateToHistoryEntry is an action to navigate to the specified navigation entry.
NavigationEntries is an action to retrieve the page's navigation history entries.
New creates and starts a new CDP instance.
NewPool creates a new Chrome runner pool.
NewTargetHandler creates a new handler for the specified client target.
NodeEnabled is a query option to wait until the element is enabled.
NodeIDs retrieves the node IDs matching the selector.
NodeNotPresent is a query option to wait until no elements match are present matching the selector.
NodeNotVisible is a query option to wait until the element is not visible.
NodeReady is a query option to wait until the element is ready.
Nodes retrieves the document nodes matching the selector.
NodeSelected is a query option to wait until the element is selected.
NodeVisible is a query option to wait until the element is visible.
OuterHTML retrieves the outer html of the first node matching the selector.
PoolLog is a pool option to set the logging to use for the pool.
PortRange is a pool option to set the port range to use.
Query is an action to query for document nodes match the specified sel and the supplied query options.
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.
Reload reloads the current page.
RemoveAttribute removes the element attribute with name from the first node matching the selector.
Reset is an action that resets the form of the first node matching the selector belongs to.
Screenshot takes a screenshot of the first node matching the selector.
ScrollIntoView scrolls the window to the first node matching the selector.
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.
SetAttributes sets the element attributes for the first node matching the selector.
SetAttributeValue sets the element attribute with name to value for the first node matching the selector.
SetJavascriptAttribute sets the javascript attribute for the first node matching the selector.
SetUploadFiles sets the files to upload (ie, for a input[type="file"] node) for the first node matching the selector.
SetValue sets the value of an element.
Sleep is an empty action that calls time.Sleep with the specified duration.
Stop stops all navigation and pending resource retrieval.
Submit is an action that submits the form of the first node matching the selector belongs to.
Text retrieves the visible text of the first node matching the selector.
Title retrieves the document title.
Value retrieves the value of the first node matching the selector.
WaitEnabled waits until the selected element is enabled (does not have attribute 'disabled').
WaitFunc is a query option to set a custom wait func.
WaitNotPresent waits until no elements match the specified selector.
WaitNotVisible waits until the selected element is not visible.
WaitReady waits until the element is ready (ie, loaded by chromedp).
WaitSelected waits until the element is selected (has attribute 'selected').
WaitVisible waits until the selected element is visible.
WithClient is a CDP option to use the incoming targets from a client.
WithConsolef is a CDP option to specify a func to receive chrome log events.
WithDebugf is a CDP option to specify a func to receive debug logging (ie, protocol information).
WithErrorf is a CDP option to specify a func to receive error logging.
WithLog is a CDP option that sets the logging, debugging, and error funcs to f.
WithLogf is a CDP option to specify a func to receive general logging.
WithRunner is a CDP option to specify the underlying Chrome runner to monitor for page handlers.
WithRunnerOptions is a CDP option to specify the options to pass to a newly created Chrome process runner.
WithTargets is a CDP option to specify the incoming targets to monitor for page handlers.
WithURL is a CDP option to use a client with the specified URL.
# Constants
DefaultCheckDuration is the default time to sleep between a check.
DefaultNewTargetTimeout is the default time to wait for a new target to be started.
DefaultPoolEndPort is the default end port number.
DefaultPoolStartPort is the default start port number.
ErrChannelClosed is the channel closed error.
ErrDisabled is the disabled error.
ErrHasResults is the has results error.
ErrInvalidBoxModel is the invalid box model error.
ErrInvalidDimensions is the invalid dimensions error.
ErrInvalidHandler is the invalid handler error.
ErrNoResults is the no results error.
ErrNotSelected is the not selected error.
ErrNotVisible is the not visible error.
ErrVisible is the visible error.
# Structs
CDP is the high-level Chrome DevTools Protocol browser manager, handling the browser process runner, WebSocket clients, associated targets, and network, page, and DOM events.
Pool manages a pool of running Chrome processes.
Res is a pool resource.
Selector holds information pertaining to an element query select action.
TargetHandler manages a Chrome DevTools Protocol target.
# Interfaces
Action is the common interface for an action that will be executed against a context and frame handler.
# Type aliases
ActionFunc is a adapter to allow the use of ordinary func's as an Action.
Error is a chromedp error.
EvaluateOption is the type for script evaluation options.
KeyOption is a key action option.
MouseOption is a mouse action option.
Option is a Chrome DevTools Protocol option.
PoolOption is a pool option.
QueryOption is a element query selector option.
Tasks is a sequential list of Actions that can be used as a single Action.