DOMApi class
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.
Constructors
- DOMApi(Client _client)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
onAttributeModified
→ Stream<
AttributeModifiedEvent> -
Fired when
Element's attribute is modified.no setter -
onAttributeRemoved
→ Stream<
AttributeRemovedEvent> -
Fired when
Element's attribute is removed.no setter -
onCharacterDataModified
→ Stream<
CharacterDataModifiedEvent> -
Mirrors
DOMCharacterDataModifiedevent.no setter -
onChildNodeCountUpdated
→ Stream<
ChildNodeCountUpdatedEvent> -
Fired when
Container's child node count has changed.no setter -
onChildNodeInserted
→ Stream<
ChildNodeInsertedEvent> -
Mirrors
DOMNodeInsertedevent.no setter -
onChildNodeRemoved
→ Stream<
ChildNodeRemovedEvent> -
Mirrors
DOMNodeRemovedevent.no setter -
onDistributedNodesUpdated
→ Stream<
DistributedNodesUpdatedEvent> -
Called when distribution is changed.
no setter
-
onDocumentUpdated
→ Stream<
void> -
Fired when
Documenthas been totally updated. Node ids are no longer valid.no setter -
onInlineStyleInvalidated
→ Stream<
List< NodeId> > -
Fired when
Element's inline style is modified via a CSS property modification.no setter -
onPseudoElementAdded
→ Stream<
PseudoElementAddedEvent> -
Called when a pseudo element is added to an element.
no setter
-
onPseudoElementRemoved
→ Stream<
PseudoElementRemovedEvent> -
Called when a pseudo element is removed from an element.
no setter
-
onScrollableFlagUpdated
→ Stream<
ScrollableFlagUpdatedEvent> -
Fired when a node's scrollability state changes.
no setter
-
onSetChildNodes
→ Stream<
SetChildNodesEvent> -
Fired when backend wants to provide client with the missing DOM structure. This happens upon
most of the calls requesting node ids.
no setter
-
onShadowRootPopped
→ Stream<
ShadowRootPoppedEvent> -
Called when shadow root is popped from the element.
no setter
-
onShadowRootPushed
→ Stream<
ShadowRootPushedEvent> -
Called when shadow root is pushed into the element.
no setter
-
onTopLayerElementsUpdated
→ Stream<
void> -
Called when top layer elements are changed.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
collectClassNamesFromSubtree(
NodeId nodeId) → Future< List< String> > -
Collects class names for the node with given id and all of it's child nodes.
nodeIdId of the node to collect class names. Returns: Class name list. -
copyTo(
NodeId nodeId, NodeId targetNodeId, {NodeId? insertBeforeNodeId}) → Future< NodeId> -
Creates a deep copy of the specified node and places it into the target container before the
given anchor.
nodeIdId of the node to copy.targetNodeIdId of the element to drop the copy into.insertBeforeNodeIdDrop the copy before this node (if absent, the copy becomes the last child oftargetNodeId). Returns: Id of the node clone. -
describeNode(
{NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId, int? depth, bool? pierce}) → Future< Node> -
Describes node given its id, does not require domain to be enabled. Does not start tracking any
objects, can be used for automation.
nodeIdIdentifier of the node.backendNodeIdIdentifier of the backend node.objectIdJavaScript object id of the node wrapper.depthThe maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.pierceWhether or not iframes and shadow roots should be traversed when returning the subtree (default is false). Returns: Node description. -
disable(
) → Future< void> - Disables DOM agent for the given page.
-
discardSearchResults(
String searchId) → Future< void> -
Discards search results from the session with the given id.
getSearchResultsshould no longer be called for that search.searchIdUnique search session identifier. -
enable(
{String? includeWhitespace}) → Future< void> -
Enables DOM agent for the given page.
includeWhitespaceWhether to include whitespaces in the children array of returned Nodes. -
focus(
{NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId}) → Future< void> -
Focuses the given element.
nodeIdIdentifier of the node.backendNodeIdIdentifier of the backend node.objectIdJavaScript object id of the node wrapper. -
forceShowPopover(
NodeId nodeId, bool enable) → Future< List< NodeId> > -
When enabling, this API force-opens the popover identified by nodeId
and keeps it open until disabled.
nodeIdId of the popover HTMLElementenableIf true, opens the popover and keeps it open. If false, closes the popover if it was previously force-opened. Returns: List of popovers that were closed in order to respect popover stacking order. -
getAnchorElement(
NodeId nodeId, {String? anchorSpecifier}) → Future< NodeId> -
Returns the target anchor element of the given anchor query according to
https://www.w3.org/TR/css-anchor-position-1/#target.
nodeIdId of the positioned element from which to find the anchor.anchorSpecifierAn 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. Returns: The anchor element of the given anchor query. -
getAttributes(
NodeId nodeId) → Future< List< String> > -
Returns attributes for the specified node.
nodeIdId of the node to retrieve attributes for. Returns: An interleaved array of node attribute names and values. -
getBoxModel(
{NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId}) → Future< BoxModel> -
Returns boxes for the given node.
nodeIdIdentifier of the node.backendNodeIdIdentifier of the backend node.objectIdJavaScript object id of the node wrapper. Returns: Box model for the node. -
getContainerForNode(
NodeId nodeId, {String? containerName, PhysicalAxes? physicalAxes, LogicalAxes? logicalAxes, bool? queriesScrollState, bool? queriesAnchored}) → Future< NodeId> - 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. Returns: The container node for the given node, or null if not found.
-
getContentQuads(
{NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId}) → Future< List< Quad> > -
Returns quads that describe node position on the page. This method
might return multiple quads for inline nodes.
nodeIdIdentifier of the node.backendNodeIdIdentifier of the backend node.objectIdJavaScript object id of the node wrapper. Returns: Quads that describe node layout relative to viewport. -
getDetachedDomNodes(
) → Future< List< DetachedElementInfo> > - Returns list of detached nodes Returns: The list of detached nodes
-
getDocument(
{int? depth, bool? pierce}) → Future< Node> -
Returns the root DOM node (and optionally the subtree) to the caller.
Implicitly enables the DOM domain events for the current target.
depthThe maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.pierceWhether or not iframes and shadow roots should be traversed when returning the subtree (default is false). Returns: Resulting node. -
getElementByRelation(
NodeId nodeId, String relation) → Future< NodeId> -
Returns the NodeId of the matched element according to certain relations.
nodeIdId of the node from which to query the relation.relationType of relation to get. Returns: NodeId of the element matching the queried relation. -
getFileInfo(
RemoteObjectId objectId) → Future< String> -
Returns file information for the given
File wrapper.
objectIdJavaScript object id of the node wrapper. -
getFlattenedDocument(
{int? depth, bool? pierce}) → Future< List< Node> > -
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.
depthThe maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.pierceWhether or not iframes and shadow roots should be traversed when returning the subtree (default is false). Returns: Resulting node. -
getFrameOwner(
FrameId frameId) → Future< GetFrameOwnerResult> - Returns iframe node that owns iframe with the given domain.
-
getNodeForLocation(
int x, int y, {bool? includeUserAgentShadowDOM, bool? ignorePointerEventsNone}) → Future< GetNodeForLocationResult> -
Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is
either returned or not.
xX coordinate.yY coordinate.includeUserAgentShadowDOMFalse to skip to the nearest non-UA shadow root ancestor (default: false).ignorePointerEventsNoneWhether to ignore pointer-events: none on elements and hit test them. -
getNodesForSubtreeByStyle(
NodeId nodeId, List< CSSComputedStyleProperty> computedStyles, {bool? pierce}) → Future<List< NodeId> > -
Finds nodes with a given computed style in a subtree.
nodeIdNode ID pointing to the root of a subtree.computedStylesThe style to filter nodes by (includes nodes if any of properties matches).pierceWhether or not iframes and shadow roots in the same target should be traversed when returning the results (default is false). Returns: Resulting nodes. -
getNodeStackTraces(
NodeId nodeId) → Future< StackTraceData> -
Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation.
nodeIdId of the node to get stack traces for. Returns: Creation stack trace, if available. -
getOuterHTML(
{NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId, bool? includeShadowDOM}) → Future< String> -
Returns node's HTML markup.
nodeIdIdentifier of the node.backendNodeIdIdentifier of the backend node.objectIdJavaScript object id of the node wrapper.includeShadowDOMInclude all shadow roots. Equals to false if not specified. Returns: Outer HTML markup. -
getQueryingDescendantsForContainer(
NodeId nodeId) → Future< List< NodeId> > -
Returns the descendants of a container query container that have
container queries against this container.
nodeIdId of the container node to find querying descendants from. Returns: Descendant nodes with container queries against the given container. -
getRelayoutBoundary(
NodeId nodeId) → Future< NodeId> -
Returns the id of the nearest ancestor that is a relayout boundary.
nodeIdId of the node. Returns: Relayout boundary node id for the given node. -
getSearchResults(
String searchId, int fromIndex, int toIndex) → Future< List< NodeId> > -
Returns search results from given
fromIndexto giventoIndexfrom the search with the given identifier.searchIdUnique search session identifier.fromIndexStart index of the search result to be returned.toIndexEnd index of the search result to be returned. Returns: Ids of the search result nodes. -
getTopLayerElements(
) → Future< List< NodeId> > - 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. Returns: NodeIds of top layer elements
-
hideHighlight(
) → Future< void> - Hides any highlight.
-
highlightNode(
) → Future< void> - Highlights DOM node.
-
highlightRect(
) → Future< void> - Highlights given rectangle.
-
markUndoableState(
) → Future< void> - Marks last undoable state.
-
moveTo(
NodeId nodeId, NodeId targetNodeId, {NodeId? insertBeforeNodeId}) → Future< NodeId> -
Moves node into the new container, places it before the given anchor.
nodeIdId of the node to move.targetNodeIdId of the element to drop the moved node into.insertBeforeNodeIdDrop node before this one (if absent, the moved node becomes the last child oftargetNodeId). Returns: New id of the moved node. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
performSearch(
String query, {bool? includeUserAgentShadowDOM}) → Future< PerformSearchResult> -
Searches for a given string in the DOM tree. Use
getSearchResultsto access search results orcancelSearchto end this search session.queryPlain text or query selector or XPath search query.includeUserAgentShadowDOMTrue to search in user agent shadow DOM. -
pushNodeByPathToFrontend(
String path) → Future< NodeId> -
Requests that the node is sent to the caller given its path. // FIXME, use XPath
pathPath to node in the proprietary format. Returns: Id of the node for given path. -
pushNodesByBackendIdsToFrontend(
List< BackendNodeId> backendNodeIds) → Future<List< NodeId> > -
Requests that a batch of nodes is sent to the caller given their backend node ids.
backendNodeIdsThe array of backend node ids. Returns: The array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds. -
querySelector(
NodeId nodeId, String selector) → Future< NodeId> -
Executes
querySelectoron a given node.nodeIdId of the node to query upon.selectorSelector string. Returns: Query selector result. -
querySelectorAll(
NodeId nodeId, String selector) → Future< List< NodeId> > -
Executes
querySelectorAllon a given node.nodeIdId of the node to query upon.selectorSelector string. Returns: Query selector result. -
redo(
) → Future< void> - Re-does the last undone action.
-
removeAttribute(
NodeId nodeId, String name) → Future< void> -
Removes attribute with given name from an element with given id.
nodeIdId of the element to remove attribute from.nameName of the attribute to remove. -
removeNode(
NodeId nodeId) → Future< void> -
Removes node with given id.
nodeIdId of the node to remove. -
requestChildNodes(
NodeId nodeId, {int? depth, bool? pierce}) → Future< void> -
Requests that children of the node with given id are returned to the caller in form of
setChildNodesevents where not only immediate children are retrieved, but all children down to the specified depth.nodeIdId of the node to get children for.depthThe maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.pierceWhether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false). -
requestNode(
RemoteObjectId objectId) → Future< NodeId> -
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
setChildNodesnotifications.objectIdJavaScript object id to convert into node. Returns: Node id for given object. -
resolveNode(
{NodeId? nodeId, BackendNodeId? backendNodeId, String? objectGroup, ExecutionContextId? executionContextId}) → Future< RemoteObject> -
Resolves the JavaScript node object for a given NodeId or BackendNodeId.
nodeIdId of the node to resolve.backendNodeIdBackend identifier of the node to resolve.objectGroupSymbolic group name that can be used to release multiple objects.executionContextIdExecution context in which to resolve the node. Returns: JavaScript object wrapper for given node. -
scrollIntoViewIfNeeded(
{NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId, Rect? rect}) → Future< void> -
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.
nodeIdIdentifier of the node.backendNodeIdIdentifier of the backend node.objectIdJavaScript object id of the node wrapper.rectThe 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. -
setAttributesAsText(
NodeId nodeId, String text, {String? name}) → Future< void> -
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.
nodeIdId of the element to set attributes for.textText with a number of attributes. Will parse this text using HTML parser.nameAttribute name to replace with new attributes derived from text in case text parsed successfully. -
setAttributeValue(
NodeId nodeId, String name, String value) → Future< void> -
Sets attribute for an element with given id.
nodeIdId of the element to set attribute for.nameAttribute name.valueAttribute value. -
setFileInputFiles(
List< String> files, {NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId}) → Future<void> -
Sets files for the given file input element.
filesArray of file paths to set.nodeIdIdentifier of the node.backendNodeIdIdentifier of the backend node.objectIdJavaScript object id of the node wrapper. -
setInspectedNode(
NodeId nodeId) → Future< void> -
Enables console to refer to the node with given id via $x (see Command Line API for more details
$x functions).
nodeIdDOM node id to be accessible by means of $x command line API. -
setNodeName(
NodeId nodeId, String name) → Future< NodeId> -
Sets node name for a node with given id.
nodeIdId of the node to set name for.nameNew node's name. Returns: New node's id. -
setNodeStackTracesEnabled(
bool enable) → Future< void> -
Sets if stack traces should be captured for Nodes. See
Node.getNodeStackTraces. Default is disabled.enableEnable or disable. -
setNodeValue(
NodeId nodeId, String value) → Future< void> -
Sets node value for a node with given id.
nodeIdId of the node to set value for.valueNew node's value. -
setOuterHTML(
NodeId nodeId, String outerHTML) → Future< void> -
Sets node HTML markup, returns new node id.
nodeIdId of the node to set markup for.outerHTMLOuter HTML markup to set. -
toString(
) → String -
A string representation of this object.
inherited
-
undo(
) → Future< void> - Undoes the last performed action.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited