跳到主要内容

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.
参数必填标记类型描述原文
nodeIdNodeId节点的标识符。
ENIdentifier of the node.
backendNodeIdBackendNodeId后端节点的标识符。
ENIdentifier of the backend node.
objectIdRuntime.RemoteObjectId节点包装器的JavaScript对象标识符。
ENJavaScript object id of the node wrapper.
depthinteger获取子节点的最大深度,默认为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.
pierceboolean是否在返回子树时遍历 iframe 和 shadow root(默认为 false)。
ENWhether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
返回对象类型描述原文
nodeNode节点描述。
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.
参数必填标记类型描述原文
nodeIdNodeId节点的标识符。
ENIdentifier of the node.
backendNodeIdBackendNodeId后端节点的标识符。
ENIdentifier of the backend node.
objectIdRuntime.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.
返回对象类型描述原文
attributesarray[string]一个交错排列的节点属性名称和值的数组。
ENAn interleaved array of node attribute names and values.

🔨DOM.getBoxModel

返回给定节点的''boxes''。

EN
Returns boxes for the given node.
参数必填标记类型描述原文
nodeIdNodeId节点的标识符。
ENIdentifier of the node.
backendNodeIdBackendNodeId后端节点的标识符。
ENIdentifier of the backend node.
objectIdRuntime.RemoteObjectId节点包装器的JavaScript对象标识符。
ENJavaScript object id of the node wrapper.
返回对象类型描述原文
modelBoxModel节点的盒模型。
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.
参数必填标记类型描述原文
depthinteger获取子节点的最大深度,默认为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.
pierceboolean在返回子树时是否应遍历iframe和shadow root(默认为false)。
ENWhether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
返回对象类型描述原文
rootNode结果节点。
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✔️integerX 坐标。
ENX coordinate.
y✔️integerY 坐标。
ENY coordinate.
includeUserAgentShadowDOMboolean设置为 false 以跳过至最近的非用户代理阴影根祖先(默认值:false)。
ENFalse to skip to the nearest non-UA shadow root ancestor (default: false).
ignorePointerEventsNoneboolean是否忽略元素上的pointer-events: none并对其进行命中测试。
ENWhether to ignore pointer-events: none on elements and hit test them.
返回对象类型描述原文
backendNodeIdBackendNodeId生成的节点。
ENResulting node.
frameIdPage.FrameId此节点所属的框架。
ENFrame this node belongs to.
nodeIdNodeId节点在给定坐标处的标识符,仅当启用并请求文档时。
ENId of the node at given coordinates, only when enabled and requested document.

🔨DOM.getOuterHTML

返回节点的HTML标记。

EN
Returns node's HTML markup.
参数必填标记类型描述原文
nodeIdNodeId节点的标识符。
ENIdentifier of the node.
backendNodeIdBackendNodeId后端节点的标识符。
ENIdentifier of the backend node.
objectIdRuntime.RemoteObjectId节点包装器的 JavaScript 对象标识符。
ENJavaScript object id of the node wrapper.
includeShadowDOM🧪boolean包含所有影子根。如果未指定,则默认为 false。
ENInclude all shadow roots. Equals to false if not specified.
返回对象类型描述原文
outerHTMLstring外部 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.
insertBeforeNodeIdNodeId将节点移至此节点之前(如果缺失,被移动的节点将成为 targetNodeId 的最后一个子节点)。
ENDrop node before this one (if absent, the moved node becomes the last child of targetNodeId).
返回对象类型描述原文
nodeIdNodeId移动后节点的新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.
返回对象类型描述原文
nodeIdNodeId查询选择器结果。
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.
返回对象类型描述原文
nodeIdsarray[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.
参数必填标记类型描述原文
nodeId✔️NodeId要移除的节点的Id。
ENId of the node to remove.

🔨DOM.requestChildNodes

请求以setChildNodes事件的形式返回给定ID节点的子节点给调用者,其中不仅检索直接子节点,还包括指定深度内的所有子节点。

EN
Requests that children of the node with given id are returned to the caller in form of setChildNodes events where not only immediate children are retrieved, but all children down to the specified depth.
参数必填标记类型描述原文
nodeId✔️NodeId获取子节点的节点ID。
ENId of the node to get children for.
depthinteger获取子节点的最大深度,默认为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.
pierceboolean在返回子树时是否应遍历iframe和shadow root(默认为false)。
ENWhether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false).

🔨DOM.requestNode

请求将节点发送给调用者,前提是提供了JavaScript节点对象引用。从该节点到根节点路径上的所有节点也会以一系列setChildNodes通知的形式发送给客户端。

EN
Requests that the node is sent to the caller given the JavaScript node object reference. All nodes that form the path from the node to the root are also sent to the client as a series of setChildNodes notifications.
参数必填标记类型描述原文
objectId✔️Runtime.RemoteObjectId将JavaScript对象ID转换为节点。
ENJavaScript object id to convert into node.
返回对象类型描述原文
nodeIdNodeId给定对象的节点ID。
ENNode id for given object.

