← Back to DOM domain
DOM.getDocument
Returns the root DOM node (and optionally the subtree) to the caller.
Implicitly enables the DOM domain events for the current target.
Domain: DOM
stable
Parameters
| Name | Type | Description |
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). |
Returns
| Name | Type | Description |
root | Node | Resulting node. |
Example Request
{
"id": 1,
"method": "DOM.getDocument"
}
Example Response
{
"id": 1,
"result": {
"root": {
"nodeId": 1,
"nodeType": 9,
"nodeName": "#document",
"childNodeCount": 2
}
}
}
Usage in Node.js
const result = await send('DOM.getDocument');
console.log(result);
// {"root": {"nodeId": 1, "nodeType": 9, "nodeName": "#document", "childNodeCount": 2}}