DOMSnapshot Domain
This domain facilitates obtaining document snapshots with DOM, layout, and style information.
Methods
Types
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
-
boolean
Whether to include layout object paint orders into the snapshot.
- includeDOMRects
-
boolean
Whether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
- includeBlendedBackgroundColors
-
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
-
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.disable #
Disables DOM snapshot agent for the given page.
DOMSnapshot.enable #
Enables DOM snapshot agent for the given page.
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
-
boolean
Whether or not to retrieve details of DOM listeners (default false).
- includePaintOrder
-
boolean
Whether to determine and include the paint order index of LayoutTreeNodes (default false).
- includeUserAgentShadowTree
-
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
-
StringIndex
Document URL that
Document
orFrameOwner
node points to. - title
-
StringIndex
Document title.
- baseURL
-
StringIndex
Base URL that
Document
orFrameOwner
node uses for URL completion. - contentLanguage
-
StringIndex
Contains the document's content language.
- encodingName
-
StringIndex
Contains the document's character set encoding.
- publicId
-
StringIndex
DocumentType
node's publicId. - systemId
-
StringIndex
DocumentType
node's systemId. - frameId
-
StringIndex
Frame ID for frame owner elements and also for the document node.
- nodes
-
NodeTreeSnapshot
A table with dom nodes.
- layout
-
LayoutTreeSnapshot
The nodes in the layout tree.
- textBoxes
-
TextBoxSnapshot
The post-layout inline text nodes.
- scrollOffsetX
-
number
Horizontal scroll offset.
- scrollOffsetY
-
number
Vertical scroll offset.
- contentWidth
-
number
Document content width.
- contentHeight
-
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
-
string
Only set for textarea elements, contains the text value.
- inputValue
-
string
Only set for input elements, contains the input's associated text value.
- inputChecked
-
boolean
Only set for radio and checkbox input elements, indicates if the element has been checked
- optionSelected
-
boolean
Only set for option elements, indicates if the element has been selected
- backendNodeId
-
DOM.BackendNodeId
Node
's id, corresponds to DOM.Node.backendNodeId. - childNodeIndexes
-
array[ integer ]
The indexes of the node's child nodes in the
domNodes
array returned bygetSnapshot
, if any. - attributes
-
array[ NameValue ]
Attributes of an
Element
node. - pseudoElementIndexes
-
array[ integer ]
Indexes of pseudo elements associated with this node in the
domNodes
array returned bygetSnapshot
, if any. - layoutNodeIndex
-
integer
The index of the node's related layout tree node in the
layoutTreeNodes
array returned bygetSnapshot
, if any. - documentURL
-
string
Document URL that
Document
orFrameOwner
node points to. - baseURL
-
string
Base URL that
Document
orFrameOwner
node uses for URL completion. - contentLanguage
-
string
Only set for documents, contains the document's content language.
- documentEncoding
-
string
Only set for documents, contains the document's character set encoding.
- publicId
-
string
DocumentType
node's publicId. - systemId
-
string
DocumentType
node's systemId. - frameId
-
Page.FrameId
Frame ID for frame owner elements and also for the document node.
- contentDocumentIndex
-
integer
The index of a frame owner element's content document in the
domNodes
array returned bygetSnapshot
, if any. - pseudoType
-
DOM.PseudoType
Type of a pseudo element node.
- shadowRootType
-
DOM.ShadowRootType
Shadow root type.
- isClickable
-
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
-
array[ DOMDebugger.EventListener ]
Details of the node's event listeners, if any.
- currentSourceURL
-
string
The selected url for nodes with a srcset attribute.
- originURL
-
string
The url of the script (if any) that generates this node.
- scrollOffsetX
-
number
Scroll offsets, set when this node is a Document.
- scrollOffsetY
-
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
-
DOM.Rect
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 bygetSnapshot
. - boundingBox
-
DOM.Rect
The bounding box in document coordinates. Note that scroll offset of the document is ignored.
- layoutText
-
string
Contents of the LayoutText, if any.
- inlineTextNodes
-
array[ InlineTextBox ]
The post-layout inline text nodes, if any.
- styleIndex
-
integer
Index into the
computedStyles
array returned bygetSnapshot
. - paintOrder
-
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
-
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 bycaptureSnapshot
. - styles
-
array[ ArrayOfStrings ]
Array of indexes specifying computed style strings, filtered according to the
computedStyles
parameter passed tocaptureSnapshot
. - bounds
-
array[ Rectangle ]
The absolute position bounding box.
- text
-
array[ StringIndex ]
Contents of the LayoutText, if any.
- stackingContexts
-
RareBooleanData
Stacking context information.
- paintOrders
-
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
-
array[ Rectangle ]
The offset rect of nodes. Only available when includeDOMRects is set to true
- scrollRects
-
array[ Rectangle ]
The scroll rect of nodes. Only available when includeDOMRects is set to true
- clientRects
-
array[ Rectangle ]
The client rect of nodes. Only available when includeDOMRects is set to true
- blendedBackgroundColors
-
array[ StringIndex ]
The list of background colors that are blended with colors of overlapping elements.
- textColorOpacities
-
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
-
array[ integer ]
Parent node index.
- nodeType
-
array[ integer ]
Node
's nodeType. - shadowRootType
-
RareStringData
Type of the shadow root the
Node
is in. String values are equal to theShadowRootType
enum. - nodeName
-
array[ StringIndex ]
Node
's nodeName. - nodeValue
-
array[ StringIndex ]
Node
's nodeValue. - backendNodeId
-
array[ DOM.BackendNodeId ]
Node
's id, corresponds to DOM.Node.backendNodeId. - attributes
-
array[ ArrayOfStrings ]
Attributes of an
Element
node. Flatten name, value pairs. - textValue
-
RareStringData
Only set for textarea elements, contains the text value.
- inputValue
-
RareStringData
Only set for input elements, contains the input's associated text value.
- inputChecked
-
RareBooleanData
Only set for radio and checkbox input elements, indicates if the element has been checked
- optionSelected
-
RareBooleanData
Only set for option elements, indicates if the element has been selected
- contentDocumentIndex
-
RareIntegerData
The index of the document in the list of the snapshot documents.
- pseudoType
-
RareStringData
Type of a pseudo element node.
- pseudoIdentifier
-
RareStringData
Pseudo element identifier for this node. Only present if there is a valid pseudoType.
- isClickable
-
RareBooleanData
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
-
RareStringData
The selected url for nodes with a srcset attribute.
- originURL
-
RareStringData
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.