🔨DOM.resolveNode

为给定的 NodeId 或 BackendNodeId 解析对应的 JavaScript 节点对象。

EN
Resolves the JavaScript node object for a given NodeId or BackendNodeId.
参数必填标记类型描述原文
nodeIdNodeId要解析的节点的Id。
ENId of the node to resolve.
backendNodeIdDOM.BackendNodeId要解析的节点的后端标识符。
ENBackend identifier of the node to resolve.
objectGroupstring可用于释放多个对象的符号化组名。
ENSymbolic group name that can be used to release multiple objects.
executionContextIdRuntime.ExecutionContextId解析节点所在的执行上下文。
ENExecution context in which to resolve the node.
返回对象类型描述原文
objectRuntime.RemoteObject给定节点的JavaScript对象包装器。
ENJavaScript object wrapper for given node.

🔨DOM.scrollIntoViewIfNeeded

如果指定节点的矩形区域当前不可见,则将其滚动至视图中。注意:应传入 nodeId、backendNodeId 和 objectId 中的任意一个参数来标识节点。

EN
Scrolls the specified rect of the given node into view if not already visible. Note: exactly one between nodeId, backendNodeId and objectId should be passed to identify the node.
参数必填标记类型描述原文
nodeIdNodeId节点的标识符。
ENIdentifier of the node.
backendNodeIdBackendNodeId后端节点的标识符。
ENIdentifier of the backend node.
objectIdRuntime.RemoteObjectId节点包装器的JavaScript对象标识符。
ENJavaScript object id of the node wrapper.
rectRect要滚动到视口内的矩形区域,相对于节点的边框盒,以CSS像素为单位。如果省略,则使用节点的中心,类似于Element.scrollIntoView的行为。
ENThe rect to be scrolled into view, relative to the node's border box, in CSS pixels. When omitted, center of the node will be used, similar to Element.scrollIntoView.

🔨DOM.setAttributesAsText

设置具有给定id的元素的属性。当用户编辑某些现有属性值并输入多个属性名称/值对时,此方法非常有用。

EN
Sets attributes on element with given id. This method is useful when user edits some existing attribute value and types in several attribute name/value pairs.
参数必填标记类型描述原文
nodeId✔️NodeId为元素设置属性的ID。
ENId of the element to set attributes for.
text✔️string包含多个属性的文本。将使用HTML解析器解析此文本。
ENText with a number of attributes. Will parse this text using HTML parser.
namestring属性名称,在文本解析成功的情况下,将替换为从文本派生出的新属性。
ENAttribute name to replace with new attributes derived from text in case text parsed successfully.

🔨DOM.setAttributeValue

为具有给定 id 的元素设置属性。

EN
Sets attribute for an element with given id.
参数必填标记类型描述原文
nodeId✔️NodeId要设置属性的元素ID。
ENId of the element to set attribute for.
name✔️string属性名称。
ENAttribute name.
value✔️string属性值。
ENAttribute value.

🔨DOM.setFileInputFiles

为给定的文件输入元素设置文件。

EN
Sets files for the given file input element.
参数必填标记类型描述原文
files✔️array[string]要设置的文件路径数组。
ENArray of file paths to set.
nodeIdNodeId节点的标识符。
ENIdentifier of the node.
backendNodeIdBackendNodeId后端节点的标识符。
ENIdentifier of the backend node.
objectIdRuntime.RemoteObjectId节点包装器的JavaScript对象标识符。
ENJavaScript object id of the node wrapper.

🔨DOM.setNodeName

为具有给定id的节点设置节点名称。

EN
Sets node name for a node with given id.
参数必填标记类型描述原文
nodeId✔️NodeId为节点设置名称的Id。
ENId of the node to set name for.
name✔️string新节点的名称。
ENNew node's name.
返回对象类型描述原文
nodeIdNodeId新节点的ID。
ENNew node's id.

🔨DOM.setNodeValue

为具有给定id的节点设置节点值。

EN
Sets node value for a node with given id.
参数必填标记类型描述原文
nodeId✔️NodeId为节点设置值的ID。
ENId of the node to set value for.
value✔️string新节点的值。
ENNew node's value.

🔨DOM.setOuterHTML

设置节点HTML标记,返回新节点ID。

EN
Sets node HTML markup, returns new node id.
参数必填标记类型描述原文
nodeId✔️NodeId为节点设置标记的ID。
ENId of the node to set markup for.
outerHTML✔️string设置外部HTML标记。
ENOuter HTML markup to set.

🔨DOM.getFlattenedDocument❌️

返回根DOM节点(以及可选的子树)给调用者。已弃用,因为它并未设计为与DOM代理的其他部分良好协作。请改用DOMSnapshot.captureSnapshot。

