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.
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.
//
// parameters:
// nodeID - Id of the node to focus.
func Focus(nodeID cdp.NodeID) *FocusParams {
return &FocusParams{
NodeID: nodeID,
}
func Focus() *FocusParams {
return &FocusParams{}
}
// 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
@ -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.
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.
//
// parameters:
// nodeID - Id of the file input node to set files for.
// files - Array of file paths to set.
func SetFileInputFiles(nodeID cdp.NodeID, files []string) *SetFileInputFilesParams {
func SetFileInputFiles(files []string) *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
// target handler.
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.
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.
//
// parameters:
// nodeID - Id of the node to get box model for.
func GetBoxModel(nodeID cdp.NodeID) *GetBoxModelParams {
return &GetBoxModelParams{
NodeID: nodeID,
}
func GetBoxModel() *GetBoxModelParams {
return &GetBoxModelParams{}
}
// 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.

View File

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

View File

@ -600,6 +600,14 @@ func easyjsonC5a4559bDecodeGithubComKnqChromedpCdpDomsnapshot4(in *jlexer.Lexer,
out.NodeName = string(in.String())
case "nodeValue":
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":
(out.BackendNodeID).UnmarshalEasyJSON(in)
case "childNodeIndexes":
@ -735,6 +743,38 @@ func easyjsonC5a4559bEncodeGithubComKnqChromedpCdpDomsnapshot4(out *jwriter.Writ
first = false
out.RawString("\"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 {
out.RawByte(',')
}

View File

@ -13,6 +13,10 @@ type DOMNode struct {
NodeType cdp.NodeType `json:"nodeType"` // Node's nodeType.
NodeName string `json:"nodeName"` // Node's nodeName.
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.
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.

View File

@ -6016,7 +6016,20 @@
{
"name": "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.",
@ -6025,11 +6038,6 @@
{
"name": "setFileInputFiles",
"parameters": [
{
"name": "nodeId",
"$ref": "NodeId",
"description": "Id of the file input node to set files for."
},
{
"name": "files",
"type": "array",
@ -6037,6 +6045,24 @@
"type": "string"
},
"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.",
@ -6048,7 +6074,20 @@
{
"name": "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": [
@ -7517,6 +7556,30 @@
"type": "string",
"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",
"$ref": "DOM.BackendNodeId",

View File

@ -65,7 +65,7 @@ func MouseClickNode(n *cdp.Node, opts ...MouseOption) Action {
return err
}
box, err := dom.GetBoxModel(n.NodeID).Do(ctxt, h)
box, err := dom.GetBoxModel().WithNodeID(n.NodeID).Do(ctxt, h)
if err != nil {
return err
}
@ -174,7 +174,7 @@ func KeyAction(keys string, opts ...KeyOption) Action {
// KeyActionNode dispatches a key event on a node.
func KeyActionNode(n *cdp.Node, keys string, opts ...KeyOption) Action {
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 {
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 dom.Focus(nodes[0].NodeID).Do(ctxt, h)
return dom.Focus().WithNodeID(nodes[0].NodeID).Do(ctxt, h)
}, 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)
}
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
}, opts...)
}
@ -385,7 +385,7 @@ func SendKeys(sel interface{}, v string, opts ...QueryOption) Action {
// when working with input[type="file"], call dom.SetFileInputFiles
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)
@ -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 dom.SetFileInputFiles(nodes[0].NodeID, files).Do(ctxt, h)
return dom.SetFileInputFiles(files).WithNodeID(nodes[0].NodeID).Do(ctxt, h)
}, opts...)
}
@ -418,7 +418,7 @@ func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) Action {
var err error
// 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 {
return err
}

4
sel.go
View File

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