112 lines
2.7 KiB
Go
112 lines
2.7 KiB
Go
// Package accessibility provides the Chrome Debugging Protocol
|
|
// commands, types, and events for the Chrome Accessibility domain.
|
|
//
|
|
// Generated by the chromedp-gen command.
|
|
package accessibility
|
|
|
|
// AUTOGENERATED. DO NOT EDIT.
|
|
|
|
import (
|
|
"context"
|
|
|
|
. "github.com/knq/chromedp/cdp"
|
|
"github.com/mailru/easyjson"
|
|
)
|
|
|
|
var (
|
|
_ BackendNode
|
|
_ BackendNodeID
|
|
_ ComputedProperty
|
|
_ ErrorType
|
|
_ Frame
|
|
_ FrameID
|
|
_ LoaderID
|
|
_ Message
|
|
_ MessageError
|
|
_ MethodType
|
|
_ Node
|
|
_ NodeID
|
|
_ NodeType
|
|
_ PseudoType
|
|
_ RGBA
|
|
_ ShadowRootType
|
|
_ Timestamp
|
|
)
|
|
|
|
// GetPartialAXTreeParams fetches the accessibility node and partial
|
|
// accessibility tree for this DOM node, if it exists.
|
|
type GetPartialAXTreeParams struct {
|
|
NodeID NodeID `json:"nodeId"` // ID of node to get the partial accessibility tree for.
|
|
FetchRelatives bool `json:"fetchRelatives,omitempty"` // Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
|
|
}
|
|
|
|
// GetPartialAXTree fetches the accessibility node and partial accessibility
|
|
// tree for this DOM node, if it exists.
|
|
//
|
|
// parameters:
|
|
// nodeId - ID of node to get the partial accessibility tree for.
|
|
func GetPartialAXTree(nodeId NodeID) *GetPartialAXTreeParams {
|
|
return &GetPartialAXTreeParams{
|
|
NodeID: nodeId,
|
|
}
|
|
}
|
|
|
|
// WithFetchRelatives whether to fetch this nodes ancestors, siblings and
|
|
// children. Defaults to true.
|
|
func (p GetPartialAXTreeParams) WithFetchRelatives(fetchRelatives bool) *GetPartialAXTreeParams {
|
|
p.FetchRelatives = fetchRelatives
|
|
return &p
|
|
}
|
|
|
|
// GetPartialAXTreeReturns return values.
|
|
type GetPartialAXTreeReturns struct {
|
|
Nodes []*AXNode `json:"nodes,omitempty"` // The Accessibility.AXNode for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
|
|
}
|
|
|
|
// Do executes Accessibility.getPartialAXTree.
|
|
//
|
|
// returns:
|
|
// nodes - The Accessibility.AXNode for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
|
|
func (p *GetPartialAXTreeParams) Do(ctxt context.Context, h FrameHandler) (nodes []*AXNode, err error) {
|
|
if ctxt == nil {
|
|
ctxt = context.Background()
|
|
}
|
|
|
|
// marshal
|
|
buf, err := easyjson.Marshal(p)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// execute
|
|
ch := h.Execute(ctxt, CommandAccessibilityGetPartialAXTree, easyjson.RawMessage(buf))
|
|
|
|
// read response
|
|
select {
|
|
case res := <-ch:
|
|
if res == nil {
|
|
return nil, ErrChannelClosed
|
|
}
|
|
|
|
switch v := res.(type) {
|
|
case easyjson.RawMessage:
|
|
// unmarshal
|
|
var r GetPartialAXTreeReturns
|
|
err = easyjson.Unmarshal(v, &r)
|
|
if err != nil {
|
|
return nil, ErrInvalidResult
|
|
}
|
|
|
|
return r.Nodes, nil
|
|
|
|
case error:
|
|
return nil, v
|
|
}
|
|
|
|
case <-ctxt.Done():
|
|
return nil, ErrContextDone
|
|
}
|
|
|
|
return nil, ErrUnknownResult
|
|
}
|