EN
Returns the root DOM node (and optionally the subtree) to the caller. Deprecated, as it is not designed to work well with the rest of the DOM agent. Use DOMSnapshot.captureSnapshot instead.
参数必填标记类型描述原文
depthinteger获取子节点的最大深度,默认为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.
pierceboolean是否在返回子树时遍历 iframe 和 shadow root(默认为 false)。
ENWhether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
返回对象类型描述原文
nodesarray[Node]结果节点。
ENResulting node.

🔨DOM.collectClassNamesFromSubtree🧪

收集具有给定ID的节点及其所有子节点的类名。

EN
Collects class names for the node with given id and all of it's child nodes.
参数必填标记类型描述原文
nodeId✔️NodeId要收集类名的节点ID。
ENId of the node to collect class names.
返回对象类型描述原文
classNamesarray[string]类名列表。
ENClass name list.

🔨DOM.copyTo🧪

创建指定节点的深度副本,并将其放置在目标容器中给定锚点之前。

EN
Creates a deep copy of the specified node and places it into the target container before the given anchor.
参数必填标记类型描述原文
nodeId✔️NodeId要复制的节点的ID。
ENId of the node to copy.
targetNodeId✔️NodeId将副本拖入的元素的Id。
ENId of the element to drop the copy into.
insertBeforeNodeIdNodeId在此节点之前放置副本(如果不存在,则副本将成为 targetNodeId 的最后一个子节点)。
ENDrop the copy before this node (if absent, the copy becomes the last child of targetNodeId).
返回对象类型描述原文
nodeIdNodeId节点克隆的ID。
ENId of the node clone.

🔨DOM.discardSearchResults🧪

丢弃具有给定ID的会话中的搜索结果。对于该搜索,不应再调用getSearchResults

EN
Discards search results from the session with the given id. getSearchResults should no longer be called for that search.
参数必填标记类型描述原文
searchId✔️string唯一的搜索会话标识符。
ENUnique search session identifier.

🔨DOM.forceShowPopover🧪

启用时,此API会强制打开由nodeId标识的弹出层,并在禁用前保持其开启状态。

EN
When enabling, this API force-opens the popover identified by nodeId and keeps it open until disabled.
参数必填标记类型描述原文
nodeId✔️NodeId弹出式HTML元素的Id
ENId of the popover HTMLElement
enable✔️boolean如果为真,则打开弹出窗口并保持其打开状态。如果为假,则关闭之前被强制打开的弹出窗口。
ENIf true, opens the popover and keeps it open. If false, closes the popover if it was previously force-opened.
返回对象类型描述原文
nodeIdsarray[NodeId]根据弹出层堆叠顺序而关闭的弹出层列表。
ENList of popovers that were closed in order to respect popover stacking order.

🔨DOM.getAnchorElement🧪

根据https://www.w3.org/TR/css-anchor-position-1/#target规范,返回给定锚点查询对应的目标锚点元素。

EN
Returns the target anchor element of the given anchor query according to https://www.w3.org/TR/css-anchor-position-1/#target.
参数必填标记类型描述原文
nodeId✔️NodeId定位元素的ID,用于查找锚点。
ENId of the positioned element from which to find the anchor.
anchorSpecifierstring一个可选的锚点指定符,定义见https://www.w3.org/TR/css-anchor-position-1/#anchor-specifier。若未提供,将返回给定定位元素的隐式锚点元素。
ENAn optional anchor specifier, as defined in https://www.w3.org/TR/css-anchor-position-1/#anchor-specifier. If not provided, it will return the implicit anchor element for the given positioned element.
返回对象类型描述原文
nodeIdNodeId给定锚点查询的锚点元素。
ENThe anchor element of the given anchor query.

🔨DOM.getContainerForNode🧪

返回给定节点基于容器查询条件的查询容器:容器名称、物理和逻辑轴,以及是否查询滚动状态或锚定元素。如果未提供轴且queriesScrollState为false,则返回样式容器,即直接父节点或具有匹配容器名称的最近元素。

EN
Returns the query container of the given node based on container query conditions: containerName, physical and logical axes, and whether it queries scroll-state or anchored elements. If no axes are provided and queriesScrollState is false, the style container is returned, which is the direct parent or the closest element with a matching container-name.
参数必填标记类型描述原文
nodeId✔️NodeId
containerNamestring
physicalAxesPhysicalAxes
logicalAxesLogicalAxes
queriesScrollStateboolean
queriesAnchoredboolean
返回对象类型描述原文
nodeIdNodeId给定节点的容器节点,如果未找到则为null。
ENThe container node for the given node, or null if not found.

🔨DOM.getContentQuads🧪

返回描述节点在页面上位置的四边形。此方法可能为内联节点返回多个四边形。

