Domains Accessibility Animation ApplicationCache CSS CacheStorage Console DOM DOMDebugger DOMStorage Database Debugger DeviceOrientation Emulation FileSystem HeapProfiler IndexedDB Input Inspector LayerTree Memory Network Page Power Profiler Rendering Runtime ScreenOrientation Security ServiceWorker Timeline Tracing Worker
Chrome Debugger Protocol Viewer

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

enable

Enables DOM agent for the given page.

disable

Disables DOM agent for the given page.

getDocument

Returns the root DOM node to the caller.

Return object
root
Node Resulting node.

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

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.

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.

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.

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.

removeNode

Removes node with given id.

Parameters
nodeId
NodeId Id of the node to remove.

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.

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
string Attribute name to replace with new attributes derived from text in case text parsed successfully.

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.

getOuterHTML

Returns node's HTML markup.

Parameters
nodeId
NodeId Id of the node to get markup for.
Return object
outerHTML
string Outer HTML markup.

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.

performSearch

Searches for a given string in the DOM tree. Use getSearchResults to access search results or cancelSearch to end this search session.

Parameters
query
string Plain text or query selector or XPath search query.
includeUserAgentShadowDOM
boolean True to search in user agent shadow DOM.
Return object
searchId
string Unique search session identifier.
resultCount
integer Number of search results.

getSearchResults

Returns search results from given fromIndex to given toIndex from the sarch with the given identifier.

Parameters
searchId
string Unique search session identifier.
fromIndex
integer Start index of the search result to be returned.
toIndex
integer End index of the search result to be returned.
Return object
nodeIds
array [ NodeId ] Ids of the search result nodes.

discardSearchResults

Discards search results from the session with the given id. getSearchResults should no longer be called for that search.

Parameters
searchId
string Unique search session identifier.

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.

setInspectMode

Enters the 'inspect' mode. In this mode, elements that user is hovering over are highlighted. Backend then generates 'inspectNodeRequested' event upon element selection.

Parameters
mode
InspectMode Set an inspection mode.
highlightConfig
HighlightConfig A descriptor for the highlight appearance of hovered-over nodes. May be omitted if enabled == false.

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
RGBA The highlight fill color (default: transparent).
outlineColor
RGBA The highlight outline color (default: transparent).

highlightQuad

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

Parameters
quad
Quad Quad to highlight
color
RGBA The highlight fill color (default: transparent).
outlineColor
RGBA The highlight outline color (default: transparent).

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
NodeId Identifier of the node to highlight.
backendNodeId
BackendNodeId Identifier of the backend node to highlight.
objectId
Runtime.RemoteObjectId JavaScript object id of the node to be highlighted.

hideHighlight

Hides DOM node highlight.

highlightFrame

Highlights owner element of the frame with given id.

Parameters
frameId
Page.FrameId Identifier of the frame to highlight.
contentColor
RGBA The content box highlight fill color (default: transparent).
contentOutlineColor
RGBA The content box highlight outline color (default: transparent).

pushNodeByPathToFrontend

Requests that the node is sent to the caller given its path. // FIXME, use XPath

Parameters
path
string Path to node in the proprietary format.
Return object
nodeId
NodeId Id of the node for given path.

pushNodesByBackendIdsToFrontend

Requests that a batch of nodes is sent to the caller given their backend node ids.

Parameters
backendNodeIds
array [ BackendNodeId ] The array of backend node ids.
Return object
nodeIds
array [ NodeId ] The array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds.

setInspectedNode

Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).

Parameters
nodeId
NodeId DOM node id to be accessible by means of $x command line API.

resolveNode

Resolves JavaScript node object for given node id.

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

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.

copyTo

Creates a deep copy of the specified node and places it into the target container before the given anchor.

Parameters
nodeId
NodeId Id of the node to copy.
targetNodeId
NodeId Id of the element to drop the copy into.
insertBeforeNodeId
NodeId Drop the copy before this node (if absent, the copy becomes the last child of targetNodeId).
Return object
nodeId
NodeId Id of the node clone.

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

undo

Undoes the last performed action.

redo

Re-does the last undone action.

markUndoableState

Marks last undoable state.

focus

Focuses the given element.

Parameters
nodeId
NodeId Id of the node to focus.

setFileInputFiles

Sets files for the given file input element.

Parameters
nodeId
NodeId Id of the file input node to set files for.
files
array [string] Array of file paths to set.

getBoxModel

Returns boxes for the currently selected nodes.

Parameters
nodeId
NodeId Id of the node to get box model for.
Return object
model
BoxModel Box model for the node.

getNodeForLocation

Returns node id at given location.

Parameters
x
integer X coordinate.
y
integer Y coordinate.
Return object
nodeId
NodeId Id of the node at given coordinates.

getRelayoutBoundary

Returns the id of the nearest ancestor that is a relayout boundary.

