Updating to latest protocol.json

This commit is contained in:
Kenneth Shaw 2017-07-14 10:29:52 +07:00
parent 79b88e2c01
commit 2d46c88024
8 changed files with 277 additions and 52 deletions

View File

@ -1037,17 +1037,34 @@ func (p *MarkUndoableStateParams) Do(ctxt context.Context, h cdp.Handler) (err e
// FocusParams focuses the given element. // FocusParams focuses the given element.
type FocusParams struct { type FocusParams struct {
NodeID cdp.NodeID `json:"nodeId"` // Id of the node to focus. NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node.
BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node.
ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper.
} }
// Focus focuses the given element. // Focus focuses the given element.
// //
// parameters: // parameters:
// nodeID - Id of the node to focus. func Focus() *FocusParams {
func Focus(nodeID cdp.NodeID) *FocusParams { return &FocusParams{}
return &FocusParams{ }
NodeID: nodeID,
} // WithNodeID identifier of the node.
func (p FocusParams) WithNodeID(nodeID cdp.NodeID) *FocusParams {
p.NodeID = nodeID
return &p
}
// WithBackendNodeID identifier of the backend node.
func (p FocusParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *FocusParams {
p.BackendNodeID = backendNodeID
return &p
}
// WithObjectID javaScript object id of the node wrapper.
func (p FocusParams) WithObjectID(objectID runtime.RemoteObjectID) *FocusParams {
p.ObjectID = objectID
return &p
} }
// Do executes DOM.focus against the provided context and // Do executes DOM.focus against the provided context and
@ -1058,22 +1075,40 @@ func (p *FocusParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
// SetFileInputFilesParams sets files for the given file input element. // SetFileInputFilesParams sets files for the given file input element.
type SetFileInputFilesParams struct { type SetFileInputFilesParams struct {
NodeID cdp.NodeID `json:"nodeId"` // Id of the file input node to set files for.
Files []string `json:"files"` // Array of file paths to set. Files []string `json:"files"` // Array of file paths to set.
NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node.
BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node.
ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper.
} }
// SetFileInputFiles sets files for the given file input element. // SetFileInputFiles sets files for the given file input element.
// //
// parameters: // parameters:
// nodeID - Id of the file input node to set files for.
// files - Array of file paths to set. // files - Array of file paths to set.
func SetFileInputFiles(nodeID cdp.NodeID, files []string) *SetFileInputFilesParams { func SetFileInputFiles(files []string) *SetFileInputFilesParams {
return &SetFileInputFilesParams{ return &SetFileInputFilesParams{
NodeID: nodeID,
Files: files, Files: files,
} }
} }
// WithNodeID identifier of the node.
func (p SetFileInputFilesParams) WithNodeID(nodeID cdp.NodeID) *SetFileInputFilesParams {
p.NodeID = nodeID
return &p
}
// WithBackendNodeID identifier of the backend node.
func (p SetFileInputFilesParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *SetFileInputFilesParams {
p.BackendNodeID = backendNodeID
return &p
}
// WithObjectID javaScript object id of the node wrapper.
func (p SetFileInputFilesParams) WithObjectID(objectID runtime.RemoteObjectID) *SetFileInputFilesParams {
p.ObjectID = objectID
return &p
}
// Do executes DOM.setFileInputFiles against the provided context and // Do executes DOM.setFileInputFiles against the provided context and
// target handler. // target handler.
func (p *SetFileInputFilesParams) Do(ctxt context.Context, h cdp.Handler) (err error) { func (p *SetFileInputFilesParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
@ -1082,17 +1117,34 @@ func (p *SetFileInputFilesParams) Do(ctxt context.Context, h cdp.Handler) (err e
// GetBoxModelParams returns boxes for the currently selected nodes. // GetBoxModelParams returns boxes for the currently selected nodes.
type GetBoxModelParams struct { type GetBoxModelParams struct {
NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get box model for. NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node.
BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node.
ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper.
} }
// GetBoxModel returns boxes for the currently selected nodes. // GetBoxModel returns boxes for the currently selected nodes.
// //
// parameters: // parameters:
// nodeID - Id of the node to get box model for. func GetBoxModel() *GetBoxModelParams {
func GetBoxModel(nodeID cdp.NodeID) *GetBoxModelParams { return &GetBoxModelParams{}
return &GetBoxModelParams{ }
NodeID: nodeID,
} // WithNodeID identifier of the node.
func (p GetBoxModelParams) WithNodeID(nodeID cdp.NodeID) *GetBoxModelParams {
p.NodeID = nodeID
return &p
}
// WithBackendNodeID identifier of the backend node.
func (p GetBoxModelParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *GetBoxModelParams {
p.BackendNodeID = backendNodeID
return &p
}
// WithObjectID javaScript object id of the node wrapper.
func (p GetBoxModelParams) WithObjectID(objectID runtime.RemoteObjectID) *GetBoxModelParams {
p.ObjectID = objectID
return &p
} }
// GetBoxModelReturns return values. // GetBoxModelReturns return values.

View File

@ -637,8 +637,6 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDom7(in *jlexer.Lexer, out *Se
continue continue
} }
switch key { switch key {
case "nodeId":
(out.NodeID).UnmarshalEasyJSON(in)
case "files": case "files":
if in.IsNull() { if in.IsNull() {
in.Skip() in.Skip()
@ -662,6 +660,12 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDom7(in *jlexer.Lexer, out *Se
} }
in.Delim(']') in.Delim(']')
} }
case "nodeId":
(out.NodeID).UnmarshalEasyJSON(in)
case "backendNodeId":
(out.BackendNodeID).UnmarshalEasyJSON(in)
case "objectId":
out.ObjectID = runtime.RemoteObjectID(in.String())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -680,12 +684,6 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDom7(out *jwriter.Writer, in S
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"nodeId\":")
out.Int64(int64(in.NodeID))
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"files\":") out.RawString("\"files\":")
if in.Files == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { if in.Files == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null") out.RawString("null")
@ -699,6 +697,30 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDom7(out *jwriter.Writer, in S
} }
out.RawByte(']') out.RawByte(']')
} }
if in.NodeID != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"nodeId\":")
out.Int64(int64(in.NodeID))
}
if in.BackendNodeID != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"backendNodeId\":")
out.Int64(int64(in.BackendNodeID))
}
if in.ObjectID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"objectId\":")
out.String(string(in.ObjectID))
}
out.RawByte('}') out.RawByte('}')
} }
@ -3667,6 +3689,10 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDom45(in *jlexer.Lexer, out *G
switch key { switch key {
case "nodeId": case "nodeId":
(out.NodeID).UnmarshalEasyJSON(in) (out.NodeID).UnmarshalEasyJSON(in)
case "backendNodeId":
(out.BackendNodeID).UnmarshalEasyJSON(in)
case "objectId":
out.ObjectID = runtime.RemoteObjectID(in.String())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -3681,12 +3707,30 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDom45(out *jwriter.Writer, in
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
if in.NodeID != 0 {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"nodeId\":") out.RawString("\"nodeId\":")
out.Int64(int64(in.NodeID)) out.Int64(int64(in.NodeID))
}
if in.BackendNodeID != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"backendNodeId\":")
out.Int64(int64(in.BackendNodeID))
}
if in.ObjectID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"objectId\":")
out.String(string(in.ObjectID))
}
out.RawByte('}') out.RawByte('}')
} }
@ -3902,6 +3946,10 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDom48(in *jlexer.Lexer, out *F
switch key { switch key {
case "nodeId": case "nodeId":
(out.NodeID).UnmarshalEasyJSON(in) (out.NodeID).UnmarshalEasyJSON(in)
case "backendNodeId":
(out.BackendNodeID).UnmarshalEasyJSON(in)
case "objectId":
out.ObjectID = runtime.RemoteObjectID(in.String())
default: default:
in.SkipRecursive() in.SkipRecursive()
} }
@ -3916,12 +3964,30 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDom48(out *jwriter.Writer, in
out.RawByte('{') out.RawByte('{')
first := true first := true
_ = first _ = first
if in.NodeID != 0 {
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }
first = false first = false
out.RawString("\"nodeId\":") out.RawString("\"nodeId\":")
out.Int64(int64(in.NodeID)) out.Int64(int64(in.NodeID))
}
if in.BackendNodeID != 0 {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"backendNodeId\":")
out.Int64(int64(in.BackendNodeID))
}
if in.ObjectID != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"objectId\":")
out.String(string(in.ObjectID))
}
out.RawByte('}') out.RawByte('}')
} }