EN
Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.
参数必填标记类型描述原文
nodeIdNodeId节点的标识符。
ENIdentifier of the node.
backendNodeIdBackendNodeId后端节点的标识符。
ENIdentifier of the backend node.
objectIdRuntime.RemoteObjectId节点包装器的 JavaScript 对象标识符。
ENJavaScript object id of the node wrapper.
返回对象类型描述原文
quadsarray[Quad]描述节点相对于视口布局的四边形。
ENQuads that describe node layout relative to viewport.

🔨DOM.getDetachedDomNodes🧪

返回分离节点列表

EN
Returns list of detached nodes
返回对象类型描述原文
detachedNodesarray[DetachedElementInfo]分离节点列表
ENThe list of detached nodes

🔨DOM.getElementByRelation🧪

根据特定关系返回匹配元素的NodeId。

EN
Returns the NodeId of the matched element according to certain relations.
参数必填标记类型描述原文
nodeId✔️NodeId查询关系的节点标识。
ENId of the node from which to query the relation.
relation✔️string要获取的关系类型。
允许的值:PopoverTargetInterestTargetCommandFor
ENType of relation to get.
Allowed Values: PopoverTarget, InterestTarget, CommandFor
返回对象类型描述原文
nodeIdNodeId匹配查询关系的元素的NodeId。
ENNodeId of the element matching the queried relation.

🔨DOM.getFileInfo🧪

返回给定File包装器的文件信息。

EN
Returns file information for the given File wrapper.
参数必填标记类型描述原文
objectId✔️Runtime.RemoteObjectId节点包装器的JavaScript对象标识符。
ENJavaScript object id of the node wrapper.
返回对象类型描述原文
pathstring

🔨DOM.getFrameOwner🧪

返回拥有指定域名的iframe的iframe节点。

EN
Returns iframe node that owns iframe with the given domain.
参数必填标记类型描述原文
frameId✔️Page.FrameId
返回对象类型描述原文
backendNodeIdBackendNodeId结果节点。
ENResulting node.
nodeIdNodeId在启用并请求文档的情况下,仅返回给定坐标处的节点ID。
ENId of the node at given coordinates, only when enabled and requested document.

🔨DOM.getNodesForSubtreeByStyle🧪

在子树中查找具有指定计算样式的节点。

EN
Finds nodes with a given computed style in a subtree.
参数必填标记类型描述原文
nodeId✔️NodeId指向子树根的节点ID。
ENNode ID pointing to the root of a subtree.
computedStyles✔️array[CSSComputedStyleProperty]用于筛选节点的样式(如果任何属性匹配,则包含节点)。
ENThe style to filter nodes by (includes nodes if any of properties matches).
pierceboolean是否在返回结果时遍历同一目标中的 iframe 和 shadow root(默认为 false)。
ENWhether or not iframes and shadow roots in the same target should be traversed when returning the results (default is false).
返回对象类型描述原文
nodeIdsarray[NodeId]结果节点。
ENResulting nodes.

🔨DOM.getNodeStackTraces🧪

获取与节点关联的堆栈跟踪。截至目前,仅提供节点创建时的堆栈跟踪。

EN
Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation.
参数必填标记类型描述原文
nodeId✔️NodeId获取堆栈跟踪的节点ID。
ENId of the node to get stack traces for.
返回对象类型描述原文
creationRuntime.StackTrace创建堆栈跟踪(如果可用)。
ENCreation stack trace, if available.

🔨DOM.getQueryingDescendantsForContainer🧪

返回一个容器查询容器的后代元素,这些后代元素针对该容器设置了容器查询。

EN
Returns the descendants of a container query container that have container queries against this container.
参数必填标记类型描述原文
nodeId✔️NodeId从其中查找查询后代的容器节点ID。
ENId of the container node to find querying descendants from.
返回对象类型描述原文
nodeIdsarray[NodeId]针对给定容器的具有容器查询的后代节点。
ENDescendant nodes with container queries against the given container.

🔨DOM.getRelayoutBoundary🧪

返回最近祖先的id,该祖先是一个重新布局边界。

EN
Returns the id of the nearest ancestor that is a relayout boundary.
参数必填标记类型描述原文
nodeId✔️NodeId节点的ID。
ENId of the node.
返回对象类型描述原文
nodeIdNodeId给定节点的重排边界节点ID。
ENRelayout boundary node id for the given node.

🔨DOM.getSearchResults🧪

从给定标识符的搜索结果中,返回从指定fromIndextoIndex的搜索结果。

EN
Returns search results from given fromIndex to given toIndex from the search with the given identifier.
参数必填标记类型描述原文
searchId✔️string唯一的搜索会话标识符。
ENUnique search session identifier.
fromIndex✔️integer要返回的搜索结果的起始索引。
ENStart index of the search result to be returned.
toIndex✔️integer要返回的搜索结果的结束索引。
ENEnd index of the search result to be returned.
返回对象类型描述原文
nodeIdsarray[NodeId]搜索结果节点的ID。
ENIds of the search result nodes.

