Documentation ¶
Overview ¶
Package devtool provides methods for interacting with a DevTools endpoint.
To activate the DevTools endpoint, a browser (or other debug target) should be started with debugging enabled:
chromium --remote-debugging-port=9222 ./<path>/EdgeDiagnosticsAdapter.exe --port 9223 node --inspect=9224
Create a new DevTools instance that interacts with the given URL:
devt := devtool.New("http://127.0.0.1:9222")
Get the active page or create a new one:
devt := devtool.New("http://127.0.0.1:9222") page, err := devt.Get(context.Background(), devtool.Page) if err != nil { page, err = devt.Create(context.Background()) if err != nil { // Handle error. } } // ...
Set request timeouts via contexts:
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() devt := devtool.New("http://127.0.0.1:9222") list, err := devt.List(ctx) if err != nil { // Handle error. } // ...
Index ¶
- type DevTools
- func (d *DevTools) Activate(ctx context.Context, t *Target) error
- func (d *DevTools) Close(ctx context.Context, t *Target) error
- func (d *DevTools) Create(ctx context.Context) (*Target, error)
- func (d *DevTools) CreateURL(ctx context.Context, openURL string) (*Target, error)
- func (d *DevTools) Get(ctx context.Context, typ Type) (*Target, error)
- func (d *DevTools) List(ctx context.Context) ([]*Target, error)
- func (d *DevTools) Version(ctx context.Context) (*Version, error)
- type DevToolsOption
- type Target
- type Type
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DevTools ¶
type DevTools struct {
// contains filtered or unexported fields
}
DevTools represents a devtools endpoint for managing and querying information about targets.
func New ¶
func New(url string, opts ...DevToolsOption) *DevTools
New returns a DevTools instance that uses URL.
func (*DevTools) CreateURL ¶
CreateURL is like Create but opens the provided URL. The URL must be valid and begin with "http://" or "https://".
type DevToolsOption ¶
type DevToolsOption func(*DevTools)
DevToolsOption represents a function that sets a DevTools option.
func WithClient ¶
func WithClient(client *http.Client) DevToolsOption
WithClient returns a DevToolsOption that sets the http Client used for HTTP GET requests.
type Target ¶
type Target struct { Description string `json:"description"` DevToolsFrontendURL string `json:"devtoolsFrontendUrl"` ID string `json:"id"` Title string `json:"title"` Type Type `json:"type"` URL string `json:"url"` WebSocketDebuggerURL string `json:"webSocketDebuggerUrl"` }
Target represents a devtools target, e.g. a browser tab.
type Version ¶
type Version struct { // Present in Chrome, Edge, Node, etc. Browser string `json:"Browser"` Protocol string `json:"Protocol-Version"` // Present in Chrome, Edge. UserAgent string `json:"User-Agent"` V8 string `json:"V8-Version"` WebKit string `json:"WebKit-Version"` // Present on Android. AndroidPackage string `json:"Android-Package"` }
Version contains the version information for the DevTools endpoint.