Chrome DevTools

DOM Domain

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

Events

Types

Methods

Chrome DevTools

DOM.disable #

Disables DOM agent for the given page.


Chrome DevTools

DOM.enable #

Enables DOM agent for the given page.


Chrome DevTools

DOM.getAttributes #

Returns attributes for the specified node.

Parameters

nodeId
NodeId

Id of the node to retrieve attibutes for.

Return object

attributes
array[ string ]

An interleaved array of node attribute names and values.


Chrome DevTools

DOM.getDocument #

Returns the root DOM node to the caller.

Return object

root
Node

Resulting node.


Chrome DevTools

DOM.getOuterHTML #

Returns node's HTML markup.

Parameters

nodeId
NodeId

Id of the node to get markup for.

Return object

outerHTML
string

Outer HTML markup.


Chrome DevTools

DOM.hideHighlight #

Hides DOM node highlight.


Chrome DevTools

DOM.highlightNode #

Highlights DOM node with given id or with the given JavaScript object wrapper. Either nodeId or objectId must be specified.

Parameters

highlightConfig
HighlightConfig

A descriptor for the highlight appearance.

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.

Experimental

Chrome DevTools

DOM.highlightRect #

Highlights given rectangle. Coordinates are absolute with respect to the main frame viewport.

Parameters

x
integer

X coordinate

y
integer

Y coordinate

width
integer

Rectangle width

height
integer

Rectangle height

color
Optional
RGBA

The highlight fill color (default: transparent).

outlineColor
Optional
RGBA

The highlight outline color (default: transparent).


Chrome DevTools

DOM.moveTo #

Moves node into the new container, places it before the given anchor.

Parameters

nodeId
NodeId

Id of the node to move.

targetNodeId
NodeId

Id of the element to drop the moved node into.

insertBeforeNodeId
Optional
NodeId

Drop node before this one (if absent, the moved node becomes the last child of targetNodeId).

Return object

nodeId
NodeId

New id of the moved node.


Chrome DevTools

DOM.querySelector #

Executes querySelector on a given node.

Parameters

nodeId
NodeId

Id of the node to query upon.

selector
string

Selector string.

Return object

nodeId
NodeId

Query selector result.


Chrome DevTools

DOM.querySelectorAll #

Executes querySelectorAll on a given node.

Parameters

nodeId
NodeId

Id of the node to query upon.

selector
string

Selector string.

Return object

nodeIds
array[ NodeId ]

Query selector result.


Chrome DevTools

DOM.removeAttribute #

Removes attribute with given name from an element with given id.

Parameters

nodeId
NodeId

Id of the element to remove attribute from.

name
string

Name of the attribute to remove.


Chrome DevTools

DOM.removeNode #

Removes node with given id.

Parameters

nodeId
NodeId

Id of the node to remove.


Chrome DevTools

DOM.requestChildNodes #

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

nodeId
NodeId

Id of the node to get children for.

depth
Optional
integer

The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.

Experimental

Chrome DevTools

DOM.requestNode #

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

objectId
Runtime.RemoteObjectId

JavaScript object id to convert into node.

Return object

nodeId
NodeId

Node id for given object.


Chrome DevTools

DOM.resolveNode #

Resolves JavaScript node object for given node id.

Parameters

nodeId
NodeId

Id of the node to resolve.

objectGroup
Optional
string

Symbolic group name that can be used to release multiple objects.

Return object

object
Runtime.RemoteObject

JavaScript object wrapper for given node.


Chrome DevTools

DOM.setAttributesAsText #

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

nodeId
NodeId

Id of the element to set attributes for.

text
string

Text with a number of attributes. Will parse this text using HTML parser.

name
Optional
string

Attribute name to replace with new attributes derived from text in case text parsed successfully.


Chrome DevTools

DOM.setAttributeValue #

Sets attribute for an element with given id.

Parameters

nodeId
NodeId

Id of the element to set attribute for.

name
string

Attribute name.

value
string

Attribute value.


Chrome DevTools

DOM.setNodeName #

Sets node name for a node with given id.

Parameters

nodeId
NodeId

Id of the node to set name for.

name
string

New node's name.

Return object

nodeId
NodeId

New node's id.


Chrome DevTools

DOM.setNodeValue #

Sets node value for a node with given id.

Parameters

nodeId
NodeId

Id of the node to set value for.

value
string

New node's value.


Chrome DevTools

DOM.setOuterHTML #

Sets node HTML markup, returns new node id.

Parameters

nodeId
NodeId

Id of the node to set markup for.

outerHTML
string

Outer HTML markup to set.

Events

Chrome DevTools

DOM.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.


Chrome DevTools

DOM.attributeRemoved #