🔨DOM.getTopLayerElements🧪

返回当前顶层元素的NodeId。顶层元素在视口内渲染得最靠近用户,因此其元素始终显示在所有其他内容之上。

EN
Returns NodeIds of current top layer elements. Top layer is rendered closest to the user within a viewport, therefore its elements always appear on top of all other content.
返回对象类型描述原文
nodeIdsarray[NodeId]顶层元素的节点ID
ENNodeIds of top layer elements

🔨DOM.markUndoableState🧪

标记最后一个可撤销状态。

EN
Marks last undoable state.

🔨DOM.performSearch🧪

在DOM树中搜索给定的字符串。使用getSearchResults访问搜索结果,或使用cancelSearch结束此搜索会话。

EN
Searches for a given string in the DOM tree. Use getSearchResults to access search results or cancelSearch to end this search session.
参数必填标记类型描述原文
query✔️string纯文本或查询选择器或XPath搜索查询。
ENPlain text or query selector or XPath search query.
includeUserAgentShadowDOMboolean在用户代理影子DOM中搜索。
ENTrue to search in user agent shadow DOM.
返回对象类型描述原文
searchIdstring唯一搜索会话标识符。
ENUnique search session identifier.
resultCountinteger搜索结果数量。
ENNumber of search results.

🔨DOM.pushNodeByPathToFrontend🧪

根据其路径将节点发送给调用者的请求。 // FIXME,使用XPath

EN
Requests that the node is sent to the caller given its path. // FIXME, use XPath
参数必填标记类型描述原文
path✔️string专有格式中的节点路径。
ENPath to node in the proprietary format.
返回对象类型描述原文
nodeIdNodeId给定路径的节点Id。
ENId of the node for given path.

🔨DOM.pushNodesByBackendIdsToFrontend🧪

根据其后端节点ID,请求将一批节点发送给调用者。

EN
Requests that a batch of nodes is sent to the caller given their backend node ids.
参数必填标记类型描述原文
backendNodeIds✔️array[BackendNodeId]后端节点ID的数组。
ENThe array of backend node ids.
返回对象类型描述原文
nodeIdsarray[NodeId]与backendNodeIds中指定的后端节点ID相对应的已推送节点ID数组。
ENThe array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds.

🔨DOM.redo🧪

重做上一个已撤销的操作。

EN
Re-does the last undone action.

🔨DOM.setInspectedNode🧪

启用控制台通过$x引用具有给定ID的节点(有关$x函数的更多详细信息,请参阅命令行API)。

EN
Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).
参数必填标记类型描述原文
nodeId✔️NodeIdDOM节点ID,可通过$x命令行API访问。
ENDOM node id to be accessible by means of $x command line API.

🔨DOM.setNodeStackTracesEnabled🧪

设置是否应为节点捕获堆栈跟踪。参见 Node.getNodeStackTraces。默认情况下为禁用。

EN
Sets if stack traces should be captured for Nodes. See Node.getNodeStackTraces. Default is disabled.
参数必填标记类型描述原文
enable✔️boolean启用或禁用。
ENEnable or disable.

🔨DOM.undo🧪

撤销上次执行的操作。

EN
Undoes the last performed action.

✅️️ Events

👋DOM.attributeModified

Element的属性被修改时触发。

EN
Fired when Element's attribute is modified.
参数必填标记类型描述原文
nodeId✔️NodeId已更改节点的Id。
ENId of the node that has changed.
name✔️string属性名称。
ENAttribute name.
value✔️string属性值。
ENAttribute value.

👋DOM.attributeRemoved

Element的属性被移除时触发。

EN
Fired when Element's attribute is removed.
参数必填标记类型描述原文
nodeId✔️NodeId节点已更改的Id。
ENId of the node that has changed.
name✔️string属性名称。
ENA ttribute name.

👋DOM.characterDataModified

镜像 DOMCharacterDataModified 事件。

EN
Mirrors DOMCharacterDataModified event.
参数必填标记类型描述原文
nodeId✔️NodeId发生更改的节点的ID。
ENId of the node that has changed.
characterData✔️string新文本值。
ENNew text value.

👋DOM.childNodeCountUpdated

Container的子节点数量发生变化时触发。

EN
Fired when Container's child node count has changed.
参数必填标记类型描述原文
nodeId✔️NodeId已更改节点的ID。
ENId of the node that has changed.
childNodeCount✔️integer新节点数量。
ENNew node count.

👋DOM.childNodeInserted

镜像 DOMNodeInserted 事件。

