chrome-devtools-kotlin / org.hildan.chrome.devtools.domains.dom / DOMDomain

DOMDomain

class 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

attributeModified

Fired when Element's attribute is modified.

fun attributeModified(): Flow<AttributeModifiedEvent>

attributeRemoved

Fired when Element's attribute is removed.

fun attributeRemoved(): Flow<AttributeRemovedEvent>

characterDataModified

Mirrors DOMCharacterDataModified event.

fun characterDataModified(): Flow<CharacterDataModifiedEvent>

childNodeCountUpdated

Fired when Container's child node count has changed.

fun childNodeCountUpdated(): Flow<ChildNodeCountUpdatedEvent>

childNodeInserted

Mirrors DOMNodeInserted event.

fun childNodeInserted(): Flow<ChildNodeInsertedEvent>

childNodeRemoved

Mirrors DOMNodeRemoved event.

fun childNodeRemoved(): Flow<ChildNodeRemovedEvent>

collectClassNamesFromSubtree

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

suspend fun collectClassNamesFromSubtree(input: CollectClassNamesFromSubtreeRequest): CollectClassNamesFromSubtreeResponse

copyTo

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

suspend fun copyTo(input: CopyToRequest): CopyToResponse

describeNode

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

suspend fun describeNode(input: DescribeNodeRequest): DescribeNodeResponse

disable

Disables DOM agent for the given page.

suspend fun disable(): Unit

discardSearchResults

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

suspend fun discardSearchResults(input: DiscardSearchResultsRequest): Unit

distributedNodesUpdated

Called when distrubution is changed.

fun distributedNodesUpdated(): Flow<DistributedNodesUpdatedEvent>

documentUpdated

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

fun documentUpdated(): Flow<DocumentUpdatedEvent>

enable

Enables DOM agent for the given page.

suspend fun enable(): Unit

events

Subscribes to all events related to this domain.

fun events(): Flow<DOMEvent>

focus

Focuses the given element.

suspend fun focus(input: FocusRequest): Unit

getAttributes

Returns attributes for the specified node.

suspend fun getAttributes(input: GetAttributesRequest): GetAttributesResponse

getBoxModel

Returns boxes for the given node.

suspend fun getBoxModel(input: GetBoxModelRequest): GetBoxModelResponse

getContentQuads

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

suspend fun getContentQuads(input: GetContentQuadsRequest): GetContentQuadsResponse

getDocument

Returns the root DOM node (and optionally the subtree) to the caller.

suspend fun getDocument(input: GetDocumentRequest): GetDocumentResponse

getFileInfo

Returns file information for the given File wrapper.

suspend fun getFileInfo(input: GetFileInfoRequest): GetFileInfoResponse

getFlattenedDocument

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.

suspend fun getFlattenedDocument(input: GetFlattenedDocumentRequest): GetFlattenedDocumentResponse

getFrameOwner

Returns iframe node that owns iframe with the given domain.

suspend fun getFrameOwner(input: GetFrameOwnerRequest): GetFrameOwnerResponse

getNodeForLocation

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

suspend fun getNodeForLocation(input: GetNodeForLocationRequest): GetNodeForLocationResponse

getNodesForSubtreeByStyle

Finds nodes with a given computed style in a subtree.

suspend fun getNodesForSubtreeByStyle(input: GetNodesForSubtreeByStyleRequest): GetNodesForSubtreeByStyleResponse

getNodeStackTraces

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

suspend fun getNodeStackTraces(input: GetNodeStackTracesRequest): GetNodeStackTracesResponse

getOuterHTML

Returns node's HTML markup.

suspend fun getOuterHTML(input: GetOuterHTMLRequest): GetOuterHTMLResponse

getRelayoutBoundary

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

suspend fun getRelayoutBoundary(input: GetRelayoutBoundaryRequest): GetRelayoutBoundaryResponse

getSearchResults

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

suspend fun getSearchResults(input: GetSearchResultsRequest): GetSearchResultsResponse

hideHighlight

Hides any highlight.

suspend fun hideHighlight(): Unit

highlightNode

Highlights DOM node.

