Package org.openqa.selenium.devtools.dom
Class DOM
- java.lang.Object
-
- org.openqa.selenium.devtools.dom.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DOM.GetFrameOwnerResponse
static class
DOM.GetNodeForLocationResponse
static class
DOM.PerformSearchResponse
-
Constructor Summary
Constructors Constructor Description DOM()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Event<AttributeModified>
attributeModified()
static Event<AttributeRemoved>
attributeRemoved()
static Event<CharacterDataModified>
characterDataModified()
static Event<ChildNodeCountUpdated>
childNodeCountUpdated()
static Event<ChildNodeInserted>
childNodeInserted()
static Event<ChildNodeRemoved>
childNodeRemoved()
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.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.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.static Command<java.lang.Void>
disable()
Disables DOM agent for the given page.static Command<java.lang.Void>
discardSearchResults(java.lang.String searchId)
Discards search results from the session with the given id.static Event<DistributedNodesUpdated>
distributedNodesUpdated()
static Event<java.lang.Void>
documentUpdated()
static Command<java.lang.Void>
enable()
Enables DOM agent for the given page.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.static Command<java.util.List<java.lang.String>>
getAttributes(NodeId nodeId)
Returns attributes for the specified node.static Command<BoxModel>
getBoxModel(java.util.Optional<NodeId> nodeId, java.util.Optional<BackendNodeId> backendNodeId, java.util.Optional<RemoteObjectId> objectId)
Returns boxes for the given node.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.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.static Command<java.lang.String>
getFileInfo(RemoteObjectId objectId)
Returns file information for the given File wrapper.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.static Command<DOM.GetFrameOwnerResponse>
getFrameOwner(FrameId frameId)
Returns iframe node that owns iframe with the given domain.static Command<DOM.GetNodeForLocationResponse>
getNodeForLocation(java.lang.Integer x, java.lang.Integer y, java.util.Optional<java.lang.Boolean> includeUserAgentShadowDOM)
Returns node id at given location.static Command<StackTrace>
getNodeStackTraces(NodeId nodeId)
Gets stack traces associated with a Node.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.static Command<NodeId>
getRelayoutBoundary(NodeId nodeId)
Returns the id of the nearest ancestor that is a relayout boundary.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.static Command<java.lang.Void>
hideHighlight()
Hides any highlight.static Command<java.lang.Void>
highlightNode()
Highlights DOM node.static Command<java.lang.Void>
highlightRect()
Highlights given rectangle.static Event<java.util.List<NodeId>>
inlineStyleInvalidated()
static Command<java.lang.Void>
markUndoableState()
Marks last undoable state.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.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.static Event<PseudoElementAdded>
pseudoElementAdded()
static Event<PseudoElementRemoved>
pseudoElementRemoved()
static Command<NodeId>
pushNodeByPathToFrontend(java.lang.String path)
Requests that the node is sent to the caller given its path.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.static Command<NodeId>
querySelector(NodeId nodeId, java.lang.String selector)
Executes `querySelector` on a given node.static Command<java.util.List<NodeId>>
querySelectorAll(NodeId nodeId, java.lang.String selector)
Executes `querySelectorAll` on a given node.static Command<java.lang.Void>
redo()
Re-does the last undone action.static Command<java.lang.Void>
removeAttribute(NodeId nodeId, java.lang.String name)
Removes attribute with given name from an element with given id.static Command<java.lang.Void>
removeNode(NodeId nodeId)
Removes node with given id.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.static Command<NodeId>
requestNode(RemoteObjectId objectId)
Requests that the node is sent to the caller given the JavaScript node object reference.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.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.static Command<java.lang.Void>
setAttributeValue(NodeId nodeId, java.lang.String name, java.lang.String value)
Sets attribute for an element with given id.static Event<SetChildNodes>
setChildNodes()
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.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).static Command<NodeId>
setNodeName(NodeId nodeId, java.lang.String name)
Sets node name for a node with given id.static Command<java.lang.Void>
setNodeStackTracesEnabled(java.lang.Boolean enable)
Sets if stack traces should be captured for Nodes.static Command<java.lang.Void>
setNodeValue(NodeId nodeId, java.lang.String value)
Sets node value for a node with given id.static Command<java.lang.Void>
setOuterHTML(NodeId nodeId, java.lang.String outerHTML)
Sets node HTML markup, returns new node id.static Event<ShadowRootPopped>
shadowRootPopped()
static Event<ShadowRootPushed>
shadowRootPushed()
static Command<java.lang.Void>
undo()
Undoes the last performed action.
-
-
-
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.
-
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.
-
getBoxModel
public static Command<BoxModel> getBoxModel(java.util.Optional<NodeId> nodeId, java.util.Optional<BackendNodeId> backendNodeId, java.util.Optional<RemoteObjectId> objectId)
Returns boxes for the given 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
@Beta public static Command<DOM.GetNodeForLocationResponse> getNodeForLocation(java.lang.Integer x, java.lang.Integer y, java.util.Optional<java.lang.Boolean> includeUserAgentShadowDOM)
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.
-
getFrameOwner
@Beta public static Command<DOM.GetFrameOwnerResponse> getFrameOwner(FrameId frameId)
Returns iframe node that owns iframe with the given domain.
-
attributeModified
public static Event<AttributeModified> attributeModified()
-
attributeRemoved
public static Event<AttributeRemoved> attributeRemoved()
-
characterDataModified
public static Event<CharacterDataModified> characterDataModified()
-
childNodeCountUpdated
public static Event<ChildNodeCountUpdated> childNodeCountUpdated()
-
childNodeInserted
public static Event<ChildNodeInserted> childNodeInserted()
-
childNodeRemoved
public static Event<ChildNodeRemoved> childNodeRemoved()
-
distributedNodesUpdated
public static Event<DistributedNodesUpdated> distributedNodesUpdated()
-
documentUpdated
public static Event<java.lang.Void> documentUpdated()
-
pseudoElementAdded
public static Event<PseudoElementAdded> pseudoElementAdded()
-
pseudoElementRemoved
public static Event<PseudoElementRemoved> pseudoElementRemoved()
-
setChildNodes
public static Event<SetChildNodes> setChildNodes()
-
shadowRootPopped
public static Event<ShadowRootPopped> shadowRootPopped()
-
shadowRootPushed
public static Event<ShadowRootPushed> shadowRootPushed()
-
-