← Back to DOMSnapshot domain

DOMSnapshot.getSnapshot

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.

Domain: DOMSnapshot deprecated

Parameters

NameTypeDescription
computedStyleWhitelistarrayWhitelist of computed styles to return.
includeEventListeners (optional)booleanWhether or not to retrieve details of DOM listeners (default false).
includePaintOrder (optional)booleanWhether to determine and include the paint order index of LayoutTreeNodes (default false).
includeUserAgentShadowTree (optional)booleanWhether to include UA shadow tree in the snapshot (default false).

Returns

NameTypeDescription
domNodesarrayThe nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
layoutTreeNodesarrayThe nodes in the layout tree.
computedStylesarrayWhitelisted ComputedStyle properties for each node in the layout tree.

Example Request

{
  "id": 1,
  "method": "DOMSnapshot.getSnapshot",
  "params": {
    "computedStyleWhitelist": []
  }
}

Example Response

{
  "id": 1,
  "result": {
    "domNodes": [],
    "layoutTreeNodes": [],
    "computedStyles": []
  }
}

Usage in Node.js

const result = await send('DOMSnapshot.getSnapshot', {"computedStyleWhitelist": []});
console.log(result);
// {"domNodes": [], "layoutTreeNodes": [], "computedStyles": []}