Interface DOMAsync


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

  • Method Details

    • collectClassNamesFromSubtree

      CompletableFuture<List<String>> collectClassNamesFromSubtree(Integer nodeId)
      Collects class names for the node with given id and all of it's child nodes.
      Parameters:
      nodeId - Id of the node to collect class names.
      Returns:
      Class name list.
    • copyTo

      CompletableFuture<Integer> copyTo(Integer nodeId, Integer targetNodeId)
      Creates a deep copy of the specified node and places it into the target container before the given anchor.
      Parameters:
      nodeId - Id of the node to copy.
      targetNodeId - Id of the element to drop the copy into.
      Returns:
      Id of the node clone.
    • copyTo

      CompletableFuture<Integer> copyTo(Integer nodeId, Integer targetNodeId, Integer insertBeforeNodeId)
      Creates a deep copy of the specified node and places it into the target container before the given anchor.
      Parameters:
      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

      CompletableFuture<Node> describeNode()
      Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation.
      Returns:
      Node description.
    • describeNode

      CompletableFuture<Node> describeNode(Integer nodeId, Integer backendNodeId, String objectId, Integer depth, 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.
      Parameters:
      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

      Disables DOM agent for the given page.
    • discardSearchResults

      CompletableFuture<Void> discardSearchResults(String searchId)
      Discards search results from the session with the given id. getSearchResults should no longer be called for that search.
      Parameters:
      searchId - Unique search session identifier.
    • enable

      Enables DOM agent for the given page.
    • enable

      CompletableFuture<Void> enable(IncludeWhitespace includeWhitespace)
      Enables DOM agent for the given page.
      Parameters:
      includeWhitespace - Whether to include whitespaces in the children array of returned Nodes.
    • focus

      Focuses the given element.
    • focus

      CompletableFuture<Void> focus(Integer nodeId, Integer backendNodeId, String objectId)
      Focuses the given element.
      Parameters:
      nodeId - Identifier of the node.
      backendNodeId - Identifier of the backend node.
      objectId - JavaScript object id of the node wrapper.
    • getAttributes

      CompletableFuture<List<String>> getAttributes(Integer nodeId)
      Returns attributes for the specified node.
      Parameters:
      nodeId - Id of the node to retrieve attibutes for.
      Returns:
      An interleaved array of node attribute names and values.
    • getBoxModel

      CompletableFuture<BoxModel> getBoxModel()
      Returns boxes for the given node.
      Returns:
      Box model for the node.
    • getBoxModel

      CompletableFuture<BoxModel> getBoxModel(Integer nodeId, Integer backendNodeId, String objectId)
      Returns boxes for the given node.
      Parameters:
      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

      CompletableFuture<Integer> getContainerForNode(Integer nodeId)
      Returns the container of the given node based on container query conditions. If containerName is given, it will find the nearest container with a matching name; otherwise it will find the nearest container regardless of its container name.
      Returns:
      The container node for the given node, or null if not found.
    • getContainerForNode

      CompletableFuture<Integer> getContainerForNode(Integer nodeId, String containerName)
      Returns the container of the given node based on container query conditions. If containerName is given, it will find the nearest container with a matching name; otherwise it will find the nearest container regardless of its container name.
      Returns:
      The container node for the given node, or null if not found.
    • getContentQuads

      CompletableFuture<List<List<Double>>> getContentQuads()
      Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.
      Returns:
      Quads that describe node layout relative to viewport.
    • getContentQuads

      CompletableFuture<List<List<Double>>> getContentQuads(Integer nodeId, Integer backendNodeId, String objectId)
      Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.
      Parameters:
      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

      CompletableFuture<Node> getDocument()
      Returns the root DOM node (and optionally the subtree) to the caller.
      Returns:
      Resulting node.
    • getDocument

      CompletableFuture<Node> getDocument(Integer depth, Boolean pierce)
      Returns the root DOM node (and optionally the subtree) to the caller.
      Parameters:
      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

      CompletableFuture<String> getFileInfo(String objectId)
      Returns file information for the given File wrapper.
      Parameters:
      objectId - JavaScript object id of the node wrapper.
    • getFlattenedDocument

      @Deprecated CompletableFuture<List<Node>> getFlattenedDocument()
      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.
      Returns:
      Resulting node.
    • getFlattenedDocument

      @Deprecated CompletableFuture<List<Node>> getFlattenedDocument(Integer depth, 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.
      Parameters:
      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

      CompletableFuture<GetFrameOwnerResult> getFrameOwner(String frameId)
      Returns iframe node that owns iframe with the given domain.
      Returns:
      GetFrameOwnerResult
    • getNodeForLocation

      Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.
      Parameters:
      x - X coordinate.
      y - Y coordinate.
      Returns:
      GetNodeForLocationResult
    • getNodeForLocation

      CompletableFuture<GetNodeForLocationResult> getNodeForLocation(Integer x, Integer y, Boolean includeUserAgentShadowDOM, Boolean ignorePointerEventsNone)
      Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.
      Parameters:
      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.
      Returns:
      GetNodeForLocationResult
    • getNodeStackTraces

      CompletableFuture<StackTrace> getNodeStackTraces(Integer nodeId)
      Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation.
      Parameters:
      nodeId - Id of the node to get stack traces for.
      Returns:
      Creation stack trace, if available.
    • getNodesForSubtreeByStyle

      CompletableFuture<List<Integer>> getNodesForSubtreeByStyle(Integer nodeId, List<CSSComputedStyleProperty> computedStyles)
      Finds nodes with a given computed style in a subtree.
      Parameters:
      nodeId - Node ID pointing to the root of a subtree.
      computedStyles - The style to filter nodes by (includes nodes if any of properties matches).
      Returns:
      Resulting nodes.
    • getNodesForSubtreeByStyle

      CompletableFuture<List<Integer>> getNodesForSubtreeByStyle(Integer nodeId, List<CSSComputedStyleProperty> computedStyles, Boolean pierce)
      Finds nodes with a given computed style in a subtree.
      Parameters:
      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.
    • getOuterHTML

      CompletableFuture<String> getOuterHTML()
      Returns node's HTML markup.
      Returns:
      Outer HTML markup.
    • getOuterHTML

      CompletableFuture<String> getOuterHTML(Integer nodeId, Integer backendNodeId, String objectId)
      Returns node's HTML markup.
      Parameters:
      nodeId - Identifier of the node.
      backendNodeId - Identifier of the backend node.
      objectId - JavaScript object id of the node wrapper.
      Returns:
      Outer HTML markup.
    • getQueryingDescendantsForContainer

      CompletableFuture<List<Integer>> getQueryingDescendantsForContainer(Integer nodeId)
      Returns the descendants of a container query container that have container queries against this container.
      Parameters:
      nodeId - Id of the container node to find querying descendants from.
      Returns:
      Descendant nodes with container queries against the given container.
    • getRelayoutBoundary

      CompletableFuture<Integer> getRelayoutBoundary(Integer nodeId)
      Returns the id of the nearest ancestor that is a relayout boundary.
      Parameters:
      nodeId - Id of the node.
      Returns:
      Relayout boundary node id for the given node.
    • getSearchResults

      CompletableFuture<List<Integer>> getSearchResults(String searchId, Integer fromIndex, Integer toIndex)
      Returns search results from given fromIndex to given toIndex from the search with the given identifier.
      Parameters:
      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

      CompletableFuture<List<Integer>> 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.
      Returns:
      NodeIds of top layer elements
    • hideHighlight

      CompletableFuture<Void> hideHighlight()
      Hides any highlight.
    • highlightNode

      CompletableFuture<Void> highlightNode()
      Highlights DOM node.
    • highlightRect

      CompletableFuture<Void> highlightRect()
      Highlights given rectangle.
    • markUndoableState

      CompletableFuture<Void> markUndoableState()
      Marks last undoable state.
    • moveTo

      CompletableFuture<Integer> moveTo(Integer nodeId, Integer targetNodeId)
      Moves node into the new container, places it before the given anchor.
      Parameters:
      nodeId - Id of the node to move.
      targetNodeId - Id of the element to drop the moved node into.
      Returns:
      New id of the moved node.
    • moveTo

      CompletableFuture<Integer> moveTo(Integer nodeId, Integer targetNodeId, Integer insertBeforeNodeId)
      Moves node into the new container, places it before the given anchor.
      Parameters:
      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.
    • performSearch

      Searches for a given string in the DOM tree. Use getSearchResults to access search results or cancelSearch to end this search session.
      Parameters:
      query - Plain text or query selector or XPath search query.
      Returns:
      PerformSearchResult
    • performSearch

      CompletableFuture<PerformSearchResult> performSearch(String query, Boolean includeUserAgentShadowDOM)
      Searches for a given string in the DOM tree. Use getSearchResults to access search results or cancelSearch to end this search session.
      Parameters:
      query - Plain text or query selector or XPath search query.
      includeUserAgentShadowDOM - True to search in user agent shadow DOM.
      Returns:
      PerformSearchResult
    • pushNodeByPathToFrontend

      CompletableFuture<Integer> pushNodeByPathToFrontend(String path)
      Requests that the node is sent to the caller given its path. // FIXME, use XPath
      Parameters:
      path - Path to node in the proprietary format.
      Returns:
      Id of the node for given path.
    • pushNodesByBackendIdsToFrontend

      CompletableFuture<List<Integer>> pushNodesByBackendIdsToFrontend(List<Integer> backendNodeIds)
      Requests that a batch of nodes is sent to the caller given their backend node ids.
      Parameters:
      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

      CompletableFuture<Integer> querySelector(Integer nodeId, String selector)
      Executes querySelector on a given node.
      Parameters:
      nodeId - Id of the node to query upon.
      selector - Selector string.
      Returns:
      Query selector result.
    • querySelectorAll

      CompletableFuture<List<Integer>> querySelectorAll(Integer nodeId, String selector)
      Executes querySelectorAll on a given node.
      Parameters:
      nodeId - Id of the node to query upon.
      selector - Selector string.
      Returns:
      Query selector result.
    • redo

      Re-does the last undone action.
    • removeAttribute

      CompletableFuture<Void> removeAttribute(Integer nodeId, String name)
      Removes attribute with given name from an element with given id.
      Parameters:
      nodeId - Id of the element to remove attribute from.
      name - Name of the attribute to remove.
    • removeNode

      CompletableFuture<Void> removeNode(Integer nodeId)
      Removes node with given id.
      Parameters:
      nodeId - Id of the node to remove.
    • requestChildNodes

      CompletableFuture<Void> requestChildNodes(Integer nodeId)
      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.
      Parameters:
      nodeId - Id of the node to get children for.
    • requestChildNodes

      CompletableFuture<Void> requestChildNodes(Integer nodeId, Integer depth, 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.
      Parameters:
      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

      CompletableFuture<Integer> requestNode(String 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.
      Parameters:
      objectId - JavaScript object id to convert into node.
      Returns:
      Node id for given object.
    • resolveNode

      Resolves the JavaScript node object for a given NodeId or BackendNodeId.
      Returns:
      JavaScript object wrapper for given node.
    • resolveNode

      CompletableFuture<RemoteObject> resolveNode(Integer nodeId, Integer backendNodeId, String objectGroup, Integer executionContextId)
      Resolves the JavaScript node object for a given NodeId or BackendNodeId.
      Parameters:
      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

      CompletableFuture<Void> 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.
    • scrollIntoViewIfNeeded

      CompletableFuture<Void> scrollIntoViewIfNeeded(Integer nodeId, Integer backendNodeId, String objectId, 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.
      Parameters:
      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.
    • setAttributeValue

      CompletableFuture<Void> setAttributeValue(Integer nodeId, String name, String value)
      Sets attribute for an element with given id.
      Parameters:
      nodeId - Id of the element to set attribute for.
      name - Attribute name.
      value - Attribute value.
    • setAttributesAsText

      CompletableFuture<Void> setAttributesAsText(Integer nodeId, String text)
      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.
      Parameters:
      nodeId - Id of the element to set attributes for.
      text - Text with a number of attributes. Will parse this text using HTML parser.
    • setAttributesAsText

      CompletableFuture<Void> setAttributesAsText(Integer nodeId, String text, 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.
      Parameters:
      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.
    • setFileInputFiles

      CompletableFuture<Void> setFileInputFiles(List<String> files)
      Sets files for the given file input element.
      Parameters:
      files - Array of file paths to set.
    • setFileInputFiles

      CompletableFuture<Void> setFileInputFiles(List<String> files, Integer nodeId, Integer backendNodeId, String objectId)
      Sets files for the given file input element.
      Parameters:
      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

      CompletableFuture<Void> setInspectedNode(Integer nodeId)
      Enables console to refer to the node with given id via (see Command Line API for more details functions).
      Parameters:
      nodeId - DOM node id to be accessible by means of x command line API.
    • setNodeName

      CompletableFuture<Integer> setNodeName(Integer nodeId, String name)
      Sets node name for a node with given id.
      Parameters:
      nodeId - Id of the node to set name for.
      name - New node's name.
      Returns:
      New node's id.
    • setNodeStackTracesEnabled

      CompletableFuture<Void> setNodeStackTracesEnabled(Boolean enable)
      Sets if stack traces should be captured for Nodes. See Node.getNodeStackTraces. Default is disabled.
      Parameters:
      enable - Enable or disable.
    • setNodeValue

      CompletableFuture<Void> setNodeValue(Integer nodeId, String value)
      Sets node value for a node with given id.
      Parameters:
      nodeId - Id of the node to set value for.
      value - New node's value.
    • setOuterHTML

      CompletableFuture<Void> setOuterHTML(Integer nodeId, String outerHTML)
      Sets node HTML markup, returns new node id.
      Parameters:
      nodeId - Id of the node to set markup for.
      outerHTML - Outer HTML markup to set.
    • undo

      Undoes the last performed action.