DOMSnapshot Domain
This domain facilitates obtaining document snapshots with DOM, layout, and style information.
Methods
- DOMSnapshot.captureSnapshot
- DOMSnapshot.disable
- DOMSnapshot.enable
- DOMSnapshot.getSnapshot Deprecated
Types
- DOMSnapshot.ArrayOfStrings
- DOMSnapshot.ComputedStyle
- DOMSnapshot.DocumentSnapshot
- DOMSnapshot.DOMNode
- DOMSnapshot.InlineTextBox
- DOMSnapshot.LayoutTreeNode
- DOMSnapshot.LayoutTreeSnapshot
- DOMSnapshot.NameValue
- DOMSnapshot.NodeTreeSnapshot
- DOMSnapshot.RareBooleanData
- DOMSnapshot.RareIntegerData
- DOMSnapshot.RareStringData
- DOMSnapshot.Rectangle
- DOMSnapshot.StringIndex
- DOMSnapshot.TextBoxSnapshot
Methods
DOMSnapshot.captureSnapshot #
Returns a document snapshot, including the full DOM tree of the root node (including iframes, template contents, and imported documents) in a flattened array, as well as layout and white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is flattened.
Parameters
computedStyles
array[ string
]
Whitelist of computed styles to return.
includePaintOrder
Optional
boolean
Whether to include layout object paint orders into the snapshot.
includeDOMRects
Optional
boolean
Whether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
includeBlendedBackgroundColors
Optional
boolean
Whether to include blended background colors in the snapshot (default: false). Blended background color is achieved by blending background colors of all elements that overlap with the current element.
includeTextColorOpacities
Optional
boolean
Whether to include text color opacity in the snapshot (default: false). An element might have the opacity property set that affects the text color of the element. The final text color opacity is computed based on the opacity of all overlapping elements.
Return object
documents
array[ DocumentSnapshot ]
The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
strings
array[ string
]
Shared string table that all string properties refer to with indexes.
DOMSnapshot.getSnapshot Deprecated#
Returns a document snapshot, including the full DOM tree of the root node (including iframes, template contents, and imported documents) in a flattened array, as well as layout and white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is flattened.
Parameters
computedStyleWhitelist
array[ string
]
Whitelist of computed styles to return.
includeEventListeners
Optional
boolean
Whether or not to retrieve details of DOM listeners (default false).
includePaintOrder
Optional
boolean
Whether to determine and include the paint order index of LayoutTreeNodes (default false).
includeUserAgentShadowTree
Optional
boolean
Whether to include UA shadow tree in the snapshot (default false).
Return object
domNodes
array[ DOMNode ]
The nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
layoutTreeNodes
array[ LayoutTreeNode ]
The nodes in the layout tree.
computedStyles
array[ ComputedStyle ]
Whitelisted ComputedStyle properties for each node in the layout tree.
Types
DOMSnapshot.ComputedStyle #
A subset of the full ComputedStyle as defined by the request whitelist.
Type: object
Properties
properties
array[ NameValue ]
Name/value pairs of computed style properties.
DOMSnapshot.DocumentSnapshot #
Document snapshot.
Type: object
Properties
documentURL
Document URL that Document
or FrameOwner
node points to.
title
Document title.
baseURL
Base URL that Document
or FrameOwner
node uses for URL completion.
contentLanguage
Contains the document's content language.
encodingName
Contains the document's character set encoding.
publicId
DocumentType
node's publicId.
systemId
DocumentType
node's systemId.
frameId
Frame ID for frame owner elements and also for the document node.
nodes
A table with dom nodes.
layout
The nodes in the layout tree.
textBoxes
The post-layout inline text nodes.
scrollOffsetX
Optional
number
Horizontal scroll offset.
scrollOffsetY
Optional
number
Vertical scroll offset.
contentWidth
Optional
number
Document content width.
contentHeight
Optional
number
Document content height.
DOMSnapshot.DOMNode #
A Node in the DOM tree.
Type: object
Properties
nodeType
integer
Node
's nodeType.
nodeName
string
Node
's nodeName.
nodeValue
string
Node
's nodeValue.
textValue
Optional
string
Only set for textarea elements, contains the text value.
inputValue
Optional
string
Only set for input elements, contains the input's associated text value.
inputChecked
Optional
boolean
Only set for radio and checkbox input elements, indicates if the element has been checked
optionSelected
Optional
boolean
Only set for option elements, indicates if the element has been selected
backendNodeId
Node
's id, corresponds to DOM.Node.backendNodeId.
childNodeIndexes
Optional
array[ integer
]
The indexes of the node's child nodes in the domNodes
array returned by getSnapshot
, if
any.
attributes
Optional
array[ NameValue ]
Attributes of an Element
node.
pseudoElementIndexes
Optional
array[ integer
]
Indexes of pseudo elements associated with this node in the domNodes
array returned by
getSnapshot
, if any.
layoutNodeIndex
Optional
integer
The index of the node's related layout tree node in the layoutTreeNodes
array returned by
getSnapshot
, if any.
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.
contentLanguage
Optional
string
Only set for documents, contains the document's content language.
documentEncoding
Optional
string
Only set for documents, contains the document's character set encoding.
publicId
Optional
string
DocumentType
node's publicId.
systemId
Optional
string
DocumentType
node's systemId.
frameId
Optional
Frame ID for frame owner elements and also for the document node.
contentDocumentIndex
Optional
integer
The index of a frame owner element's content document in the domNodes
array returned by
getSnapshot
, if any.
pseudoType
Optional
Type of a pseudo element node.
shadowRootType
Optional
Shadow root type.
isClickable
Optional
boolean
Whether this DOM node responds to mouse clicks. This includes nodes that have had click event listeners attached via JavaScript as well as anchor tags that naturally navigate when clicked.
eventListeners
Optional
array[ DOMDebugger.EventListener ]
Details of the node's event listeners, if any.
currentSourceURL
Optional
string
The selected url for nodes with a srcset attribute.
originURL
Optional
string
The url of the script (if any) that generates this node.
scrollOffsetX
Optional
number
Scroll offsets, set when this node is a Document.
scrollOffsetY
Optional
number
DOMSnapshot.InlineTextBox #
Details of post layout rendered text positions. The exact layout should not be regarded as stable and may change between versions.
Type: object
Properties
boundingBox
The bounding box in document coordinates. Note that scroll offset of the document is ignored.
startCharacterIndex
integer
The starting index in characters, for this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
numCharacters
integer
The number of characters in this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
DOMSnapshot.LayoutTreeNode #
Details of an element in the DOM tree with a LayoutObject.
Type: object
Properties
domNodeIndex
integer
The index of the related DOM node in the domNodes
array returned by getSnapshot
.
boundingBox
The bounding box in document coordinates. Note that scroll offset of the document is ignored.
layoutText
Optional
string
Contents of the LayoutText, if any.
inlineTextNodes
Optional
array[ InlineTextBox ]
The post-layout inline text nodes, if any.
styleIndex
Optional
integer
Index into the computedStyles
array returned by getSnapshot
.
paintOrder
Optional
integer
Global paint order index, which is determined by the stacking order of the nodes. Nodes that are painted together will have the same index. Only provided if includePaintOrder in getSnapshot was true.
isStackingContext
Optional
boolean
Set to true to indicate the element begins a new stacking context.
DOMSnapshot.LayoutTreeSnapshot #
Table of details of an element in the DOM tree with a LayoutObject.
Type: object
Properties
nodeIndex
array[ integer
]
Index of the corresponding node in the NodeTreeSnapshot
array returned by captureSnapshot
.
styles
array[ ArrayOfStrings ]
Array of indexes specifying computed style strings, filtered according to the computedStyles
parameter passed to captureSnapshot
.
bounds
array[ Rectangle ]
The absolute position bounding box.
text
array[ StringIndex ]
Contents of the LayoutText, if any.
stackingContexts
Stacking context information.
paintOrders
Optional
array[ integer
]
Global paint order index, which is determined by the stacking order of the nodes. Nodes that are painted together will have the same index. Only provided if includePaintOrder in captureSnapshot was true.
offsetRects
Optional
array[ Rectangle ]
The offset rect of nodes. Only available when includeDOMRects is set to true
scrollRects
Optional
array[ Rectangle ]
The scroll rect of nodes. Only available when includeDOMRects is set to true
clientRects
Optional
array[ Rectangle ]
The client rect of nodes. Only available when includeDOMRects is set to true
blendedBackgroundColors
Optional
array[ StringIndex ]
The list of background colors that are blended with colors of overlapping elements.
textColorOpacities
Optional
array[ number
]
The list of computed text opacities.
DOMSnapshot.NameValue #
A name/value pair.
Type: object
Properties
name
string
Attribute/property name.
value
string
Attribute/property value.
DOMSnapshot.NodeTreeSnapshot #
Table containing nodes.
Type: object
Properties
parentIndex
Optional
array[ integer
]
Parent node index.
nodeType
Optional
array[ integer
]
Node
's nodeType.
shadowRootType
Optional
Type of the shadow root the Node
is in. String values are equal to the ShadowRootType
enum.
nodeName
Optional
array[ StringIndex ]
Node
's nodeName.
nodeValue
Optional
array[ StringIndex ]
Node
's nodeValue.
backendNodeId
Optional
array[ DOM.BackendNodeId ]
Node
's id, corresponds to DOM.Node.backendNodeId.
attributes
Optional
array[ ArrayOfStrings ]
Attributes of an Element
node. Flatten name, value pairs.
textValue
Optional
Only set for textarea elements, contains the text value.
inputValue
Optional
Only set for input elements, contains the input's associated text value.
inputChecked
Optional
Only set for radio and checkbox input elements, indicates if the element has been checked
optionSelected
Optional
Only set for option elements, indicates if the element has been selected
contentDocumentIndex
Optional
The index of the document in the list of the snapshot documents.
pseudoType
Optional
Type of a pseudo element node.
pseudoIdentifier
Optional
Pseudo element identifier for this node. Only present if there is a valid pseudoType.
isClickable
Optional
Whether this DOM node responds to mouse clicks. This includes nodes that have had click event listeners attached via JavaScript as well as anchor tags that naturally navigate when clicked.
currentSourceURL
Optional
The selected url for nodes with a srcset attribute.
originURL
Optional
The url of the script (if any) that generates this node.
DOMSnapshot.RareStringData #
Data that is only present on rare nodes.
Type: object
Properties
index
array[ integer
]
value
array[ StringIndex ]
DOMSnapshot.TextBoxSnapshot #
Table of details of the post layout rendered text positions. The exact layout should not be regarded as stable and may change between versions.
Type: object
Properties
layoutIndex
array[ integer
]
Index of the layout tree node that owns this box collection.
bounds
array[ Rectangle ]
The absolute position bounding box.
start
array[ integer
]
The starting index in characters, for this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
length
array[ integer
]
The number of characters in this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.