DOM
该域公开了DOM的读写操作。每个DOM节点都通过其镜像对象表示,该对象具有一个id。此id可用于获取节点的附加信息,将其解析为JavaScript对象包装器等。客户端仅接收已知节点的DOM事件至关重要。后端会跟踪已发送给客户端的节点,并且永远不会重复发送同一节点。客户端有责任收集已发送给客户端的节点信息。请注意,iframe所有者元素将返回相应的文档元素作为其子节点。
EN
This domain exposes DOM read/write operations. Each DOM Node is represented with its mirror object that has an
id. This id can be used to get additional information on the Node, resolve it into the JavaScript object wrapper, etc. It is important that client receives DOM events only for the nodes that are known to the client. Backend keeps track of the nodes that were sent to the client and never sends the same node twice. It is client's responsibility to collect information about the nodes that were sent to the client. Note that iframe owner elements will return corresponding document elements as their child nodes.✅️️ Methods
🔨DOM.describeNode
描述给定其ID的节点,不需要启用域。不开始跟踪任何对象,可用于自动化。
EN
Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | NodeId | 节点的标识符。 | ENIdentifier of the node. | ||
| backendNodeId | BackendNodeId | 后端节点的标识符。 | ENIdentifier of the backend node. | ||
| objectId | Runtime.RemoteObjectId | 节点包装器的JavaScript对象标识符。 | ENJavaScript object id of the node wrapper. | ||
| depth | integer | 获取子节点的最大深度,默认为1。使用-1表示整个子树,或提供大于0的整数。 | ENThe 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 | boolean | 是否在返回子树时遍历 iframe 和 shadow root(默认为 false)。 | ENWhether or not iframes and shadow roots should be traversed when returning the subtree (default is false). |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| node | Node | 节点描述。 | ENNode description. |
🔨DOM.disable
为给定页面禁用DOM代理。
EN
Disables DOM agent for the given page.
🔨DOM.enable
为给定页面启用DOM代理。
EN
Enables DOM agent for the given page.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| includeWhitespace | 🧪 | string | 是否在返回节点的子节点数组中包含空白字符。 允许的值: none, all | ENWhether to include whitespaces in the children array of returned Nodes.Allowed Values: none, all |
🔨DOM.focus
聚焦给定的元素。
EN
Focuses the given element.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | NodeId | 节点的标识符。 | ENIdentifier of the node. | ||
| backendNodeId | BackendNodeId | 后端节点的标识符。 | ENIdentifier of the backend node. | ||
| objectId | Runtime.RemoteObjectId | 节点包装器的JavaScript对象标识符。 | ENJavaScript object id of the node wrapper. |
🔨DOM.getAttributes
返回指定节点的属性。
EN
Returns attributes for the specified node.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | ✔️ | NodeId | 要检索属性的节点ID。 | ENId of the node to retrieve attributes for. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| attributes | array[string] | 一个交错排列的节点属性名称和值的数组。 | ENAn interleaved array of node attribute names and values. |
🔨DOM.getBoxModel
返回给定节点的''boxes''。
EN
Returns boxes for the given node.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | NodeId | 节点的标识符。 | ENIdentifier of the node. | ||
| backendNodeId | BackendNodeId | 后端节点的标识符。 | ENIdentifier of the backend node. | ||
| objectId | Runtime.RemoteObjectId | 节点包装器的JavaScript对象标识符。 | ENJavaScript object id of the node wrapper. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| model | BoxModel | 节点的盒模型。 | ENBox model for the node. |
🔨DOM.getDocument
返回根DOM节点(以及可选的子树)给调用者。隐式地为当前目标启用DOM域事件。
EN
Returns the root DOM node (and optionally the subtree) to the caller. Implicitly enables the DOM domain events for the current target.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| depth | integer | 获取子节点的最大深度,默认为1。使用-1表示整个子树,或提供大于0的整数。 | ENThe 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 | boolean | 在返回子树时是否应遍历iframe和shadow root(默认为false)。 | ENWhether or not iframes and shadow roots should be traversed when returning the subtree (default is false). |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| root | Node | 结果节点。 | ENResulting node. |
🔨DOM.getNodeForLocation
返回给定位置的节点ID。根据DOM域是否启用,nodeId可能会被返回或不返回。
EN
Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| x | ✔️ | integer | X 坐标。 | ENX coordinate. | |
| y | ✔️ | integer | Y 坐标。 | ENY coordinate. | |
| includeUserAgentShadowDOM | boolean | 设置为 false 以跳过至最近的非用户代理阴影根祖先(默认值:false)。 | ENFalse to skip to the nearest non-UA shadow root ancestor (default: false). | ||
| ignorePointerEventsNone | boolean | 是否忽略元素上的pointer-events: none并对其进行命中测试。 | ENWhether to ignore pointer-events: none on elements and hit test them. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| backendNodeId | BackendNodeId | 生成的节点。 | ENResulting node. |
| frameId | Page.FrameId | 此节点所属的框架。 | ENFrame this node belongs to. |
| nodeId | NodeId | 节点在给定坐标处的标识符,仅当启用并请求文档时。 | ENId of the node at given coordinates, only when enabled and requested document. |
🔨DOM.getOuterHTML
返回节点的HTML标记。
EN
Returns node's HTML markup.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | NodeId | 节点的标识符。 | ENIdentifier of the node. | ||
| backendNodeId | BackendNodeId | 后端节点的标识符。 | ENIdentifier of the backend node. | ||
| objectId | Runtime.RemoteObjectId | 节点包装器的 JavaScript 对 象标识符。 | ENJavaScript object id of the node wrapper. | ||
| includeShadowDOM | 🧪 | boolean | 包含所有影子根。如果未指定,则默认为 false。 | ENInclude all shadow roots. Equals to false if not specified. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| outerHTML | string | 外部 HTML 标记。 | ENOuter HTML markup. |
🔨DOM.hideHighlight
隐藏任何高亮。
EN
Hides any highlight.
🔨DOM.highlightNode
高亮显示DOM节点。
EN
Highlights DOM node.
🔨DOM.highlightRect
高 亮显示给定的矩形。
EN
Highlights given rectangle.
🔨DOM.moveTo
将节点移动到新的容器中,并将其放置在给定锚点之前。
EN
Moves node into the new container, places it before the given anchor.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | ✔️ | NodeId | 要移动的节点的Id。 | ENId of the node to move. | |
| targetNodeId | ✔️ | NodeId | 要移动的节点将被放置到的元素ID。 | ENId of the element to drop the moved node into. | |
| insertBeforeNodeId | NodeId | 将节点移至此节点之前(如果缺失,被移动的节点将成为 targetNodeId 的最后一个子节点)。 | ENDrop node before this one (if absent, the moved node becomes the last child oftargetNodeId). |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| nodeId | NodeId | 移动后节点的新ID。 | ENNew id of the moved node. |
🔨DOM.querySelector
在给定节点上执行 querySelector。
EN
Executes
querySelector on a given node.| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | ✔️ | NodeId | 要查询的节点的''Id''。 | ENId of the node to query upon. | |
| selector | ✔️ | string | 选择器字符串。 | ENSelector string. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| nodeId | NodeId | 查询选择器结果。 | ENQuery selector result. |
🔨DOM.querySelectorAll
在指定节点上执行 querySelectorAll。
EN
Executes
querySelectorAll on a given node.| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | ✔️ | NodeId | 要查询的节点的''Id''。 | ENId of the node to query upon. | |
| selector | ✔️ | string | 选择器字符串。 | ENSelector string. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| nodeIds | array[NodeId] | 查询选择器结果。 | ENQuery selector result. |
🔨DOM.removeAttribute
从具有指定id的元素中移除具有指定名称的属性。
EN
Removes attribute with given name from an element with given id.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| nodeId | ✔️ | NodeId | 要从其移除属性的元素ID。 | ENId of the element to remove attribute from. | |
| name | ✔️ | string | 要移除的属性的名称。 | ENName of the attribute to remove. |
🔨DOM.removeNode
删除具有给定 id 的节点。
EN
Removes node with given id.
| 参数 | 必填 | 标记 |
|---|