Fired when Element's attribute is removed.

Parameters

nodeId
NodeId

Id of the node that has changed.

name
string

A ttribute name.


Chrome DevTools

DOM.characterDataModified #

Mirrors DOMCharacterDataModified event.

Parameters

nodeId
NodeId

Id of the node that has changed.

characterData
string

New text value.


Chrome DevTools

DOM.childNodeCountUpdated #

Fired when Container's child node count has changed.

Parameters

nodeId
NodeId

Id of the node that has changed.

childNodeCount
integer

New node count.


Chrome DevTools

DOM.childNodeInserted #

Mirrors DOMNodeInserted event.

Parameters

parentNodeId
NodeId

Id of the node that has changed.

previousNodeId
NodeId

If of the previous siblint.

node
Node

Inserted node data.


Chrome DevTools

DOM.childNodeRemoved #

Mirrors DOMNodeRemoved event.

Parameters

parentNodeId
NodeId

Parent id.

nodeId
NodeId

Id of the node that has been removed.


Chrome DevTools

DOM.documentUpdated #

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


Chrome DevTools

DOM.setChildNodes #

Fired when backend wants to provide client with the missing DOM structure. This happens upon most of the calls requesting node ids.

Parameters

parentId
NodeId

Parent node id to populate with children.

nodes
array[ Node ]

Child nodes array.

Types

Chrome DevTools

DOM.HighlightConfig #

Configuration data for the highlighting of page elements.

Type: object

Properties

showInfo
Optional
boolean

Whether the node info tooltip should be shown (default: false).

showRulers
Optional
boolean

Whether the rulers should be shown (default: false).

showExtensionLines
Optional
boolean

Whether the extension lines from node to the rulers should be shown (default: false).

displayAsMaterial
Optional
booleanExperimental
contentColor
Optional
RGBA

The content box highlight fill color (default: transparent).

paddingColor
Optional
RGBA

The padding highlight fill color (default: transparent).

borderColor
Optional
RGBA

The border highlight fill color (default: transparent).

marginColor
Optional
RGBA

The margin highlight fill color (default: transparent).

eventTargetColor
Optional
RGBA

The event target element highlight fill color (default: transparent).

Experimental
shapeColor
Optional
RGBA

The shape outside fill color (default: transparent).

Experimental
shapeMarginColor
Optional
RGBA

The shape margin fill color (default: transparent).

Experimental
selectorList
Optional
string

Selectors to highlight relevant nodes.


Chrome DevTools

DOM.Node #

DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type.

Type: object

Properties

nodeId
NodeId

Node identifier that is passed into the rest of the DOM messages as the 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.

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
array[ Node ]

Child nodes of this node when requested with children.

attributes
Optional
array[ string ]

Attributes of the Element node in the form of flat array [name1, value1, name2, value2].

documentURL
Optional
string

Document URL that Document or FrameOwner node points to.

baseURL
Optional
string

Base URL that Document or FrameOwner node uses for URL completion.

Experimental
publicId
Optional
string

DocumentType's publicId.

systemId
Optional
string

DocumentType's systemId.

internalSubset
Optional
string

DocumentType's internalSubset.

xmlVersion
Optional
string

Document's XML version in case of XML documents.

name
Optional
string

Attr's name.

value
Optional
string

Attr's value.

pseudoType
Optional
PseudoType

Pseudo element type for this node.

shadowRootType
Optional
ShadowRootType

Shadow root type.

frameId
Optional
Page.FrameId

Frame ID for frame owner elements.

Experimental
contentDocument
Optional
Node

Content document for frame owner elements.

shadowRoots
Optional
array[ Node ]

Shadow root list for given element host.

Experimental
templateContent
Optional
Node

Content document fragment for template elements.

Experimental
pseudoElements
Optional
array[ Node ]

Pseudo elements associated with this node.

Experimental
importedDocument
Optional
Node

Import document for the HTMLImport links.

distributedNodes
Optional
array[ BackendNode ]

Distributed nodes for given insertion point.

Experimental

Chrome DevTools

DOM.NodeId #

Unique DOM node identifier.

Type: integer


Chrome DevTools

DOM.PseudoType #

Pseudo element type.

Type: string

Allowed values: first-line, first-letter, before, after, backdrop, selection, first-line-inherited, scrollbar, scrollbar-thumb, scrollbar-button, scrollbar-track, scrollbar-track-piece, scrollbar-corner, resizer, input-list-button


Chrome DevTools

DOM.RGBA #

A structure holding an RGBA color.

Type: object

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: 1).


Chrome DevTools

DOM.ShadowRootType #

Shadow root type.

Type: string

Allowed values: user-agent, open, closed