EN
Mirrors DOMNodeInserted event.
参数必填标记类型描述原文
parentNodeId✔️NodeId发生更改的节点的Id。
ENId of the node that has changed.
previousNodeId✔️NodeId前一个兄弟节点的标识符。
ENId of the previous sibling.
node✔️Node已插入节点数据。
ENInserted node data.

👋DOM.childNodeRemoved

镜像 DOMNodeRemoved 事件。

EN
Mirrors DOMNodeRemoved event.
参数必填标记类型描述原文
parentNodeId✔️NodeId父级ID。
ENParent id.
nodeId✔️NodeId已被移除的节点的Id。
ENId of the node that has been removed.

👋DOM.documentUpdated

Document 完全更新时触发。节点 ID 不再有效。

EN
Fired when Document has been totally updated. Node ids are no longer valid.

👋DOM.setChildNodes

当后端希望向客户端提供缺失的DOM结构时触发。这发生在大多数请求节点ID的调用中。

EN
Fired when backend wants to provide client with the missing DOM structure. This happens upon most of the calls requesting node ids.
参数必填标记类型描述原文
parentId✔️NodeId父节点ID,用于填充子节点。
ENParent node id to populate with children.
nodes✔️array[Node]子节点数组。
ENChild nodes array.

👋DOM.adoptedStyleSheetsModified🧪

Element的adoptedStyleSheets被修改时触发。

EN
Fired when Element's adoptedStyleSheets are modified.
参数必填标记类型描述原文
nodeId✔️NodeId节点已更改的Id。
ENId of the node that has changed.
adoptedStyleSheets✔️🧪array[StyleSheetId]新采用的样式表数组。
ENNew adoptedStyleSheets array.

👋DOM.adRelatedStateUpdated🧪

当节点的广告相关状态发生变化时触发。

EN
Fired when a node's ad related state changes.
参数必填标记类型描述原文
nodeId✔️DOM.NodeId节点的id。
ENThe id of the node.
isAdRelated✔️boolean如果节点与广告相关。
ENIf the node is ad related.

👋DOM.affectedByStartingStylesFlagUpdated🧪

当节点的起始样式发生变化时触发。

EN
Fired when a node's starting styles changes.
参数必填标记类型描述原文
nodeId✔️DOM.NodeId节点的id。
ENThe id of the node.
affectedByStartingStyles✔️boolean如果节点具有起始样式。
ENIf the node has starting styles.

👋DOM.distributedNodesUpdated🧪

当分布发生变化时调用。

EN
Called when distribution is changed.
参数必填标记类型描述原文
insertionPointId✔️NodeId插入点,分布式节点在此处被更新。
ENInsertion point where distributed nodes were updated.
distributedNodes✔️array[BackendNode]给定插入点的分布式节点。
ENDistributed nodes for given insertion point.

👋DOM.inlineStyleInvalidated🧪

当通过CSS属性修改更改Element的内联样式时触发。

EN
Fired when Element's inline style is modified via a CSS property modification.
参数必填标记类型描述原文
nodeIds✔️array[NodeId]''和``内的内容保持不变,节点内联样式失效的ID。
ENIds of the nodes for which the inline styles have been invalidated.

👋DOM.pseudoElementAdded🧪

当伪元素被添加到元素时调用。

EN
Called when a pseudo element is added to an element.
参数必填标记类型描述原文
parentId✔️NodeId伪元素的父元素ID。
ENPseudo element's parent element id.
pseudoElement✔️Node新增的伪元素。
ENThe added pseudo element.

👋DOM.pseudoElementRemoved🧪

当伪元素从元素中移除时调用。

EN
Called when a pseudo element is removed from an element.
参数必填标记类型描述原文
parentId✔️NodeId伪元素的父元素ID。
ENPseudo element's parent element id.
pseudoElementId✔️NodeId被移除的伪元素ID。
ENThe removed pseudo element id.

👋DOM.scrollableFlagUpdated🧪

当节点的可滚动状态发生变化时触发。

EN
Fired when a node's scrollability state changes.
参数必填标记类型描述原文
nodeId✔️DOM.NodeId节点的id。
ENThe id of the node.
isScrollable✔️boolean如果节点是可滚动的。
ENIf the node is scrollable.

👋DOM.shadowRootPopped🧪

当影子根从元素中弹出时调用。

EN
Called when shadow root is popped from the element.
参数必填标记类型描述原文
hostId✔️NodeId宿主元素ID。
ENHost element id.
rootId✔️NodeIdShadow root id.
ENShadow root id.

👋DOM.shadowRootPushed🧪

当影子根节点被推入元素时调用。

EN
Called when shadow root is pushed into the element.
参数必填标记类型描述原文
hostId✔️NodeId宿主元素ID。
ENHost element id.
root✔️NodeShadow root。
ENShadow root.

👋DOM.topLayerElementsUpdated🧪

当顶层元素发生改变时调用。

EN
Called when top layer elements are changed.

✅️️ Types

