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 DOMCharacterDataModified event.
no setter
onChildNodeCountUpdated Stream<ChildNodeCountUpdatedEvent>
Fired when Container's child node count has changed.
no setter
onChildNodeInserted Stream<ChildNodeInsertedEvent>
Mirrors DOMNodeInserted event.
no setter
onChildNodeRemoved Stream<ChildNodeRemovedEvent>
Mirrors DOMNodeRemoved event.
no setter
onDistributedNodesUpdated Stream<DistributedNodesUpdatedEvent>
Called when distribution is changed.
no setter
onDocumentUpdated Stream<void>
Fired when Document has 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
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. nodeId Id 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. nodeId Id of the node to copy. targetNodeId Id of the element to drop the copy into. insertBeforeNodeId Drop the copy before this node (if absent, the copy becomes the last child of targetNodeId). 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. nodeId Identifier of the node. backendNodeId Identifier of the backend node. objectId JavaScript object id of the node wrapper. depth The 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 Whether 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. getSearchResults should no longer be called for that search. searchId Unique search session identifier.
enable({String? includeWhitespace}) Future<void>
Enables DOM agent for the given page. includeWhitespace Whether to include whitespaces in the children array of returned Nodes.
focus({NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId}) Future<void>
Focuses the given element. nodeId Identifier of the node. backendNodeId Identifier of the backend node. objectId JavaScript object id of the node wrapper.
getAttributes(NodeId nodeId) Future<List<String>>
Returns attributes for the specified node. nodeId Id of the node to retrieve attibutes 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. nodeId Identifier of the node. backendNodeId Identifier of the backend node. objectId JavaScript object id of the node wrapper. Returns: Box model for the node.
getContainerForNode(NodeId nodeId, {String? containerName, PhysicalAxes? physicalAxes, LogicalAxes? logicalAxes}) Future<NodeId>
Returns the query container of the given node based on container query conditions: containerName, physical, and logical axes. If no axes are provided, 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. nodeId Identifier of the node. backendNodeId Identifier of the backend node. objectId JavaScript object id of the node wrapper. Returns: Quads that describe node layout relative to viewport.
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. depth The 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 Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false). Returns: Resulting node.
getFileInfo(RemoteObjectId objectId) Future<String>
Returns file information for the given File wrapper. objectId JavaScript 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. depth The 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 Whether 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. x X coordinate. y Y coordinate. includeUserAgentShadowDOM False to skip to the nearest non-UA shadow root ancestor (default: false). ignorePointerEventsNone Whether 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. nodeId Node ID pointing to the root of a subtree. computedStyles The style to filter nodes by (includes nodes if any of properties matches). pierce Whether 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. nodeId Id of the node to get stack traces for. Returns: Creation stack trace, if available.
getOuterHTML({NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId}) Future<String>
Returns node's HTML markup. nodeId Identifier of the node. backendNodeId Identifier of the backend node. objectId JavaScript object id of the node wrapper. 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. nodeId Id 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. nodeId Id 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 fromIndex to given toIndex from the search with the given identifier. searchId Unique search session identifier. fromIndex Start index of the search result to be returned. toIndex End 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. nodeId Id of the node to move. targetNodeId Id of the element to drop the moved node into. insertBeforeNodeId Drop node before this one (if absent, the moved node becomes the last child of targetNodeId). 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 getSearchResults to access search results or cancelSearch to end this search session. query Plain text or query selector or XPath search query. includeUserAgentShadowDOM True 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 path Path 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. backendNodeIds The 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 querySelector on a given node. nodeId Id of the node to query upon. selector Selector string. Returns: Query selector result.
querySelectorAll(NodeId nodeId, String selector) Future<List<NodeId>>
Executes querySelectorAll on a given node. nodeId Id of the node to query upon. selector Selector 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. nodeId Id of the element to remove attribute from. name Name of the attribute to remove.
removeNode(NodeId nodeId) Future<void>
Removes node with given id. nodeId Id 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 setChildNodes events where not only immediate children are retrieved, but all children down to the specified depth. nodeId Id of the node to get children for. depth The 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 Whether 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 setChildNodes notifications. objectId JavaScript 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. nodeId Id of the node to resolve. backendNodeId Backend identifier of the node to resolve. objectGroup Symbolic group name that can be used to release multiple objects. executionContextId Execution 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. nodeId Identifier of the node. backendNodeId Identifier of the backend node. objectId JavaScript object id of the node wrapper. rect The 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. nodeId Id of the element to set attributes for. text Text with a number of attributes. Will parse this text using HTML parser. name Attribute 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. nodeId Id of the element to set attribute for. name Attribute name. value Attribute value.
setFileInputFiles(List<String> files, {NodeId? nodeId, BackendNodeId? backendNodeId, RemoteObjectId? objectId}) Future<void>
Sets files for the given file input element. files Array of file paths to set. nodeId Identifier of the node. backendNodeId Identifier of the backend node. objectId JavaScript 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). nodeId DOM 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. nodeId Id of the node to set name for. name New 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. enable Enable or disable.
setNodeValue(NodeId nodeId, String value) Future<void>
Sets node value for a node with given id. nodeId Id of the node to set value for. value New node's value.
setOuterHTML(NodeId nodeId, String outerHTML) Future<void>
Sets node HTML markup, returns new node id. nodeId Id of the node to set markup for. outerHTML Outer 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