← Back to DOM domain

DOM.getNodeForLocation

Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.

Domain: DOM stable

Parameters

NameTypeDescription
xintegerX coordinate.
yintegerY coordinate.
includeUserAgentShadowDOM (optional)booleanFalse to skip to the nearest non-UA shadow root ancestor (default: false).
ignorePointerEventsNone (optional)booleanWhether to ignore pointer-events: none on elements and hit test them.

Returns

NameTypeDescription
backendNodeIdBackendNodeIdResulting node.
frameIdPage.FrameIdFrame this node belongs to.
nodeIdNodeIdId of the node at given coordinates, only when enabled and requested document.

Example Request

{
  "id": 1,
  "method": "DOM.getNodeForLocation",
  "params": {
    "x": 100,
    "y": 100
  }
}

Example Response

{
  "id": 1,
  "result": {
    "backendNodeId": "backendNodeId-value",
    "frameId": "ABC123DEF456",
    "nodeId": 3
  }
}

Usage in Node.js

const result = await send('DOM.getNodeForLocation', {"x": 100, "y": 100});
console.log(result);
// {"backendNodeId": "backendNodeId-value", "frameId": "ABC123DEF456", "nodeId": 3}