Class DOM


  • public class DOM
    extends java.lang.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 Detail

      • DOM

        public DOM()
    • Method Detail

      • collectClassNamesFromSubtree

        @Beta
        public static Command<java.util.List<java.lang.String>> collectClassNamesFromSubtree​(NodeId nodeId)
        Collects class names for the node with given id and all of it's child nodes.
      • copyTo

        @Beta
        public static Command<NodeId> copyTo​(NodeId nodeId,
                                             NodeId targetNodeId,
                                             java.util.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 Command<Node> describeNode​(java.util.Optional<NodeId> nodeId,
                                                 java.util.Optional<BackendNodeId> backendNodeId,
                                                 java.util.Optional<RemoteObjectId> objectId,
                                                 java.util.Optional<java.lang.Integer> depth,
                                                 java.util.Optional<java.lang.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 Command<java.lang.Void> scrollIntoViewIfNeeded​(java.util.Optional<NodeId> nodeId,
                                                                     java.util.Optional<BackendNodeId> backendNodeId,
                                                                     java.util.Optional<RemoteObjectId> objectId,
                                                                     java.util.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 Command<java.lang.Void> disable()
        Disables DOM agent for the given page.
      • discardSearchResults

        @Beta
        public static Command<java.lang.Void> discardSearchResults​(java.lang.String searchId)
        Discards search results from the session with the given id. `getSearchResults` should no longer be called for that search.
      • enable

        public static Command<java.lang.Void> enable()
        Enables DOM agent for the given page.
      • focus

        public static Command<java.lang.Void> focus​(java.util.Optional<NodeId> nodeId,
                                                    java.util.Optional<BackendNodeId> backendNodeId,
                                                    java.util.Optional<RemoteObjectId> objectId)
        Focuses the given element.
      • getAttributes

        public static Command<java.util.List<java.lang.String>> getAttributes​(NodeId nodeId)
        Returns attributes for the specified node.
      • getContentQuads

        @Beta
        public static Command<java.util.List<Quad>> getContentQuads​(java.util.Optional<NodeId> nodeId,
                                                                    java.util.Optional<BackendNodeId> backendNodeId,
                                                                    java.util.Optional<RemoteObjectId> objectId)
        Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.
      • getDocument

        public static Command<Node> getDocument​(java.util.Optional<java.lang.Integer> depth,
                                                java.util.Optional<java.lang.Boolean> pierce)
        Returns the root DOM node (and optionally the subtree) to the caller.
      • getFlattenedDocument

        public static Command<java.util.List<Node>> getFlattenedDocument​(java.util.Optional<java.lang.Integer> depth,
                                                                         java.util.Optional<java.lang.Boolean> pierce)
        Returns the root DOM node (and optionally the subtree) to the caller.
      • getNodeForLocation

        public static Command<DOM.GetNodeForLocationResponse> getNodeForLocation​(java.lang.Integer x,
                                                                                 java.lang.Integer y,
                                                                                 java.util.Optional<java.lang.Boolean> includeUserAgentShadowDOM,
                                                                                 java.util.Optional<java.lang.Boolean> ignorePointerEventsNone)
        Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.
      • getOuterHTML

        public static Command<java.lang.String> getOuterHTML​(java.util.Optional<NodeId> nodeId,
                                                             java.util.Optional<BackendNodeId> backendNodeId,
                                                             java.util.Optional<RemoteObjectId> objectId)
        Returns node's HTML markup.
      • getRelayoutBoundary

        @Beta
        public static Command<NodeId> getRelayoutBoundary​(NodeId nodeId)
        Returns the id of the nearest ancestor that is a relayout boundary.
      • getSearchResults

        @Beta
        public static Command<java.util.List<NodeId>> getSearchResults​(java.lang.String searchId,
                                                                       java.lang.Integer fromIndex,
                                                                       java.lang.Integer toIndex)
        Returns search results from given `fromIndex` to given `toIndex` from the search with the given identifier.
      • hideHighlight

        public static Command<java.lang.Void> hideHighlight()
        Hides any highlight.
      • highlightNode

        public static Command<java.lang.Void> highlightNode()
        Highlights DOM node.
      • highlightRect

        public static Command<java.lang.Void> highlightRect()
        Highlights given rectangle.
      • markUndoableState

        @Beta
        public static Command<java.lang.Void> markUndoableState()
        Marks last undoable state.
      • moveTo

        public static Command<NodeId> moveTo​(NodeId nodeId,
                                             NodeId targetNodeId,
                                             java.util.Optional<NodeId> insertBeforeNodeId)
        Moves node into the new container, places it before the given anchor.
      • performSearch

        @Beta
        public static Command<DOM.PerformSearchResponse> performSearch​(java.lang.String query,
                                                                       java.util.Optional<java.lang.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 Command<NodeId> pushNodeByPathToFrontend​(java.lang.String path)
        Requests that the node is sent to the caller given its path. // FIXME, use XPath
      • pushNodesByBackendIdsToFrontend

        @Beta
        public static Command<java.util.List<NodeId>> pushNodesByBackendIdsToFrontend​(java.util.List<BackendNodeId> backendNodeIds)
        Requests that a batch of nodes is sent to the caller given their backend node ids.
      • querySelector

        public static Command<NodeId> querySelector​(NodeId nodeId,
                                                    java.lang.String selector)
        Executes `querySelector` on a given node.
      • querySelectorAll

        public static Command<java.util.List<NodeId>> querySelectorAll​(NodeId nodeId,
                                                                       java.lang.String selector)
        Executes `querySelectorAll` on a given node.
      • redo

        @Beta
        public static Command<java.lang.Void> redo()
        Re-does the last undone action.
      • removeAttribute

        public static Command<java.lang.Void> removeAttribute​(NodeId nodeId,
                                                              java.lang.String name)
        Removes attribute with given name from an element with given id.
      • removeNode

        public static Command<java.lang.Void> removeNode​(NodeId nodeId)
        Removes node with given id.
      • requestChildNodes

        public static Command<java.lang.Void> requestChildNodes​(NodeId nodeId,
                                                                java.util.Optional<java.lang.Integer> depth,
                                                                java.util.Optional<java.lang.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 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 Command<RemoteObject> resolveNode​(java.util.Optional<NodeId> nodeId,
                                                        java.util.Optional<BackendNodeId> backendNodeId,
                                                        java.util.Optional<java.lang.String> objectGroup,
                                                        java.util.Optional<ExecutionContextId> executionContextId)
        Resolves the JavaScript node object for a given NodeId or BackendNodeId.
      • setAttributeValue

        public static Command<java.lang.Void> setAttributeValue​(NodeId nodeId,
                                                                java.lang.String name,
                                                                java.lang.String value)
        Sets attribute for an element with given id.
      • setAttributesAsText

        public static Command<java.lang.Void> setAttributesAsText​(NodeId nodeId,
                                                                  java.lang.String text,
                                                                  java.util.Optional<java.lang.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 Command<java.lang.Void> setFileInputFiles​(java.util.List<java.lang.String> files,
                                                                java.util.Optional<NodeId> nodeId,
                                                                java.util.Optional<BackendNodeId> backendNodeId,
                                                                java.util.Optional<RemoteObjectId> objectId)
        Sets files for the given file input element.
      • setNodeStackTracesEnabled

        @Beta
        public static Command<java.lang.Void> setNodeStackTracesEnabled​(java.lang.Boolean enable)
        Sets if stack traces should be captured for Nodes. See `Node.getNodeStackTraces`. Default is disabled.
      • getNodeStackTraces

        @Beta
        public static 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 Command<java.lang.String> getFileInfo​(RemoteObjectId objectId)
        Returns file information for the given File wrapper.
      • setInspectedNode

        @Beta
        public static Command<java.lang.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 Command<NodeId> setNodeName​(NodeId nodeId,
                                                  java.lang.String name)
        Sets node name for a node with given id.
      • setNodeValue

        public static Command<java.lang.Void> setNodeValue​(NodeId nodeId,
                                                           java.lang.String value)
        Sets node value for a node with given id.
      • setOuterHTML

        public static Command<java.lang.Void> setOuterHTML​(NodeId nodeId,
                                                           java.lang.String outerHTML)
        Sets node HTML markup, returns new node id.
      • undo

        @Beta
        public static Command<java.lang.Void> undo()
        Undoes the last performed action.
      • documentUpdated

        public static Event<java.lang.Void> documentUpdated()
      • inlineStyleInvalidated

        public static Event<java.util.List<NodeId>> inlineStyleInvalidated()