DOMDomain

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.

Official doc

Functions

Link copied to clipboard
Link copied to clipboard

Fired when Element's attribute is modified.

Link copied to clipboard
Link copied to clipboard

Fired when Element's attribute is removed.

Link copied to clipboard
suspend fun DOMDomain.awaitNodeAbsentBySelector(selector: CssSelector, pollingPeriod: Duration = 200.milliseconds)

Waits until the given selector matches no node in the DOM. Inspects the DOM every pollingPeriod.

Link copied to clipboard
suspend fun DOMDomain.awaitNodeBySelector(selector: CssSelector, pollingPeriodMillis: Long): NodeId

suspend fun DOMDomain.awaitNodeBySelector(selector: CssSelector, pollingPeriod: Duration = 200.milliseconds): NodeId

Retrieves the ID of the node corresponding to the given selector, and retries until there is a match using the given pollingPeriod.

Link copied to clipboard

Mirrors DOMCharacterDataModified event.

Link copied to clipboard

Fired when Container's child node count has changed.

Link copied to clipboard
Link copied to clipboard

Mirrors DOMNodeInserted event.

Link copied to clipboard
Link copied to clipboard

Mirrors DOMNodeRemoved event.

Link copied to clipboard

Collects class names for the node with given id and all of it's child nodes.

Link copied to clipboard
suspend fun copyTo(input: CopyToRequest): CopyToResponse
inline suspend fun copyTo(nodeId: NodeId, targetNodeId: NodeId, optionalArgs: CopyToRequest.Builder.() -> Unit = {}): CopyToResponse

Creates a deep copy of the specified node and places it into the target container before the given anchor.

Link copied to clipboard
inline suspend fun describeNode(optionalArgs: DescribeNodeRequest.Builder.() -> Unit = {}): DescribeNodeResponse

Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation.

Link copied to clipboard
suspend fun disable(): DisableResponse

Disables DOM agent for the given page.

Link copied to clipboard

Discards search results from the session with the given id. getSearchResults should no longer be called for that search.

Link copied to clipboard

Called when distribution is changed.

Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard
inline suspend fun enable(optionalArgs: EnableRequest.Builder.() -> Unit = {}): EnableResponse
suspend fun enable(input: EnableRequest): EnableResponse

Enables DOM agent for the given page.

Link copied to clipboard
fun events(): Flow<DOMEvent>

Subscribes to all events related to this domain.

Link copied to clipboard

Retrieves the ID of the node corresponding to the given selector, or null if not found.

Link copied to clipboard
inline suspend fun focus(optionalArgs: FocusRequest.Builder.() -> Unit = {}): FocusResponse
suspend fun focus(input: FocusRequest): FocusResponse

Focuses the given element.

Link copied to clipboard

Moves the focus to the node corresponding to the given selector, or null if not found.

Link copied to clipboard

Returns attributes for the specified node.

Link copied to clipboard
suspend fun DOMDomain.getAttributeValue(nodeId: NodeId, attributeName: String): String?

Gets the value of the attribute attributeName of the node corresponding to the given nodeId, or null if the attribute was not present on the node.

suspend fun DOMDomain.getAttributeValue(nodeSelector: CssSelector, attributeName: String): String?

Gets the value of the attribute attributeName of the node corresponding to the given nodeSelector, or null if the selector didn't match any node or if the attribute was not present on the node.

Link copied to clipboard
inline suspend fun getBoxModel(optionalArgs: GetBoxModelRequest.Builder.() -> Unit = {}): GetBoxModelResponse

Returns boxes for the given node.

Link copied to clipboard
suspend fun DOMDomain.getBoxModel(nodeId: NodeId): BoxModel

Returns boxes for the node corresponding to the given nodeId.

suspend fun DOMDomain.getBoxModel(selector: CssSelector): BoxModel?

Returns boxes for the node corresponding to the given selector, or null if the selector didn't match any node.

Link copied to clipboard

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.

Link copied to clipboard

Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.

Link copied to clipboard
inline suspend fun getDocument(optionalArgs: GetDocumentRequest.Builder.() -> Unit = {}): GetDocumentResponse

Returns the root DOM node (and optionally the subtree) to the caller. Implicitly enables the DOM domain events for the current target.

Link copied to clipboard

Retrieves the root Node of the current document.

Link copied to clipboard

Retrieves the ID of the root node of the current document.

Link copied to clipboard

Returns file information for the given File wrapper.

Link copied to clipboard

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.

Link copied to clipboard

Returns iframe node that owns iframe with the given domain.

Link copied to clipboard

