Class DOM
java.lang.Object
org.openqa.selenium.devtools.v119.dom.DOM
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
static class
static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.openqa.selenium.devtools.Event<AttributeModified>
static org.openqa.selenium.devtools.Event<AttributeRemoved>
static org.openqa.selenium.devtools.Event<CharacterDataModified>
static org.openqa.selenium.devtools.Event<ChildNodeCountUpdated>
static org.openqa.selenium.devtools.Event<ChildNodeInserted>
static org.openqa.selenium.devtools.Event<ChildNodeRemoved>
collectClassNamesFromSubtree
(NodeId nodeId) Collects class names for the node with given id and all of it's child nodes.static org.openqa.selenium.devtools.Command<NodeId>
Creates a deep copy of the specified node and places it into the target container before the given anchor.static org.openqa.selenium.devtools.Command<Node>
describeNode
(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId, Optional<Integer> depth, Optional<Boolean> pierce) Describes node given its id, does not require domain to be enabled.static org.openqa.selenium.devtools.Command<Void>
disable()
Disables DOM agent for the given page.static org.openqa.selenium.devtools.Command<Void>
discardSearchResults
(String searchId) Discards search results from the session with the given id.static org.openqa.selenium.devtools.Event<DistributedNodesUpdated>
static org.openqa.selenium.devtools.Event<Void>
static org.openqa.selenium.devtools.Command<Void>
enable
(Optional<DOM.EnableIncludeWhitespace> includeWhitespace) Enables DOM agent for the given page.static org.openqa.selenium.devtools.Command<Void>
focus
(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Focuses the given element.getAttributes
(NodeId nodeId) Returns attributes for the specified node.static org.openqa.selenium.devtools.Command<BoxModel>
getBoxModel
(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Returns boxes for the given node.static org.openqa.selenium.devtools.Command<NodeId>
getContainerForNode
(NodeId nodeId, Optional<String> containerName, Optional<PhysicalAxes> physicalAxes, Optional<LogicalAxes> logicalAxes) Returns the query container of the given node based on container query conditions: containerName, physical, and logical axes.getContentQuads
(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Returns quads that describe node position on the page.static org.openqa.selenium.devtools.Command<Node>
getDocument
(Optional<Integer> depth, Optional<Boolean> pierce) Returns the root DOM node (and optionally the subtree) to the caller.static org.openqa.selenium.devtools.Command<String>
getFileInfo
(RemoteObjectId objectId) Returns file information for the given File wrapper.getFlattenedDocument
(Optional<Integer> depth, Optional<Boolean> pierce) Deprecated.static org.openqa.selenium.devtools.Command<DOM.GetFrameOwnerResponse>
getFrameOwner
(FrameId frameId) Returns iframe node that owns iframe with the given domain.static org.openqa.selenium.devtools.Command<DOM.GetNodeForLocationResponse>
getNodeForLocation
(Integer x, Integer y, Optional<Boolean> includeUserAgentShadowDOM, Optional<Boolean> ignorePointerEventsNone) Returns node id at given location.getNodesForSubtreeByStyle
(NodeId nodeId, List<CSSComputedStyleProperty> computedStyles, Optional<Boolean> pierce) Finds nodes with a given computed style in a subtree.static org.openqa.selenium.devtools.Command<StackTrace>
getNodeStackTraces
(NodeId nodeId) Gets stack traces associated with a Node.static org.openqa.selenium.devtools.Command<String>
getOuterHTML
(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Returns node's HTML markup.Returns the descendants of a container query container that have container queries against this container.static org.openqa.selenium.devtools.Command<NodeId>
getRelayoutBoundary
(NodeId nodeId) Returns the id of the nearest ancestor that is a relayout boundary.getSearchResults
(String searchId, Integer fromIndex, Integer toIndex) Returns search results from given `fromIndex` to given `toIndex` from the search with the given identifier.Returns NodeIds of current top layer elements.static org.openqa.selenium.devtools.Command<Void>
Hides any highlight.static org.openqa.selenium.devtools.Command<Void>
Highlights DOM node.static org.openqa.selenium.devtools.Command<Void>
Highlights given rectangle.static org.openqa.selenium.devtools.Command<Void>
Marks last undoable state.static org.openqa.selenium.devtools.Command<NodeId>
Moves node into the new container, places it before the given anchor.static org.openqa.selenium.devtools.Command<DOM.PerformSearchResponse>
performSearch
(String query, Optional<Boolean> includeUserAgentShadowDOM) Searches for a given string in the DOM tree.static org.openqa.selenium.devtools.Event<PseudoElementAdded>
static org.openqa.selenium.devtools.Event<PseudoElementRemoved>
static org.openqa.selenium.devtools.Command<NodeId>
Requests that the node is sent to the caller given its path.pushNodesByBackendIdsToFrontend
(List<BackendNodeId> backendNodeIds) Requests that a batch of nodes is sent to the caller given their backend node ids.static org.openqa.selenium.devtools.Command<NodeId>
querySelector
(NodeId nodeId, String selector) Executes `querySelector` on a given node.querySelectorAll
(NodeId nodeId, String selector) Executes `querySelectorAll` on a given node.static org.openqa.selenium.devtools.Command<Void>
redo()
Re-does the last undone action.static org.openqa.selenium.devtools.Command<Void>
removeAttribute
(NodeId nodeId, String name) Removes attribute with given name from an element with given id.static org.openqa.selenium.devtools.Command<Void>
removeNode
(NodeId nodeId) Removes node with given id.static org.openqa.selenium.devtools.Command<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.static org.openqa.selenium.devtools.Command<NodeId>
requestNode
(RemoteObjectId objectId) Requests that the node is sent to the caller given the JavaScript node object reference.static org.openqa.selenium.devtools.Command<RemoteObject>
resolveNode
(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<String> objectGroup, Optional<ExecutionContextId> executionContextId) Resolves the JavaScript node object for a given NodeId or BackendNodeId.static org.openqa.selenium.devtools.Command<Void>
scrollIntoViewIfNeeded
(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId, Optional<Rect> rect) Scrolls the specified rect of the given node into view if not already visible.static org.openqa.selenium.devtools.Command<Void>
setAttributesAsText
(NodeId nodeId, String text, Optional<String> name) Sets attributes on element with given id.static org.openqa.selenium.devtools.Command<Void>
setAttributeValue
(NodeId nodeId, String name, String value) Sets attribute for an element with given id.static org.openqa.selenium.devtools.Event<SetChildNodes>
static org.openqa.selenium.devtools.Command<Void>
setFileInputFiles
(List<String> files, Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Sets files for the given file input element.static org.openqa.selenium.devtools.Command<Void>
setInspectedNode
(NodeId nodeId) Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).static org.openqa.selenium.devtools.Command<NodeId>
setNodeName
(NodeId nodeId, String name) Sets node name for a node with given id.static org.openqa.selenium.devtools.Command<Void>
setNodeStackTracesEnabled
(Boolean enable) Sets if stack traces should be captured for Nodes.static org.openqa.selenium.devtools.Command<Void>
setNodeValue
(NodeId nodeId, String value) Sets node value for a node with given id.static org.openqa.selenium.devtools.Command<Void>
setOuterHTML
(NodeId nodeId, String outerHTML) Sets node HTML markup, returns new node id.static org.openqa.selenium.devtools.Event<ShadowRootPopped>
static org.openqa.selenium.devtools.Event<ShadowRootPushed>
static org.openqa.selenium.devtools.Event<Void>
static org.openqa.selenium.devtools.Command<Void>
undo()
Undoes the last performed action.
-
Constructor Details
-
DOM
public DOM()
-
-
Method Details
-
collectClassNamesFromSubtree
@Beta public static org.openqa.selenium.devtools.Command<List<String>> collectClassNamesFromSubtree(NodeId nodeId) Collects class names for the node with given id and all of it's child nodes. -
copyTo
@Beta public static org.openqa.selenium.devtools.Command<NodeId> copyTo(NodeId nodeId, NodeId targetNodeId, Optional<NodeId> insertBeforeNodeId) Creates a deep copy of the specified node and places it into the target container before the given anchor. -
describeNode
public static org.openqa.selenium.devtools.Command<Node> describeNode(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId, Optional<Integer> depth, Optional<Boolean> pierce) Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation. -
scrollIntoViewIfNeeded
@Beta public static org.openqa.selenium.devtools.Command<Void> scrollIntoViewIfNeeded(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId, Optional<Rect> rect) 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. -
disable
Disables DOM agent for the given page. -
discardSearchResults
@Beta public static org.openqa.selenium.devtools.Command<Void> discardSearchResults(String searchId) Discards search results from the session with the given id. `getSearchResults` should no longer be called for that search. -
enable
public static org.openqa.selenium.devtools.Command<Void> enable(Optional<DOM.EnableIncludeWhitespace> includeWhitespace) Enables DOM agent for the given page. -
focus
public static org.openqa.selenium.devtools.Command<Void> focus(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Focuses the given element. -
getAttributes
Returns attributes for the specified node. -
getBoxModel
public static org.openqa.selenium.devtools.Command<BoxModel> getBoxModel(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Returns boxes for the given node. -
getContentQuads
@Beta public static org.openqa.selenium.devtools.Command<List<Quad>> getContentQuads(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Returns quads that describe node position on the page. This method might return multiple quads for inline nodes. -
getDocument
public static org.openqa.selenium.devtools.Command<Node> getDocument(Optional<Integer> depth, Optional<Boolean> pierce) Returns the root DOM node (and optionally the subtree) to the caller. Implicitly enables the DOM domain events for the current target. -
getFlattenedDocument
@Deprecated public static org.openqa.selenium.devtools.Command<List<Node>> getFlattenedDocument(Optional<Integer> depth, Optional<Boolean> pierce) Deprecated.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. -
getNodesForSubtreeByStyle
@Beta public static org.openqa.selenium.devtools.Command<List<NodeId>> getNodesForSubtreeByStyle(NodeId nodeId, List<CSSComputedStyleProperty> computedStyles, Optional<Boolean> pierce) Finds nodes with a given computed style in a subtree. -
getNodeForLocation
public static org.openqa.selenium.devtools.Command<DOM.GetNodeForLocationResponse> getNodeForLocation(Integer x, Integer y, Optional<Boolean> includeUserAgentShadowDOM, Optional<Boolean> ignorePointerEventsNone) Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not. -
getOuterHTML
public static org.openqa.selenium.devtools.Command<String> getOuterHTML(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Returns node's HTML markup. -
getRelayoutBoundary
Returns the id of the nearest ancestor that is a relayout boundary. -
getSearchResults
@Beta public static org.openqa.selenium.devtools.Command<List<NodeId>> getSearchResults(String searchId, Integer fromIndex, Integer toIndex) Returns search results from given `fromIndex` to given `toIndex` from the search with the given identifier. -
hideHighlight
Hides any highlight. -
highlightNode
Highlights DOM node. -
highlightRect
Highlights given rectangle. -
markUndoableState
Marks last undoable state. -
moveTo
public static org.openqa.selenium.devtools.Command<NodeId> moveTo(NodeId nodeId, NodeId targetNodeId, Optional<NodeId> insertBeforeNodeId) Moves node into the new container, places it before the given anchor. -
performSearch
@Beta public static org.openqa.selenium.devtools.Command<DOM.PerformSearchResponse> performSearch(String query, Optional<Boolean> includeUserAgentShadowDOM) Searches for a given string in the DOM tree. Use `getSearchResults` to access search results or `cancelSearch` to end this search session. -
pushNodeByPathToFrontend
@Beta public static org.openqa.selenium.devtools.Command<NodeId> pushNodeByPathToFrontend(String path) Requests that the node is sent to the caller given its path. // FIXME, use XPath -
pushNodesByBackendIdsToFrontend
@Beta public static org.openqa.selenium.devtools.Command<List<NodeId>> pushNodesByBackendIdsToFrontend(List<BackendNodeId> backendNodeIds) Requests that a batch of nodes is sent to the caller given their backend node ids. -
querySelector
public static org.openqa.selenium.devtools.Command<NodeId> querySelector(NodeId nodeId, String selector) Executes `querySelector` on a given node. -
querySelectorAll
public static org.openqa.selenium.devtools.Command<List<NodeId>> querySelectorAll(NodeId nodeId, String selector) Executes `querySelectorAll` on a given node. -
getTopLayerElements
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. -
redo
Re-does the last undone action. -
removeAttribute
public static org.openqa.selenium.devtools.Command<Void> removeAttribute(NodeId nodeId, String name) Removes attribute with given name from an element with given id. -
removeNode
Removes node with given id. -
requestChildNodes
public static org.openqa.selenium.devtools.Command<Void> requestChildNodes(NodeId nodeId, Optional<Integer> depth, Optional<Boolean> pierce) 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. -
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. -
resolveNode
public static org.openqa.selenium.devtools.Command<RemoteObject> resolveNode(Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<String> objectGroup, Optional<ExecutionContextId> executionContextId) Resolves the JavaScript node object for a given NodeId or BackendNodeId. -
setAttributeValue
public static org.openqa.selenium.devtools.Command<Void> setAttributeValue(NodeId nodeId, String name, String value) Sets attribute for an element with given id. -
setAttributesAsText
public static org.openqa.selenium.devtools.Command<Void> setAttributesAsText(NodeId nodeId, String text, Optional<String> name) 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. -
setFileInputFiles
public static org.openqa.selenium.devtools.Command<Void> setFileInputFiles(List<String> files, Optional<NodeId> nodeId, Optional<BackendNodeId> backendNodeId, Optional<RemoteObjectId> objectId) Sets files for the given file input element. -
setNodeStackTracesEnabled
@Beta public static org.openqa.selenium.devtools.Command<Void> setNodeStackTracesEnabled(Boolean enable) Sets if stack traces should be captured for Nodes. See `Node.getNodeStackTraces`. Default is disabled. -
getNodeStackTraces
@Beta public static org.openqa.selenium.devtools.Command<StackTrace> getNodeStackTraces(NodeId nodeId) Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation. -
getFileInfo
@Beta public static org.openqa.selenium.devtools.Command<String> getFileInfo(RemoteObjectId objectId) Returns file information for the given File wrapper. -
setInspectedNode
Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions). -
setNodeName
Sets node name for a node with given id. -
setNodeValue
Sets node value for a node with given id. -
setOuterHTML
public static org.openqa.selenium.devtools.Command<Void> setOuterHTML(NodeId nodeId, String outerHTML) Sets node HTML markup, returns new node id. -
undo
Undoes the last performed action. -
getFrameOwner
@Beta public static org.openqa.selenium.devtools.Command<DOM.GetFrameOwnerResponse> getFrameOwner(FrameId frameId) Returns iframe node that owns iframe with the given domain. -
getContainerForNode
@Beta public static org.openqa.selenium.devtools.Command<NodeId> getContainerForNode(NodeId nodeId, Optional<String> containerName, Optional<PhysicalAxes> physicalAxes, Optional<LogicalAxes> logicalAxes) 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. -
getQueryingDescendantsForContainer
@Beta public static org.openqa.selenium.devtools.Command<List<NodeId>> getQueryingDescendantsForContainer(NodeId nodeId) Returns the descendants of a container query container that have container queries against this container. -
attributeModified
-
attributeRemoved
-
characterDataModified
-
childNodeCountUpdated
-
childNodeInserted
-
childNodeRemoved
-
distributedNodesUpdated
-
documentUpdated
-
inlineStyleInvalidated
-
pseudoElementAdded
-
topLayerElementsUpdated
-
pseudoElementRemoved
-
setChildNodes
-
shadowRootPopped
-
shadowRootPushed
-