View File

@ -600,6 +600,14 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomsnapshot4(in *jlexer.Lexer,
out.NodeName = string(in.String()) out.NodeName = string(in.String())
case "nodeValue": case "nodeValue":
out.NodeValue = string(in.String()) out.NodeValue = string(in.String())
case "textValue":
out.TextValue = string(in.String())
case "inputValue":
out.InputValue = string(in.String())
case "inputChecked":
out.InputChecked = bool(in.Bool())
case "optionSelected":
out.OptionSelected = bool(in.Bool())
case "backendNodeId": case "backendNodeId":
(out.BackendNodeID).UnmarshalEasyJSON(in) (out.BackendNodeID).UnmarshalEasyJSON(in)
case "childNodeIndexes": case "childNodeIndexes":
@ -735,6 +743,38 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomsnapshot4(out *jwriter.Writ
first = false first = false
out.RawString("\"nodeValue\":") out.RawString("\"nodeValue\":")
out.String(string(in.NodeValue)) out.String(string(in.NodeValue))
if in.TextValue != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"textValue\":")
out.String(string(in.TextValue))
}
if in.InputValue != "" {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"inputValue\":")
out.String(string(in.InputValue))
}
if in.InputChecked {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"inputChecked\":")
out.Bool(bool(in.InputChecked))
}
if in.OptionSelected {
if !first {
out.RawByte(',')
}
first = false
out.RawString("\"optionSelected\":")
out.Bool(bool(in.OptionSelected))
}
if !first { if !first {
out.RawByte(',') out.RawByte(',')
} }

