← Back to DOM domain

DOM.getElementByRelation

Returns the NodeId of the matched element according to certain relations.

Domain: DOM experimental

Parameters

NameTypeDescription
nodeIdNodeIdId of the node from which to query the relation.
relationstringType of relation to get.

Returns

NameTypeDescription
nodeIdNodeIdNodeId of the element matching the queried relation.

Example Request

{
  "id": 1,
  "method": "DOM.getElementByRelation",
  "params": {
    "nodeId": 1,
    "relation": "relation-value"
  }
}

Example Response

{
  "id": 1,
  "result": {
    "nodeId": 3
  }
}

Usage in Node.js

const result = await send('DOM.getElementByRelation', {"nodeId": 1, "relation": "relation-value"});
console.log(result);
// {"nodeId": 3}