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
- DOM.describeNode
- DOM.disable
- DOM.enable
- DOM.focus
- DOM.getAttributes
- DOM.getBoxModel
- DOM.getDocument
- DOM.getNodeForLocation
- DOM.getOuterHTML
- DOM.hideHighlight
- DOM.highlightNode
- DOM.highlightRect
- DOM.moveTo
- DOM.querySelector
- DOM.querySelectorAll
- DOM.removeAttribute
- DOM.removeNode
- DOM.requestChildNodes
- DOM.requestNode
- DOM.resolveNode
- DOM.scrollIntoViewIfNeeded
- DOM.setAttributesAsText
- DOM.setAttributeValue
- DOM.setFileInputFiles
- DOM.setNodeName
- DOM.setNodeValue
- DOM.setOuterHTML
Events
- DOM.attributeModified
- DOM.attributeRemoved
- DOM.characterDataModified
- DOM.childNodeCountUpdated
- DOM.childNodeInserted
- DOM.childNodeRemoved
- DOM.documentUpdated
- DOM.setChildNodes
Types
Methods
DOM.describeNode #
Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation.
Parameters
nodeId
Optional
Identifier of the node.
backendNodeId
Optional
Identifier of the backend node.
objectId
Optional
JavaScript object id of the node wrapper.
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.
pierce
Optional
boolean
Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
Return object
node
Node description.
DOM.enable #
Enables DOM agent for the given page.
Parameters
includeWhitespace
Optional
string
Whether to include whitespaces in the children array of returned Nodes.
Allowed values: none
, all
DOM.focus #
Focuses the given element.
Parameters
nodeId
Optional
Identifier of the node.
backendNodeId
Optional
Identifier of the backend node.
objectId
Optional
JavaScript object id of the node wrapper.
DOM.getAttributes #
Returns attributes for the specified node.
Parameters
nodeId
Id of the node to retrieve attributes for.
Return object
attributes
array[ string
]
An interleaved array of node attribute names and values.
DOM.getBoxModel #
Returns boxes for the given node.
Parameters
nodeId
Optional
Identifier of the node.
backendNodeId
Optional
Identifier of the backend node.
objectId
Optional
JavaScript object id of the node wrapper.
Return object
model
Box model for the node.
DOM.getDocument #
Returns the root DOM node (and optionally the subtree) to the caller. Implicitly enables the DOM domain events for the current target.
Parameters
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.
pierce
Optional
boolean
Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
Return object
root
Resulting node.
DOM.getNodeForLocation #
Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.
Parameters
x
integer
X coordinate.
y
integer
Y coordinate.
includeUserAgentShadowDOM
Optional
boolean
False to skip to the nearest non-UA shadow root ancestor (default: false).
ignorePointerEventsNone
Optional
boolean
Whether to ignore pointer-events: none on elements and hit test them.
Return object
backendNodeId
Resulting node.
frameId
Frame this node belongs to.
nodeId
Optional
Id of the node at given coordinates, only when enabled and requested document.
DOM.getOuterHTML #
Returns node's HTML markup.
Parameters
nodeId
Optional
Identifier of the node.
backendNodeId
Optional
Identifier of the backend node.
objectId
Optional
JavaScript object id of the node wrapper.
Return object
outerHTML
string
Outer HTML markup.
DOM.moveTo #
Moves node into the new container, places it before the given anchor.
Parameters
nodeId
Id of the node to move.
targetNodeId
Id of the element to drop the moved node into.
insertBeforeNodeId
Optional
Drop node before this one (if absent, the moved node becomes the last child of
targetNodeId
).
Return object
nodeId
New id of the moved node.
DOM.querySelector #
Executes querySelector
on a given node.
Parameters
nodeId
Id of the node to query upon.
selector
string
Selector string.
Return object
nodeId
Query selector result.
DOM.querySelectorAll #
Executes querySelectorAll
on a given node.
Parameters
nodeId
Id of the node to query upon.
selector
string
Selector string.
Return object
nodeIds
array[ NodeId ]
Query selector result.
DOM.removeAttribute #
Removes attribute with given name from an element with given id.
Parameters
nodeId
Id of the element to remove attribute from.
name
string
Name of the attribute to remove.
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
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.
pierce
Optional
boolean
Whether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false).
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
JavaScript object id to convert into node.
Return object
nodeId
Node id for given object.
DOM.resolveNode #
Resolves the JavaScript node object for a given NodeId or BackendNodeId.
Parameters
nodeId
Optional
Id of the node to resolve.
backendNodeId
Optional
Backend identifier of the node to resolve.
objectGroup
Optional
string
Symbolic group name that can be used to release multiple objects.
executionContextId
Optional
Execution context in which to resolve the node.
Return object
object
JavaScript object wrapper for given node.
DOM.scrollIntoViewIfNeeded #
Scrolls the specified rect of the given node into view if not already visible. Note: exactly one between nodeId, backendNodeId and objectId should be passed to identify the node.
Parameters
nodeId
Optional
Identifier of the node.
backendNodeId
Optional
Identifier of the backend node.
objectId
Optional
JavaScript object id of the node wrapper.
rect
Optional
The rect to be scrolled into view, relative to the node's border box, in CSS pixels. When omitted, center of the node will be used, similar to Element.scrollIntoView.
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
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.
DOM.setAttributeValue #
Sets attribute for an element with given id.
Parameters
nodeId
Id of the element to set attribute for.
name
string
Attribute name.
value
string
Attribute value.
DOM.setFileInputFiles #
Sets files for the given file input element.
Parameters
files
array[ string
]
Array of file paths to set.
nodeId
Optional
Identifier of the node.
backendNodeId
Optional
Identifier of the backend node.
objectId
Optional
JavaScript object id of the node wrapper.
DOM.setNodeName #
Sets node name for a node with given id.
Parameters
nodeId
Id of the node to set name for.
name
string
New node's name.
Return object
nodeId
New node's id.
Events
DOM.attributeModified #
Fired when Element
's attribute is modified.
Parameters
nodeId
Id of the node that has changed.
name
string
Attribute name.
value
string
Attribute value.
DOM.attributeRemoved #
Fired when Element
's attribute is removed.
Parameters
nodeId
Id of the node that has changed.
name
string
A ttribute name.
DOM.characterDataModified #
Mirrors DOMCharacterDataModified
event.
Parameters
nodeId
Id of the node that has changed.
characterData
string
New text value.
DOM.childNodeCountUpdated #
Fired when Container
's child node count has changed.
Parameters
nodeId
Id of the node that has changed.
childNodeCount
integer
New node count.
DOM.childNodeInserted #
Mirrors DOMNodeInserted
event.
Parameters
parentNodeId
Id of the node that has changed.
previousNodeId
Id of the previous sibling.
node
Inserted node data.
Types
DOM.BackendNode #
Backend node with a friendly name.
Type: object
Properties
nodeType
integer
Node
's nodeType.
nodeName
string
Node
's nodeName.
backendNodeId
DOM.BackendNodeId #
Unique DOM node identifier used to reference a node that may not have been pushed to the front-end.
Type: integer
DOM.BoxModel #
Box model.
Type: object
Properties
content
Content box
padding
Padding box
border
Border box
margin
Margin box
width
integer
Node width
height
integer
Node height
shapeOutside
Optional
Shape outside coordinates
DOM.CompatibilityMode #
Document compatibility mode.
Type: string
Allowed values: QuirksMode
, LimitedQuirksMode
, NoQuirksMode
DOM.CSSComputedStyleProperty #
Type: object
Properties
name
string
Computed style property name.
value
string
Computed style property value.
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
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.
parentId
Optional
The id of the parent node if any.
backendNodeId
The BackendNodeId for 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
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.
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
Pseudo element type for this node.
pseudoIdentifier
Optional
string
Pseudo element identifier for this node. Only present if there is a valid pseudoType.
shadowRootType
Optional
Shadow root type.
frameId
Optional
Frame ID for frame owner elements.
contentDocument
Optional
Content document for frame owner elements.
shadowRoots
Optional
array[ Node ]
Shadow root list for given element host.
templateContent
Optional
Content document fragment for template elements.
pseudoElements
Optional
array[ Node ]
Pseudo elements associated with this node.
importedDocument
Optional
Deprecated, as the HTML Imports API has been removed (crbug.com/937746). This property used to return the imported document for the HTMLImport links. The property is always undefined now.
distributedNodes
Optional
array[ BackendNode ]
Distributed nodes for given insertion point.
isSVG
Optional
boolean
Whether the node is SVG.
compatibilityMode
Optional
assignedSlot
Optional
DOM.PhysicalAxes #
ContainerSelector physical axes
Type: string
Allowed values: Horizontal
, Vertical
, Both
DOM.PseudoType #
Pseudo element type.
Type: string
Allowed values: first-line
, first-letter
, before
, after
, marker
, backdrop
, selection
, search-text
, target-text
, spelling-error
, grammar-error
, highlight
, first-line-inherited
, scroll-marker
, scroll-marker-group
, scrollbar
, scrollbar-thumb
, scrollbar-button
, scrollbar-track
, scrollbar-track-piece
, scrollbar-corner
, resizer
, input-list-button
, view-transition
, view-transition-group
, view-transition-image-pair
, view-transition-old
, view-transition-new
DOM.Quad #
An array of quad vertices, x immediately followed by y for each point, points clock-wise.
Type: array[
number
]
DOM.Rect #
Rectangle.
Type: object
Properties
x
number
X coordinate
y
number
Y coordinate
width
number
Rectangle width
height
number
Rectangle height
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).