📌DOM.BackendNode

具有友好名称的后端节点。

EN
Backend node with a friendly name.

返回类型:object

属性必填标记类型描述原文
nodeType✔️integerNode的nodeType。
ENNode's nodeType.
nodeName✔️stringNode 的 nodeName。
ENNode's nodeName.
backendNodeId✔️BackendNodeId

📌DOM.BackendNodeId

用于引用可能尚未推送到前端的节点的唯一DOM节点标识符。

EN
Unique DOM node identifier used to reference a node that may not have been pushed to the front-end.

返回类型:integer


📌DOM.BoxModel

盒子模型。

EN
Box model.

返回类型:object

属性必填标记类型描述原文
content✔️Quad内容框
ENContent box
padding✔️QuadPadding box
ENPadding box
border✔️Quad边框盒
ENBorder box
margin✔️QuadMargin box
ENMargin box
width✔️integer节点宽度
ENNode width
height✔️integer节点高度
ENNode height
shapeOutsideShapeOutsideInfo形状外部坐标
ENShape outside coordinates

📌DOM.CompatibilityMode

文档兼容模式。
允许的取值:QuirksModeLimitedQuirksModeNoQuirksMode

EN
Document compatibility mode.
Allowed Values: QuirksMode, LimitedQuirksMode, NoQuirksMode

返回类型:string


📌DOM.CSSComputedStyleProperty

返回类型:object

属性必填标记类型描述原文
name✔️string计算样式属性名称。
ENComputed style property name.
value✔️string计算后的样式属性值。
ENComputed style property value.

📌DOM.DetachedElementInfo

一个用于存储分离树的顶层节点及其保留后代数组的结构。

EN
A structure to hold the top-level node of a detached tree and an array of its retained descendants.

返回类型:object

属性必填标记类型描述原文
treeNode✔️Node
retainedNodeIds✔️array[NodeId]

📌DOM.LogicalAxes

ContainerSelector 逻辑轴
允许的值:InlineBlockBoth

EN
ContainerSelector logical axes
Allowed Values: Inline, Block, Both

返回类型:string


📌DOM.Node

DOM交互是通过代表实际DOM节点的镜像对象实现的。DOMNode是一个基础的节点镜像类型。

EN
DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type.

返回类型:object

属性必填标记类型描述原文
nodeId✔️NodeId作为nodeId传递给其余DOM消息的节点标识符。后端仅会推送具有给定id的节点一次。它知晓所有被请求的节点,并且只会为客户端已知的节点触发DOM事件。
ENNode identifier that is passed into the rest of the DOM messages as the nodeId. Backend will only push node with given id once. It is aware of all requested nodes and will only fire DOM events for nodes known to the client.
parentIdNodeId父节点的ID(如果存在)。
ENThe id of the parent node if any.
backendNodeId✔️BackendNodeId此节点的后端节点ID。
ENThe BackendNodeId for this node.
nodeType✔️integerNode的nodeType。
ENNode's nodeType.
nodeName✔️stringNode的nodeName。
ENNode's nodeName.
localName✔️stringNode 的 localName。
ENNode's localName.
nodeValue✔️stringNode的nodeValue。
ENNode's nodeValue.
childNodeCountintegerContainer 节点的子节点数量。
ENChild count for Container nodes.
childrenarray[Node]当使用children请求时,此节点的子节点。
ENChild nodes of this node when requested with children.
attributesarray[string]Element节点的属性以扁平数组的形式呈现,即[name1, value1, name2, value2]
ENAttributes of the Element node in the form of flat array [name1, value1, name2, value2].
documentURLstringDocumentFrameOwner 节点指向的文档 URL。
ENDocument URL that Document or FrameOwner node points to.
baseURLstringDocumentFrameOwner 节点用于 URL 补全的基础 URL。
ENBase URL that Document or FrameOwner node uses for URL completion.
publicIdstringDocumentType的publicId。
ENDocumentType's publicId.
systemIdstringDocumentType 的 systemId。
ENDocumentType's systemId.
internalSubsetstringDocumentType 的 internalSubset。
ENDocumentType's internalSubset.
xmlVersionstringDocument的XML版本,针对XML文档的情况。
ENDocument's XML version in case of XML documents.
namestringAttr 的名称。
ENAttr's name.
valuestringAttr的值。
ENAttr's value.
pseudoTypePseudoType该节点的伪元素类型。
ENPseudo element type for this node.
pseudoIdentifierstring此节点的伪元素标识符。仅当存在有效的伪类型时才会显示。
ENPseudo element identifier for this node. Only present if there is a valid pseudoType.
shadowRootTypeShadowRootTypeShadow root 类型。
ENShadow root type.
frameIdPage.FrameId框架所有者元素的框架ID。
ENFrame ID for frame owner elements.
contentDocumentNode框架所有者元素的内容文档。
ENContent document for frame owner elements.
shadowRootsarray[Node]给定元素宿主的影子根列表。
ENShadow root list for given element host.
templateContentNode模板元素的内容文档片段。
ENContent document fragment for template elements.
pseudoElementsarray[Node]与此节点关联的伪元素。
ENPseudo elements associated with this node.
importedDocument❌️Node已弃用,因为HTML Imports API已被移除(crbug.com/937746)。此属性曾用于返回HTMLImport链接的导入文档。该属性现在始终为undefined。
ENDeprecated, as the HTML Imports API has been removed (crbug.com/937746). This property used to return the imported document for the HTMLImport links. The property is always undefined now.
distributedNodesarray[BackendNode]给定插入点的分布式节点。
ENDistributed nodes for given insertion point.
isSVGboolean节点是否为SVG。
ENWhether the node is SVG.
compatibilityModeCompatibilityMode
assignedSlotBackendNode
isScrollable🧪boolean
affectedByStartingStyles🧪boolean
adoptedStyleSheets🧪array[StyleSheetId]
isAdRelated🧪boolean

