1.1: DOM
Contents
This domain exposes DOM read/write operations. Each DOM Node is represented with its mirror object that has an id
. This id
can be used to get additional information on the Node, resolve it into the JavaScript object wrapper, etc. It is important that client receives DOM events only for the nodes that are known to the client. Backend keeps track of the nodes that were sent to the client and never sends the same node twice. It is client's responsibility to collect information about the nodes that were sent to the client.
Note that iframe
owner elements will return corresponding document elements as their child nodes.
Commands
DOM.getAttributes
"id": <number>,
"method": "DOM.getAttributes",
"params": {
"nodeId": <NodeId>
}
"id": <number>,
"error": <object>,
"result": {
"attributes": <array of string>
}
Returns attributes for the specified node.
Parameters
Returns
DOM.getDocument
"id": <number>,
"method": "DOM.getDocument"
"id": <number>,
"error": <object>,
"result": {
"root": <Node>
}
DOM.getOuterHTML
"id": <number>,
"method": "DOM.getOuterHTML",
"params": {
"nodeId": <NodeId>
}
"id": <number>,
"error": <object>,
"result": {
"outerHTML": <string>
}
Returns node's HTML markup.
Parameters
Returns
DOM.hideHighlight
"id": <number>,
"method": "DOM.hideHighlight"
"id": <number>,
"error": <object>
Hides DOM node highlight.
DOM.highlightNode
"id": <number>,
"method": "DOM.highlightNode",
"params": {
"highlightConfig": <HighlightConfig>,
"nodeId": <NodeId>
}
"id": <number>,
"error": <object>
Highlights DOM node with given id or with the given JavaScript object wrapper. Either nodeId or objectId must be specified.
Parameters
DOM.highlightRect
"id": <number>,
"method": "DOM.highlightRect",
"params": {
"x": <integer>,
"y": <integer>,
"width": <integer>,
"height": <integer>,
"color": <RGBA>,
"outlineColor": <RGBA>
}
"id": <number>,
"error": <object>
Highlights given rectangle. Coordinates are absolute with respect to the main frame viewport.
Parameters
DOM.moveTo
DOM.querySelector
DOM.querySelectorAll
DOM.removeAttribute
"id": <number>,
"method": "DOM.removeAttribute",
"params": {
"nodeId": <NodeId>,
"name": <string>
}
"id": <number>,
"error": <object>
Removes attribute with given name from an element with given id.
Parameters
DOM.removeNode
"id": <number>,
"method": "DOM.removeNode",
"params": {
"nodeId": <NodeId>
}
"id": <number>,
"error": <object>
DOM.requestChildNodes
"id": <number>,
"method": "DOM.requestChildNodes",
"params": {
"nodeId": <NodeId>
}
"id": <number>,
"error": <object>
Requests that children of the node with given id are returned to the caller in form of setChildNodes
events where not only immediate children are retrieved, but all children down to the specified depth.
Parameters
DOM.requestNode
"id": <number>,
"method": "DOM.requestNode",
"params": {
"objectId": <Runtime.RemoteObjectId>
}
"id": <number>,
"error": <object>,
"result": {
"nodeId": <NodeId>
}
Requests that the node is sent to the caller given the JavaScript node object reference. All nodes that form the path from the node to the root are also sent to the client as a series of setChildNodes
notifications.
Parameters
Returns
DOM.resolveNode
"id": <number>,
"method": "DOM.resolveNode",
"params": {
"nodeId": <NodeId>,
"objectGroup": <string>
}
"id": <number>,
"error": <object>,
"result": {
"object": <Runtime.RemoteObject>
}
Resolves JavaScript node object for given node id.
Parameters
Returns
DOM.setAttributeValue
"id": <number>,
"method": "DOM.setAttributeValue",
"params": {
"nodeId": <NodeId>,
"name": <string>,
"value": <string>
}
"id": <number>,
"error": <object>
Sets attribute for an element with given id.
Parameters
DOM.setAttributesAsText
"id": <number>,
"method": "DOM.setAttributesAsText",
"params": {
"nodeId": <NodeId>,
"text": <string>,
"name": <string>
}
"id": <number>,
"error": <object>
Sets attributes on element with given id. This method is useful when user edits some existing attribute value and types in several attribute name/value pairs.
Parameters
DOM.setNodeName
DOM.setNodeValue
"id": <number>,
"method": "DOM.setNodeValue",
"params": {
"nodeId": <NodeId>,
"value": <string>
}
"id": <number>,
"error": <object>
Sets node value for a node with given id.
Parameters
DOM.setOuterHTML
"id": <number>,
"method": "DOM.setOuterHTML",
"params": {
"nodeId": <NodeId>,
"outerHTML": <string>
}
"id": <number>,
"error": <object>
Sets node HTML markup, returns new node id.
Parameters
Notifications
DOM.attributeModified
"method": "DOM.attributeModified",
"params": {
"nodeId": <NodeId>,
"name": <string>,
"value": <string>
}
Fired when Element
's attribute is modified.
Parameters
DOM.attributeRemoved
Fired when Element
's attribute is removed.
Parameters
DOM.characterDataModified
"method": "DOM.characterDataModified",
"params": {
"nodeId": <NodeId>,
"characterData": <string>
}
Mirrors DOMCharacterDataModified
event.
Parameters
DOM.childNodeCountUpdated
"method": "DOM.childNodeCountUpdated",
"params": {
"nodeId": <NodeId>,
"childNodeCount": <integer>
}
Fired when Container
's child node count has changed.
Parameters
DOM.childNodeInserted
DOM.documentUpdated
"method": "DOM.documentUpdated"
Fired when Document
has been totally updated. Node ids are no longer valid.
Types
HighlightConfig: object
Node: object
Element
node in the form of flat array [name1, value1, name2, value2]
.
Container
nodes.
Document
or FrameOwner
node points to.
DocumentType
's internalSubset.
Node
's localName.
Attr
's name.
nodeId
. Backend will only push node with given id
once. It is aware of all requested nodes and will only fire DOM events for nodes known to the client.
Node
's nodeName.
Node
's nodeType.
Node
's nodeValue.
DocumentType
's publicId.
DocumentType
's systemId.
Attr
's value.
Document
's XML version in case of XML documents.