Udostępnij za pośrednictwem


DOM

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.

Methods enable, disable, getDocument, highlightNode, hideHighlight, requestChildNodes, getAttributes, getOuterHTML, pushNodesByBackendIdsToFrontend, querySelector, querySelectorAll, requestNode, resolveNode, setInspectedNode
Events setChildNodes, attributeModified, attributeRemoved, characterDataModified, childNodeInserted, childNodeRemoved, documentUpdated
Types RGBA, HighlightConfig, NodeId, Node, BackendNodeId, PseudoType
Dependencies Runtime

Methods

enable

Enables DOM agent for the given page.


disable

Disables DOM agent for the given page. Disabling the DOM will invalidate any previously valid nodeIds.


getDocument

Returns the root DOM node (and optionally the subtree) to the caller. Calling getDocument will invalidate any previously valid nodeIds

Parameters
depth integer The maximum depth at which children should be retrieved, defaults to 2. Use -1 for entire subtree.
pierce boolean Whether or not iframes should be traversed when returning the subtree (default is false).
Returns
root Node Resulting Node.


highlightNode

Higlights DOM node with given id or object wrapper. nodeId, backendNodeId, or objectId must be specified.

Parameters
nodeId
optional
NodeId Identifier of the node to highlight.
backendNodeId
optional
BackendNodeId Identifier of the backend node to highlight.
objectId
optional
Runtime.RemoteObjectId JavaScript object id of the node to be highlighted.
higlightConfig HighlightConfig Descriptor of the highlight appearance.
Returns
root Node Resulting Node.


hideHighlight

Hides any current DOM node highlight.


requestChildNodes

Requests that children of the node with given id are returned to ghe caller in the form of setChildNodes events. setChildNodes will be fired for each node that has not previously returned it's children, starting from the requested node down to the specified depth.

Parameters
nodeId NodeId Id of the node to get children from.
depth integer The maximum depth at which children should be retrieved, defaults to 1. Use -1 for entire subtree.
pierce boolean Whether or not iframes should be traversed when returning the subtree (default is false).


getAttributes

Returns attributes for the specified node.

Parameters
nodeId NodeId Id of the node to retrieve attibutes for.
Returns
attributes string[] An interleaved array of node attribute names and values.


getOuterHTML

Returns node's HTML markup.

Parameters
nodeId
optional
NodeId Identifier of the node.
backendNodeId
optional
BackendNodeId Identifier of the backend node.
objectId
optional
Runtime.RemoteObjectId JavaScript object id of the node wrapper.
Returns
outerHTML string Outer HTML markup.


pushNodesByBackendIdsToFrontend

Looks up Node Ids and resolves all parents for the specified Backend Node Ids

Parameters
backendNodeIds BackendNodeId[] Backend Node IDs of the nodes to resolve
Returns
nodeIds Node[] Node Ids of the resolved nodes


querySelector

Executes querySelector on a given node.

Parameters
nodeId NodeId Id of the node to query upon.
selector string The selector string.
Returns
nodeId NodeId Query selector result.


querySelectorAll

Executes querySelectorAll on a given node.

Parameters
nodeId NodeId Id of the node to query upon.
selector string The selector string.
Returns
nodeIds NodeId[] Query selector results.


requestNode

Requests that the node with given remote object Id is sent to caller. All nodes that form the path from the node to the root are also sent to the client as a series of setChildNodes notifications. returns 0 if the document containing the requested node has not previously been requested by the client.

Parameters
objectId Runtime.RemoteObjectId JavaScript object Id to convert into node.
Returns
nodeId NodeId Node Id for given object.


resolveNode

Resolves the JavaScript node object for a given NodeId or BackendNodeId.

Parameters
nodeId
optional
NodeId Id of the node to resolve.
backendNodeId
optional
BackendNodeId Backend Node Id of the node to resolve.
objectGroup string Symbolic group name that can be used to release multiple objects.
Returns
object Runtime.RemoteObject JavaScript object wrapper for given node.


setInspectedNode

Experimental. Enables console to refer to the previous inspected node with given id via $0-$4.

Parameters
nodeId NodeId DOM node id to be accessible by means of $0-$4 in command line API.


Events

setChildNodes

Fired when the backend wishes to provide client with missing DOM structure. This happens upon most calls requesting nodeIds

Parameters
parentId NodeId Parent node to poplate with children.
nodes NodeId[] Child nodes array.


attributeModified

Fired when Element's attribute is modified.

Parameters
nodeId NodeId Id of the node that has changed.
name string Attribute name.
value string Attribute value.


attributeRemoved

Fired when Element's attribute is removed.

Parameters
nodeId NodeId Id of the node that has changed.
name string Attribute name.


characterDataModified

Mirrors DOMCharacterDataModified event.

Parameters
nodeId NodeId Id of the node that has changed.
charcterData string New text value.


childNodeInserted

Mirrors DOMNodeInserted event.

Parameters
parentNodeId NodeId Id of the node that has changed.
previousNodeId NodeId Id of the inserted node's previous sibling.
node Node Inserted node data.


childNodeRemoved

Mirrors DOMNodeRemoved event.

Parameters
parentNodeId NodeId Id of the node that has changed.
nodeId NodeId Id of the node that has been removed.


documentUpdated

Fired when Document has been totally updated. Node ids are no longer valid.


Types

RGBA object

A Structure holding an RGBA color.

Properties
r integer The red component, in the [0-255] range.
g integer The green component, in the [0-255] range.
b integer The blue component, in the [0-255] range.
a
optional
number The alpha component, in the [0-1] range. Default is 1.


HighlightConfig object

Configuration data for highlighting of page elements.

Properties
contentColor
optional
RGBA The content box highlight fill color. Default is transparent.
paddingColor
optional
RGBA The padding highlight fill color. Default is transparent.
borderColor
optional
RGBA The border highlight fill color. Default is transparent.
marginColor
optional
RGBA The margin highlight fill color. Default is transparent.


NodeId integer

Unique DOM node identifier


Node object

Mirror object that represents the actual DOM nodes.

Properties
nodeId NodeId Node Identifier used to reference this node. Backend will fire DOM events for nodes that have a nodeId that is known to the client
parentId
optional
NodeId Node Identifier of the parent Node, if any.
backendNodeId NodeId Backend Node identifier of the node. BackendNodeIds reference Nodes that can be known to the client, but do not push DOM events about this node.
nodeType integer `Node`'s nodeType.
nodeName string `Node`'s nodeName.
localName string `Node`'s localName
nodeValue string `Node`'s nodeValue
childNodeCount
optional
integer Child count for `Container` nodes.
children
optional
Node[] Child nodes of this node when requested with children.
attributes
optional
string[] Attributes of `Element` nodes in the form of a flat array `[name1, value1, name2, value2]
documentURL
optional
string Document URL that `Document` nodes point to.
baseURL
optional
string Document URL that `Document` nodes use for URL completion.
publicId
optional
string `DocumentType` Node's publicId.
systemId
optional
string `DocumentType` Node's systemId.
internalSubset
optional
string `DocumentType` Node's internalSubset.
xmlVersion
optional
string `Document` Node's xml version in the case of XML documents.
name
optional
string `Attr` Node's name.
value
optional
string `Attr` Node's value.
frameId
optional
Page.FrameId Frame ID for frame owner elements.
contentDocument
optional
Node Content document for frame owner elements.
isSVG
optional
boolean True if the node is SVG.


BackendNodeId integer

Unique DOM node identifier used to reference a node that may not have been pushed to the front-end.


PseudoType string

Pseudo element type.

Allowed Values

first-line, first-letter, before, after, selection


Dependencies

Runtime