suspend fun highlightNode(): Unit

highlightRect

Highlights given rectangle.

suspend fun highlightRect(): Unit

inlineStyleInvalidated

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

fun inlineStyleInvalidated(): Flow<InlineStyleInvalidatedEvent>

markUndoableState

Marks last undoable state.

suspend fun markUndoableState(): Unit

moveTo

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

suspend fun moveTo(input: MoveToRequest): MoveToResponse

performSearch

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

suspend fun performSearch(input: PerformSearchRequest): PerformSearchResponse

pseudoElementAdded

Called when a pseudo element is added to an element.

fun pseudoElementAdded(): Flow<PseudoElementAddedEvent>

pseudoElementRemoved

Called when a pseudo element is removed from an element.

fun pseudoElementRemoved(): Flow<PseudoElementRemovedEvent>

pushNodeByPathToFrontend

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

suspend fun pushNodeByPathToFrontend(input: PushNodeByPathToFrontendRequest): PushNodeByPathToFrontendResponse

pushNodesByBackendIdsToFrontend

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

suspend fun pushNodesByBackendIdsToFrontend(input: PushNodesByBackendIdsToFrontendRequest): PushNodesByBackendIdsToFrontendResponse

querySelector

Executes querySelector on a given node.

suspend fun querySelector(input: QuerySelectorRequest): QuerySelectorResponse

querySelectorAll

Executes querySelectorAll on a given node.

suspend fun querySelectorAll(input: QuerySelectorAllRequest): QuerySelectorAllResponse

redo

Re-does the last undone action.

suspend fun redo(): Unit

removeAttribute

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

suspend fun removeAttribute(input: RemoveAttributeRequest): Unit

removeNode

Removes node with given id.

suspend fun removeNode(input: RemoveNodeRequest): Unit

requestChildNodes

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.

suspend fun requestChildNodes(input: RequestChildNodesRequest): Unit

requestNode

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.

suspend fun requestNode(input: RequestNodeRequest): RequestNodeResponse

resolveNode

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

suspend fun resolveNode(input: ResolveNodeRequest): ResolveNodeResponse

scrollIntoViewIfNeeded

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.

suspend fun scrollIntoViewIfNeeded(input: ScrollIntoViewIfNeededRequest): Unit

setAttributesAsText

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.

suspend fun setAttributesAsText(input: SetAttributesAsTextRequest): Unit

setAttributeValue

Sets attribute for an element with given id.

suspend fun setAttributeValue(input: SetAttributeValueRequest): Unit

setChildNodes

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

fun setChildNodes(): Flow<SetChildNodesEvent>

setFileInputFiles

Sets files for the given file input element.

suspend fun setFileInputFiles(input: SetFileInputFilesRequest): Unit

setInspectedNode

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

suspend fun setInspectedNode(input: SetInspectedNodeRequest): Unit

setNodeName

Sets node name for a node with given id.

suspend fun setNodeName(input: SetNodeNameRequest): SetNodeNameResponse

setNodeStackTracesEnabled

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

suspend fun setNodeStackTracesEnabled(input: SetNodeStackTracesEnabledRequest): Unit

setNodeValue

Sets node value for a node with given id.

suspend fun setNodeValue(input: SetNodeValueRequest): Unit

setOuterHTML

Sets node HTML markup, returns new node id.

suspend fun setOuterHTML(input: SetOuterHTMLRequest): Unit

shadowRootPopped

Called when shadow root is popped from the element.

fun shadowRootPopped(): Flow<ShadowRootPoppedEvent>

shadowRootPushed

Called when shadow root is pushed into the element.

fun shadowRootPushed(): Flow<ShadowRootPushedEvent>

undo

Undoes the last performed action.

suspend fun undo(): Unit

Extension Functions

findNodeBySelector

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

suspend fun DOMDomain.findNodeBySelector(selector: String): NodeId?

focusNodeBySelector

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

suspend fun DOMDomain.focusNodeBySelector(selector: String): Unit

getDocumentRootNodeId

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

suspend fun DOMDomain.getDocumentRootNodeId(): NodeId