java.lang.Object
org.openqa.selenium.devtools.v115.dom.DOM

public class DOM extends Object
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.

  • 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

      public static org.openqa.selenium.devtools.Command<Void> 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

      public static org.openqa.selenium.devtools.Command<List<String>> getAttributes(NodeId nodeId)
      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

      @Beta public static org.openqa.selenium.devtools.Command<NodeId> getRelayoutBoundary(NodeId nodeId)
      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

      public static org.openqa.selenium.devtools.Command<Void> hideHighlight()
      Hides any highlight.
    • highlightNode

      public static org.openqa.selenium.devtools.Command<Void> highlightNode()
      Highlights DOM node.
    • highlightRect

      public static org.openqa.selenium.devtools.Command<Void> highlightRect()
      Highlights given rectangle.
    • markUndoableState

      @Beta public static org.openqa.selenium.devtools.Command<Void> 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

      @Beta public static org.openqa.selenium.devtools.Command<List<NodeId>> 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

      @Beta public static org.openqa.selenium.devtools.Command<Void> 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

      public static org.openqa.selenium.devtools.Command<Void> removeNode(NodeId nodeId)
      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

      public 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. 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

      @Beta public 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).
    • setNodeName

      public static org.openqa.selenium.devtools.Command<NodeId> setNodeName(NodeId nodeId, String name)
      Sets node name for a node with given id.
    • setNodeValue

      public static org.openqa.selenium.devtools.Command<Void> setNodeValue(NodeId nodeId, String value)
      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

      @Beta public static org.openqa.selenium.devtools.Command<Void> 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

      public static org.openqa.selenium.devtools.Event<AttributeModified> attributeModified()
    • attributeRemoved

      public static org.openqa.selenium.devtools.Event<AttributeRemoved> attributeRemoved()
    • characterDataModified

      public static org.openqa.selenium.devtools.Event<CharacterDataModified> characterDataModified()
    • childNodeCountUpdated

      public static org.openqa.selenium.devtools.Event<ChildNodeCountUpdated> childNodeCountUpdated()
    • childNodeInserted

      public static org.openqa.selenium.devtools.Event<ChildNodeInserted> childNodeInserted()
    • childNodeRemoved

      public static org.openqa.selenium.devtools.Event<ChildNodeRemoved> childNodeRemoved()
    • distributedNodesUpdated

      public static org.openqa.selenium.devtools.Event<DistributedNodesUpdated> distributedNodesUpdated()
    • documentUpdated

      public static org.openqa.selenium.devtools.Event<Void> documentUpdated()
    • inlineStyleInvalidated

      public static org.openqa.selenium.devtools.Event<List<NodeId>> inlineStyleInvalidated()
    • pseudoElementAdded

      public static org.openqa.selenium.devtools.Event<PseudoElementAdded> pseudoElementAdded()
    • topLayerElementsUpdated

      public static org.openqa.selenium.devtools.Event<Void> topLayerElementsUpdated()
    • pseudoElementRemoved

      public static org.openqa.selenium.devtools.Event<PseudoElementRemoved> pseudoElementRemoved()
    • setChildNodes

      public static org.openqa.selenium.devtools.Event<SetChildNodes> setChildNodes()
    • shadowRootPopped

      public static org.openqa.selenium.devtools.Event<ShadowRootPopped> shadowRootPopped()
    • shadowRootPushed

      public static org.openqa.selenium.devtools.Event<ShadowRootPushed> shadowRootPushed()