📌DOM.NodeId

唯一的DOM节点标识符。

EN
Unique DOM node identifier.

返回类型:integer


📌DOM.PhysicalAxes

ContainerSelector物理轴
允许的值:HorizontalVerticalBoth

EN
ContainerSelector physical axes
Allowed Values: Horizontal, Vertical, Both

返回类型:string


📌DOM.PseudoType

伪元素类型。
允许的值:first-linefirst-lettercheckmarkbeforeafterpicker-iconinterest-hintmarkerbackdropcolumnselectionsearch-texttarget-textspelling-errorgrammar-errorhighlightfirst-line-inheritedscroll-markerscroll-marker-groupscroll-buttonscrollbarscrollbar-thumbscrollbar-buttonscrollbar-trackscrollbar-track-piecescrollbar-cornerresizerinput-list-buttonview-transitionview-transition-groupview-transition-image-pairview-transition-group-childrenview-transition-oldview-transition-newplaceholderfile-selector-buttondetails-contentpickerpermission-iconoverscroll-area-parent

EN
Pseudo element type.
Allowed Values: first-line, first-letter, checkmark, before, after, picker-icon, interest-hint, marker, backdrop, column, selection, search-text, target-text, spelling-error, grammar-error, highlight, first-line-inherited, scroll-marker, scroll-marker-group, scroll-button, scrollbar, scrollbar-thumb, scrollbar-button, scrollbar-track, scrollbar-track-piece, scrollbar-corner, resizer, input-list-button, view-transition, view-transition-group, view-transition-image-pair, view-transition-group-children, view-transition-old, view-transition-new, placeholder, file-selector-button, details-content, picker, permission-icon, overscroll-area-parent

返回类型:string


📌DOM.Quad

一组四边形顶点数组,每个点的 x 坐标后紧跟 y 坐标,点按顺时针方向排列。

EN
An array of quad vertices, x immediately followed by y for each point, points clock-wise.

返回类型:array


📌DOM.Rect

Rectangle.

EN
Rectangle.

返回类型:object

属性必填标记类型描述原文
x✔️numberX坐标
ENX coordinate
y✔️numberY 坐标
ENY coordinate
width✔️number矩形宽度
ENRectangle width
height✔️number矩形高度
ENRectangle height

📌DOM.RGBA

一个包含RGBA颜色的结构体。

EN
A structure holding an RGBA color.

返回类型:object

属性必填标记类型描述原文
r✔️integer红色分量,范围在 [0-255] 之间。
ENThe red component, in the [0-255] range.
g✔️integer绿色分量,范围在[0-255]之间。
ENThe green component, in the [0-255] range.
b✔️integer蓝色分量,在 [0-255] 范围内。
ENThe blue component, in the [0-255] range.
anumberalpha 分量,范围在 [0-1] 之间(默认值:1)。
ENThe alpha component, in the [0-1] range (default: 1).

📌DOM.ScrollOrientation

物理滚动方向
允许的取值:horizontalvertical

EN
Physical scroll orientation
Allowed Values: horizontal, vertical

返回类型:string


📌DOM.ShadowRootType

Shadow root 类型。
允许的值:user-agentopenclosed

EN
Shadow root type.
Allowed Values: user-agent, open, closed

返回类型:string


📌DOM.ShapeOutsideInfo

CSS Shape Outside 详细信息。

EN
CSS Shape Outside details.

返回类型:object

属性必填标记类型描述原文
bounds✔️Quad形状边界
ENShape bounds
shape✔️array[any]形状坐标详情
ENShape coordinate details
marginShape✔️array[any]Margin shape bounds
ENMargin shape bounds

📌DOM.StyleSheetId

CSS样式表的唯一标识符。

EN
Unique identifier for a CSS stylesheet.

返回类型:string