View File

@ -13,6 +13,10 @@ type DOMNode struct {
NodeType cdp.NodeType `json:"nodeType"` // Node's nodeType. NodeType cdp.NodeType `json:"nodeType"` // Node's nodeType.
NodeName string `json:"nodeName"` // Node's nodeName. NodeName string `json:"nodeName"` // Node's nodeName.
NodeValue string `json:"nodeValue"` // Node's nodeValue. NodeValue string `json:"nodeValue"` // Node's nodeValue.
TextValue string `json:"textValue,omitempty"` // Only set for textarea elements, contains the text value.
InputValue string `json:"inputValue,omitempty"` // Only set for input elements, contains the input's associated text value.
InputChecked bool `json:"inputChecked,omitempty"` // Only set for radio and checkbox input elements, indicates if the element has been checked
OptionSelected bool `json:"optionSelected,omitempty"` // Only set for option elements, indicates if the element has been selected
BackendNodeID cdp.BackendNodeID `json:"backendNodeId"` // Node's id, corresponds to DOM.Node.backendNodeId. BackendNodeID cdp.BackendNodeID `json:"backendNodeId"` // Node's id, corresponds to DOM.Node.backendNodeId.
ChildNodeIndexes []int64 `json:"childNodeIndexes,omitempty"` // The indexes of the node's child nodes in the domNodes array returned by getSnapshot, if any. ChildNodeIndexes []int64 `json:"childNodeIndexes,omitempty"` // The indexes of the node's child nodes in the domNodes array returned by getSnapshot, if any.
Attributes []*NameValue `json:"attributes,omitempty"` // Attributes of an Element node. Attributes []*NameValue `json:"attributes,omitempty"` // Attributes of an Element node.

View File

@ -6016,7 +6016,20 @@
{ {
"name": "nodeId", "name": "nodeId",
"$ref": "NodeId", "$ref": "NodeId",
"description": "Id of the node to focus." "optional": true,
"description": "Identifier of the node."
},
{
"name": "backendNodeId",
"$ref": "BackendNodeId",
"optional": true,
"description": "Identifier of the backend node."
},
{
"name": "objectId",
"$ref": "Runtime.RemoteObjectId",
"optional": true,
"description": "JavaScript object id of the node wrapper."
} }
], ],
"description": "Focuses the given element.", "description": "Focuses the given element.",
@ -6025,11 +6038,6 @@
{ {
"name": "setFileInputFiles", "name": "setFileInputFiles",
"parameters": [ "parameters": [
{
"name": "nodeId",
"$ref": "NodeId",
"description": "Id of the file input node to set files for."
},
{ {
"name": "files", "name": "files",
"type": "array", "type": "array",
@ -6037,6 +6045,24 @@
"type": "string" "type": "string"
}, },
"description": "Array of file paths to set." "description": "Array of file paths to set."
},
{
"name": "nodeId",
"$ref": "NodeId",
"optional": true,
"description": "Identifier of the node."
},
{
"name": "backendNodeId",
"$ref": "BackendNodeId",
"optional": true,
"description": "Identifier of the backend node."
},
{
"name": "objectId",
"$ref": "Runtime.RemoteObjectId",
"optional": true,
"description": "JavaScript object id of the node wrapper."
} }
], ],
"description": "Sets files for the given file input element.", "description": "Sets files for the given file input element.",
@ -6048,7 +6074,20 @@
{ {
"name": "nodeId", "name": "nodeId",
"$ref": "NodeId", "$ref": "NodeId",
"description": "Id of the node to get box model for." "optional": true,
"description": "Identifier of the node."
},
{
"name": "backendNodeId",
"$ref": "BackendNodeId",
"optional": true,
"description": "Identifier of the backend node."
},
{
"name": "objectId",
"$ref": "Runtime.RemoteObjectId",
"optional": true,
"description": "JavaScript object id of the node wrapper."
} }
], ],
"returns": [ "returns": [
@ -7517,6 +7556,30 @@
"type": "string", "type": "string",
"description": "<code>Node</code>'s nodeValue." "description": "<code>Node</code>'s nodeValue."
}, },
{
"name": "textValue",
"type": "string",
"optional": true,
"description": "Only set for textarea elements, contains the text value."
},
{
"name": "inputValue",
"type": "string",
"optional": true,
"description": "Only set for input elements, contains the input's associated text value."
},
{
"name": "inputChecked",
"type": "boolean",
"optional": true,
"description": "Only set for radio and checkbox input elements, indicates if the element has been checked"
},
{
"name": "optionSelected",
"type": "boolean",
"optional": true,
"description": "Only set for option elements, indicates if the element has been selected"
},
{ {
"name": "backendNodeId", "name": "backendNodeId",
"$ref": "DOM.BackendNodeId", "$ref": "DOM.BackendNodeId",

View File

@ -65,7 +65,7 @@ func MouseClickNode(n *cdp.Node, opts ...MouseOption) Action {
return err return err
} }
box, err := dom.GetBoxModel(n.NodeID).Do(ctxt, h) box, err := dom.GetBoxModel().WithNodeID(n.NodeID).Do(ctxt, h)
if err != nil { if err != nil {
return err return err
} }
@ -174,7 +174,7 @@ func KeyAction(keys string, opts ...KeyOption) Action {
// KeyActionNode dispatches a key event on a node. // KeyActionNode dispatches a key event on a node.
func KeyActionNode(n *cdp.Node, keys string, opts ...KeyOption) Action { func KeyActionNode(n *cdp.Node, keys string, opts ...KeyOption) Action {
return ActionFunc(func(ctxt context.Context, h cdp.Handler) error { return ActionFunc(func(ctxt context.Context, h cdp.Handler) error {
err := dom.Focus(n.NodeID).Do(ctxt, h) err := dom.Focus().WithNodeID(n.NodeID).Do(ctxt, h)
if err != nil { if err != nil {
return err return err
} }

View File

@ -55,7 +55,7 @@ func Focus(sel interface{}, opts ...QueryOption) Action {
return fmt.Errorf("selector `%s` did not return any nodes", sel) return fmt.Errorf("selector `%s` did not return any nodes", sel)
} }
return dom.Focus(nodes[0].NodeID).Do(ctxt, h) return dom.Focus().WithNodeID(nodes[0].NodeID).Do(ctxt, h)
}, opts...) }, opts...)
} }
@ -91,7 +91,7 @@ func Dimensions(sel interface{}, model **dom.BoxModel, opts ...QueryOption) Acti
return fmt.Errorf("selector `%s` did not return any nodes", sel) return fmt.Errorf("selector `%s` did not return any nodes", sel)
} }
var err error var err error
*model, err = dom.GetBoxModel(nodes[0].NodeID).Do(ctxt, h) *model, err = dom.GetBoxModel().WithNodeID(nodes[0].NodeID).Do(ctxt, h)
return err return err
}, opts...) }, opts...)
} }
@ -385,7 +385,7 @@ func SendKeys(sel interface{}, v string, opts ...QueryOption) Action {
// when working with input[type="file"], call dom.SetFileInputFiles // when working with input[type="file"], call dom.SetFileInputFiles
if n.NodeName == "INPUT" && typ == "file" { if n.NodeName == "INPUT" && typ == "file" {
return dom.SetFileInputFiles(n.NodeID, []string{v}).Do(ctxt, h) return dom.SetFileInputFiles([]string{v}).WithNodeID(n.NodeID).Do(ctxt, h)
} }
return KeyActionNode(n, v).Do(ctxt, h) return KeyActionNode(n, v).Do(ctxt, h)
@ -400,7 +400,7 @@ func SetUploadFiles(sel interface{}, files []string, opts ...QueryOption) Action
return fmt.Errorf("selector `%s` did not return any nodes", sel) return fmt.Errorf("selector `%s` did not return any nodes", sel)
} }
return dom.SetFileInputFiles(nodes[0].NodeID, files).Do(ctxt, h) return dom.SetFileInputFiles(files).WithNodeID(nodes[0].NodeID).Do(ctxt, h)
}, opts...) }, opts...)
} }
@ -418,7 +418,7 @@ func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) Action {
var err error var err error
// get box model // get box model
box, err := dom.GetBoxModel(nodes[0].NodeID).Do(ctxt, h) box, err := dom.GetBoxModel().WithNodeID(nodes[0].NodeID).Do(ctxt, h)
if err != nil { if err != nil {
return err return err
} }

4
sel.go
View File

@ -293,7 +293,7 @@ func NodeVisible(s *Selector) {
var err error var err error
// check box model // check box model
_, err = dom.GetBoxModel(n.NodeID).Do(ctxt, h) _, err = dom.GetBoxModel().WithNodeID(n.NodeID).Do(ctxt, h)
if err != nil { if err != nil {
if isCouldNotComputeBoxModelError(err) { if isCouldNotComputeBoxModelError(err) {
return ErrNotVisible return ErrNotVisible
@ -321,7 +321,7 @@ func NodeNotVisible(s *Selector) {
var err error var err error
// check box model // check box model
_, err = dom.GetBoxModel(n.NodeID).Do(ctxt, h) _, err = dom.GetBoxModel().WithNodeID(n.NodeID).Do(ctxt, h)
if err != nil { if err != nil {
if isCouldNotComputeBoxModelError(err) { if isCouldNotComputeBoxModelError(err) {
return nil return nil