Parameters
nodeId
NodeId Id of the node.
Return object
nodeId
NodeId Relayout boundary node id for the given node.

getHighlightObjectForTest

For testing.

Parameters
nodeId
NodeId Id of the node to get highlight object for.
Return object
highlight
object Highlight data for the node.

Events

documentUpdated

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

inspectNodeRequested

Fired when the node should be inspected. This happens after call to setInspectMode.

Parameters
backendNodeId
BackendNodeId Id of the node to inspect.

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.

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 A ttribute name.

inlineStyleInvalidated

Fired when Element's inline style is modified via a CSS property modification.

Parameters
nodeIds
array [ NodeId ] Ids of the nodes for which the inline styles have been invalidated.

characterDataModified

Mirrors DOMCharacterDataModified event.

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

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.

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.

childNodeRemoved

Mirrors DOMNodeRemoved event.

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

shadowRootPushed

Called when shadow root is pushed into the element.

Parameters
hostId
NodeId Host element id.
root
Node Shadow root.

shadowRootPopped

Called when shadow root is popped from the element.

Parameters
hostId
NodeId Host element id.
rootId
NodeId Shadow root id.

pseudoElementAdded

Called when a pseudo element is added to an element.

Parameters
parentId
NodeId Pseudo element's parent element id.
pseudoElement
Node The added pseudo element.

pseudoElementRemoved

Called when a pseudo element is removed from an element.

Parameters
parentId
NodeId Pseudo element's parent element id.
pseudoElementId
NodeId The removed pseudo element id.

distributedNodesUpdated

Called when distrubution is changed.

Parameters
insertionPointId
NodeId Insertion point where distrubuted nodes were updated.
distributedNodes
array [ BackendNode ] Distributed nodes for given insertion point.

Types

NodeId

Unique DOM node identifier.

Type: integer

BackendNodeId

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

Type: integer

BackendNode

Backend node with a friendly name.

Type: object

Properties
nodeType
integer Node's nodeType.
nodeName
string Node's nodeName.
backendNodeId
BackendNodeId

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.

ShadowRootType

Shadow root type.

Type: string

Allowed values

user-agent, open, closed.

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
integer Child count for Container nodes.
children
array [ Node ] Child nodes of this node when requested with children.
attributes
array [string] Attributes of the Element node in the form of flat array [name1, value1, name2, value2].
documentURL
string Document URL that Document or FrameOwner node points to.
baseURL
string Base URL that Document or FrameOwner node uses for URL completion.
publicId
string DocumentType's publicId.
systemId
string DocumentType's systemId.
internalSubset
string DocumentType's internalSubset.
xmlVersion
string Document's XML version in case of XML documents.
name
string Attr's name.
value
string Attr's value.
pseudoType
PseudoType Pseudo element type for this node.
shadowRootType
ShadowRootType Shadow root type.
frameId
Page.FrameId Frame ID for frame owner elements.
contentDocument
Node Content document for frame owner elements.
shadowRoots
array [ Node ] Shadow root list for given element host.
templateContent
Node Content document fragment for template elements.
pseudoElements
array [ Node ] Pseudo elements associated with this node.
importedDocument
Node Import document for the HTMLImport links.
distributedNodes
array [ BackendNode ] Distributed nodes for given insertion point.

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
number The alpha component, in the [0-1] range (default: 1).

Quad

An array of quad vertices, x immediately followed by y for each point, points clock-wise.

Type: array

BoxModel

Box model.

Type: object

Properties
content
Quad Content box
padding
Quad Padding box
border
Quad Border box
margin
Quad Margin box
width
integer Node width
height
integer Node height
shapeOutside
ShapeOutsideInfo Shape outside coordinates

ShapeOutsideInfo

CSS Shape Outside details.

Type: object

Properties
bounds
Quad Shape bounds
shape
array [any] Shape coordinate details
marginShape
array [any] Margin shape bounds

Rect

Rectangle.

Type: object

Properties
x
number X coordinate
y
number Y coordinate
width
number Rectangle width
height
number Rectangle height

HighlightConfig

Configuration data for the highlighting of page elements.

Type: object

Properties
showInfo
boolean Whether the node info tooltip should be shown (default: false).
showRulers
boolean Whether the rulers should be shown (default: false).
showExtensionLines
boolean Whether the extension lines from node to the rulers should be shown (default: false).
displayAsMaterial
boolean
contentColor
RGBA The content box highlight fill color (default: transparent).
paddingColor
RGBA The padding highlight fill color (default: transparent).
borderColor
RGBA The border highlight fill color (default: transparent).
marginColor
RGBA The margin highlight fill color (default: transparent).
eventTargetColor
RGBA The event target element highlight fill color (default: transparent).
shapeColor
RGBA The shape outside fill color (default: transparent).
shapeMarginColor
RGBA The shape margin fill color (default: transparent).

InspectMode

Type: string

Allowed values

searchForNode, searchForUAShadowDOM, showLayoutEditor, none.