Retrieves the ID of the node corresponding to the given selector, or throw an exception if not found.

Link copied to clipboard

Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.

Link copied to clipboard
Link copied to clipboard

Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation.

Link copied to clipboard
inline suspend fun getOuterHTML(optionalArgs: GetOuterHTMLRequest.Builder.() -> Unit = {}): GetOuterHTMLResponse

Returns node's HTML markup.

Link copied to clipboard

Returns the descendants of a container query container that have container queries against this container.

Link copied to clipboard

Returns the id of the nearest ancestor that is a relayout boundary.

Link copied to clipboard
suspend fun getSearchResults(searchId: String, fromIndex: Int, toIndex: Int): GetSearchResultsResponse

Returns search results from given fromIndex to given toIndex from the search with the given identifier.

Link copied to clipboard

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.

Link copied to clipboard

Gets the attributes of the node corresponding to the given nodeId.

Gets the attributes of the node corresponding to the given nodeSelector, or null if the selector didn't match any node.

Link copied to clipboard

Hides any highlight.

Link copied to clipboard

Highlights DOM node.

Link copied to clipboard

Highlights given rectangle.

Link copied to clipboard

Fired when Element's inline style is modified via a CSS property modification.

Link copied to clipboard

Marks last undoable state.

Link copied to clipboard
suspend fun moveTo(input: MoveToRequest): MoveToResponse
inline suspend fun moveTo(nodeId: NodeId, targetNodeId: NodeId, optionalArgs: MoveToRequest.Builder.() -> Unit = {}): MoveToResponse

Moves node into the new container, places it before the given anchor.

Link copied to clipboard
inline suspend fun performSearch(query: String, optionalArgs: PerformSearchRequest.Builder.() -> Unit = {}): PerformSearchResponse

Searches for a given string in the DOM tree. Use getSearchResults to access search results or cancelSearch to end this search session.

Link copied to clipboard
Link copied to clipboard

Called when a pseudo element is added to an element.

Link copied to clipboard

Called when a pseudo element is removed from an element.

Link copied to clipboard

Requests that the node is sent to the caller given its path. // FIXME, use XPath

Link copied to clipboard

Requests that a batch of nodes is sent to the caller given their backend node ids.

Link copied to clipboard
suspend fun querySelector(nodeId: NodeId, selector: String): QuerySelectorResponse

Executes querySelector on a given node.

Link copied to clipboard
suspend fun querySelectorAll(nodeId: NodeId, selector: String): QuerySelectorAllResponse

Executes querySelectorAll on a given node.

Link copied to clipboard
suspend fun redo(): RedoResponse

Re-does the last undone action.

Link copied to clipboard

Removes attribute with given name from an element with given id.

Link copied to clipboard
suspend fun removeNode(nodeId: NodeId): RemoveNodeResponse

Removes node with given id.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard
inline suspend fun resolveNode(optionalArgs: ResolveNodeRequest.Builder.() -> Unit = {}): ResolveNodeResponse

Resolves the JavaScript node object for a given NodeId or BackendNodeId.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard
suspend fun setAttributeValue(nodeId: NodeId, name: String, value: String): SetAttributeValueResponse

Sets attribute for an element with given id.

Link copied to clipboard
suspend fun DOMDomain.setAttributeValue(nodeSelector: CssSelector, name: String, value: String)

Sets the attribute of the given name to the given value on the node corresponding to the given nodeSelector. Throws an exception if the selector didn't match any node.

Link copied to clipboard
Link copied to clipboard

Fired when backend wants to provide client with the missing DOM structure. This happens upon most of the calls requesting node ids.

Link copied to clipboard

Sets files for the given file input element.

Link copied to clipboard

Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).

Link copied to clipboard
suspend fun setNodeName(nodeId: NodeId, name: String): SetNodeNameResponse

Sets node name for a node with given id.

Link copied to clipboard

Sets if stack traces should be captured for Nodes. See Node.getNodeStackTraces. Default is disabled.

Link copied to clipboard
suspend fun setNodeValue(nodeId: NodeId, value: String): SetNodeValueResponse

Sets node value for a node with given id.

Link copied to clipboard
suspend fun setOuterHTML(nodeId: NodeId, outerHTML: String): SetOuterHTMLResponse

Sets node HTML markup, returns new node id.

Link copied to clipboard
Link copied to clipboard

Called when shadow root is popped from the element.

Link copied to clipboard
Link copied to clipboard

Called when shadow root is pushed into the element.

Link copied to clipboard

Called when top layer elements are changed.

Link copied to clipboard
suspend fun undo(): UndoResponse

Undoes the last performed action.