Package Torello.Browser
Class DOM
- java.lang.Object
-
- Torello.Browser.DOM
-
public class DOM extends java.lang.Object
Class created byAutomatic Code-Generator
.
This class was built using the Chrome Remote Dev-Tools A.P.I., which is specified by two JSON-RPC Files. These files were obtained from the Chrome Dev Tools Protocol Git Hub Page, which has a "Tip of Tree" (the latest) API-Specification Page Here: JSON-RPC Protocol Specification.
JSON-Viewable Google-API:
These files may be viewed here: browser_protocol.json and js_protocol.json.
These files were converted into this Java-Browser (CDT) Library; they are a Java-Alternative to the Node.js implementation.
HTML-Viewable API:
In addition to this Class-Library, these files were also converted to a simple HTML Page, which may be browsed here: Browser API Web-PageNode.js
RDP-API Implementation:
You may read about theNode.js Chrome Remote Interface
on the Node.js Package Manager Web-Site: NPM
This domain exposes DOM read/write operations. Each DOM Node is represented with its mirror object that has anid
. Thisid
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.This class is intended to be used with a Headless Browser
These methods have been tested, to some degree, using Google Chrome. In order to use this class you must start a web-browser instance and make a connection to the browser using aRemote Debugging Port
. The initializations may be accomplished using classBRDPC
(Browser Remote Debug Protocol Connection).
Google-Chrome was used during the development process of the classes in this particular package. Note that, lately, it has been asserted Microsoft has switched to using the Chrome-Engine for its Microsoft Edge Browser Internal Code-Base. Therefore, there may limited support / functionality when running the methods in this class with Microsoft-Edge. There is the possibility these will work with Opera & Safari.
Check whether the your Web-Browser will allow itself to be driven by theWeb-Socket RDP-Port 9223
.
Foreign Function API:
Every one of the methods that reside in this class are designed to do nothing more than:- Accept Parameters from the User, and "Marshall Them" into a Valid JSON-Request
- Transmit the Marshalled Request-JSON to a Headless Web-Browser over a Web-Socket RDP Connection
- Receive BOTH that Method's Results AND any Browser Event-Firings from the Web-Socket
- Parse JSON Method-Results and Browser-Event Firings, and Subsequently Convert them to Standard Java-Types
- Report these Method-Results and Browser-Events to the User via an User-Registered Event-Listener or a Promise Object
Java-HTML Difference:
Unlike the bulk of the Java HTML JAR Library, there is very little native Java-Code, and very little testing that may be done on any of the classes & methods in this package. The code inside these classes does nothing more than marshall-and-unmarshall Java-Types into Json-Requests (and vice-versa). The Java-Script & Browser modules inside of a Google-Chrome instance are, theoretically, handling these requests, and returning their results (or events) over the Web-Socket Connection.
It has been asserted (by Google Chrome Developers) that some of these methods are only "partially working" or "experimental".
Hi-Lited Source-Code:- View Here: Torello/Browser/DOM.java
- Open New Browser-Tab: Torello/Browser/DOM.java
File Size: 183,923 Bytes Line Count: 4,608 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctional
Annotation may also be called 'The Spaghetti Report'.Static-Functional
classes are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@Stateless
Annotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 48 Method(s), 48 declared static
- 8 Field(s), 8 declared static, 7 declared final
- Fields excused from final modifier (with explanation):
Field 'counter' is not final. Reason: CONFIGURATION
-
-
Nested Class Summary
Type Classes: DOM Domain Types Modifier and Type Inner-Class static class
DOM.BackendNode
Backend node with a friendly name.static class
DOM.BoxModel
Box model.static class
DOM.CSSComputedStyleProperty
[No Description Provided by Google]
static class
DOM.Node
DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes.static class
DOM.Rect
Rectangle.static class
DOM.RGBA
A structure holding an RGBA color.static class
DOM.ShapeOutsideInfo
CSS Shape Outside details.Event Classes: DOM Domain Events Modifier and Type Inner-Class static class
DOM.attributeModified
Fired whenElement
's attribute is modified.static class
DOM.attributeRemoved
Fired whenElement
's attribute is removed.static class
DOM.characterDataModified
MirrorsDOMCharacterDataModified
event.static class
DOM.childNodeCountUpdated
Fired whenContainer
's child node count has changed.static class
DOM.childNodeInserted
MirrorsDOMNodeInserted
event.static class
DOM.childNodeRemoved
MirrorsDOMNodeRemoved
event.static class
DOM.distributedNodesUpdated
Called when distribution is changed.static class
DOM.documentUpdated
Fired whenDocument
has been totally updated.static class
DOM.inlineStyleInvalidated
Fired whenElement
's inline style is modified via a CSS property modification.static class
DOM.pseudoElementAdded
Called when a pseudo element is added to an element.static class
DOM.pseudoElementRemoved
Called when a pseudo element is removed from an element.static class
DOM.setChildNodes
Fired when backend wants to provide client with the missing DOM structure.static class
DOM.shadowRootPopped
Called when shadow root is popped from the element.static class
DOM.shadowRootPushed
Called when shadow root is pushed into the element.
-
Field Summary
DOM Domain Enumerated String Types Modifier and Type Field static String[]
CompatibilityMode
Document compatibility mode.static String[]
PseudoType
Pseudo element type.static String[]
ShadowRootType
Shadow root type.
-
Method Summary
DOM Domain Commands Script Returns Modifier and Type Method String[]
static Script<>
collectClassNamesFromSubtree(int nodeId)
Collects class names for the node with given id and all of it's child nodes.Integer
static Script<>
copyTo(int nodeId, int targetNodeId, Integer insertBeforeNodeId)
Creates a deep copy of the specified node and places it into the target container before the given anchor.DOM.Node
static Script<>
describeNode(Integer nodeId, Integer backendNodeId, String objectId, Integer depth, Boolean pierce)
Describes node given its id, does not require domain to be enabled.NONE ( void
)static Script<>
disable()
Disables DOM agent for the given page.NONE ( void
)static Script<>
discardSearchResults(String searchId)
Discards search results from the session with the given id.NONE ( void
)static Script<>
enable()
Enables DOM agent for the given page.NONE ( void
)static Script<>
focus(Integer nodeId, Integer backendNodeId, String objectId)
Focuses the given element.String[]
static Script<>
getAttributes(int nodeId)
Returns attributes for the specified node.DOM.BoxModel
static Script<>
getBoxModel(Integer nodeId, Integer backendNodeId, String objectId)
Returns boxes for the given node.Integer
static Script<>
getContainerForNode(int nodeId, String containerName)
Returns the container of the given node based on container query conditions.Number[][]
static Script<>
getContentQuads(Integer nodeId, Integer backendNodeId, String objectId)
Returns quads that describe node position on the page.DOM.Node
static Script<>
getDocument(Integer depth, Boolean pierce)
Returns the root DOM node (and optionally the subtree) to the caller.String
static Script<>
getFileInfo(String objectId)
Returns file information for the given File wrapper.DOM.Node[]
static Script<>
getFlattenedDocument(Integer depth, Boolean pierce)
Returns the root DOM node (and optionally the subtree) to the caller.Ret2<Integer,
Integer>static Script<>
getFrameOwner(String frameId)
Returns iframe node that owns iframe with the given domain.Ret3<Integer,
String,
Integer>static Script<>
getNodeForLocation(int x, int y, Boolean includeUserAgentShadowDOM, Boolean ignorePointerEventsNone)
Returns node id at given location.int[]
static Script<>
getNodesForSubtreeByStyle(int nodeId, DOM.CSSComputedStyleProperty[] computedStyles, Boolean pierce)
Finds nodes with a given computed style in a subtree.RunTime.StackTrace
static Script<>
getNodeStackTraces(int nodeId)
Gets stack traces associated with a Node.String
static Script<>
getOuterHTML(Integer nodeId, Integer backendNodeId, String objectId)
Returns node's HTML markup.int[]
static Script<>
getQueryingDescendantsForContainer(int nodeId)
Returns the descendants of a container query container that have container queries against this container.Integer
static Script<>
getRelayoutBoundary(int nodeId)
Returns the id of the nearest ancestor that is a relayout boundary.int[]
static Script<>
getSearchResults(String searchId, int fromIndex, int toIndex)
Returns search results from givenfromIndex
to giventoIndex
from the search with the given identifier.NONE ( void
)static Script<>
hideHighlight()
Hides any highlight.NONE ( void
)static Script<>
highlightNode()
Highlights DOM node.NONE ( void
)static Script<>
highlightRect()
Highlights given rectangle.NONE ( void
)static Script<>
markUndoableState()
Marks last undoable state.Integer
static Script<>
moveTo(int nodeId, int targetNodeId, Integer insertBeforeNodeId)
Moves node into the new container, places it before the given anchor.Ret2<String,
Integer>static Script<>
performSearch(String query, Boolean includeUserAgentShadowDOM)
Searches for a given string in the DOM tree.Integer
static Script<>
pushNodeByPathToFrontend(String path)
Requests that the node is sent to the caller given its path.int[]
static Script<>
pushNodesByBackendIdsToFrontend(int[] backendNodeIds)
Requests that a batch of nodes is sent to the caller given their backend node ids.Integer
static Script<>
querySelector(int nodeId, String selector)
ExecutesquerySelector
on a given node.int[]
static Script<>
querySelectorAll(int nodeId, String selector)
ExecutesquerySelectorAll
on a given node.NONE ( void
)static Script<>
redo()
Re-does the last undone action.NONE ( void
)static Script<>
removeAttribute(int nodeId, String name)
Removes attribute with given name from an element with given id.NONE ( void
)static Script<>
removeNode(int nodeId)
Removes node with given id.NONE ( void
)static Script<>
requestChildNodes(int nodeId, Integer depth, Boolean pierce)
Requests that children of the node with given id are returned to the caller in form ofsetChildNodes
events where not only immediate children are retrieved, but all children down to the specified depth.Integer
static Script<>
requestNode(String objectId)
Requests that the node is sent to the caller given the JavaScript node object reference.RunTime.RemoteObject
static Script<>
resolveNode(Integer nodeId, Integer backendNodeId, String objectGroup, Integer executionContextId)
Resolves the JavaScript node object for a given NodeId or BackendNodeId.NONE ( void
)static Script<>
scrollIntoViewIfNeeded(Integer nodeId, Integer backendNodeId, String objectId, DOM.Rect rect)
Scrolls the specified rect of the given node into view if not already visible.NONE ( void
)static Script<>
setAttributesAsText(int nodeId, String text, String name)
Sets attributes on element with given id.NONE ( void
)static Script<>
setAttributeValue(int nodeId, String name, String value)
Sets attribute for an element with given id.NONE ( void
)static Script<>
setFileInputFiles(String[] files, Integer nodeId, Integer backendNodeId, String objectId)
Sets files for the given file input element.NONE ( void
)static Script<>
setInspectedNode(int nodeId)
Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).Integer
static Script<>
setNodeName(int nodeId, String name)
Sets node name for a node with given id.NONE ( void
)static Script<>
setNodeStackTracesEnabled(boolean enable)
Sets if stack traces should be captured for Nodes.NONE ( void
)static Script<>
setNodeValue(int nodeId, String value)
Sets node value for a node with given id.NONE ( void
)static Script<>
setOuterHTML(int nodeId, String outerHTML)
Sets node HTML markup, returns new node id.NONE ( void
)static Script<>
undo()
Undoes the last performed action.
-
-
-
Field Detail
-
PseudoType
public static final java.lang.String[] PseudoType
Pseudo element type.
-
ShadowRootType
public static final java.lang.String[] ShadowRootType
Shadow root type.
-
CompatibilityMode
public static final java.lang.String[] CompatibilityMode
Document compatibility mode.
-
-
Method Detail
-
collectClassNamesFromSubtree
public static Script<java.lang.String,JsonObject,java.lang.String[]> collectClassNamesFromSubtree (int nodeId)
Collects class names for the node with given id and all of it's child nodes.
EXPERIMENTAL- Parameters:
nodeId
- Id of the node to collect class names.- Returns:
- An instance of
Script
<String,JsonObject
, String[]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, String[]>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsString[] (classNames
)
Class name list.
-
copyTo
public static Script<java.lang.String,JsonObject,java.lang.Integer> copyTo (int nodeId, int targetNodeId, java.lang.Integer insertBeforeNodeId)
Creates a deep copy of the specified node and places it into the target container before the given anchor.
EXPERIMENTAL- 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 oftargetNodeId
).
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
, Integer>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Integer>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsInteger (nodeId
)
Id of the node clone.
-
describeNode
public static Script<java.lang.String,JsonObject,DOM.Node> describeNode (java.lang.Integer nodeId, java.lang.Integer backendNodeId, java.lang.String objectId, java.lang.Integer depth, 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.- Parameters:
nodeId
- Identifier of the node.
OPTIONALbackendNodeId
- Identifier of the backend node.
OPTIONALobjectId
- JavaScript object id of the node wrapper.
OPTIONALdepth
- 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.
OPTIONALpierce
- Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,DOM.Node
>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject,
will be returned.DOM.Node
>
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returns
)DOM.Node
(node
Node description.
-
scrollIntoViewIfNeeded
public static Script<java.lang.String,JsonObject,Ret0> scrollIntoViewIfNeeded (java.lang.Integer nodeId, java.lang.Integer backendNodeId, java.lang.String objectId, DOM.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.
EXPERIMENTAL- Parameters:
nodeId
- Identifier of the node.
OPTIONALbackendNodeId
- Identifier of the backend node.
OPTIONALobjectId
- JavaScript object id of the node wrapper.
OPTIONALrect
- 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.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
disable
public static Script<java.lang.String,JsonObject,Ret0> disable()
Disables DOM agent for the given page.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
discardSearchResults
public static Script<java.lang.String,JsonObject,Ret0> discardSearchResults (java.lang.String searchId)
Discards search results from the session with the given id.getSearchResults
should no longer be called for that search.
EXPERIMENTAL- Parameters:
searchId
- Unique search session identifier.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
enable
public static Script<java.lang.String,JsonObject,Ret0> enable()
Enables DOM agent for the given page.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
focus
public static Script<java.lang.String,JsonObject,Ret0> focus (java.lang.Integer nodeId, java.lang.Integer backendNodeId, java.lang.String objectId)
Focuses the given element.- Parameters:
nodeId
- Identifier of the node.
OPTIONALbackendNodeId
- Identifier of the backend node.
OPTIONALobjectId
- JavaScript object id of the node wrapper.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
getAttributes
public static Script<java.lang.String,JsonObject,java.lang.String[]> getAttributes (int nodeId)
Returns attributes for the specified node.- Parameters:
nodeId
- Id of the node to retrieve attibutes for.- Returns:
- An instance of
Script
<String,JsonObject
, String[]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, String[]>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsString[] (attributes
)
An interleaved array of node attribute names and values.
-
getBoxModel
public static Script<java.lang.String,JsonObject,DOM.BoxModel> getBoxModel (java.lang.Integer nodeId, java.lang.Integer backendNodeId, java.lang.String objectId)
Returns boxes for the given node.- Parameters:
nodeId
- Identifier of the node.
OPTIONALbackendNodeId
- Identifier of the backend node.
OPTIONALobjectId
- JavaScript object id of the node wrapper.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,DOM.BoxModel
>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject,
will be returned.DOM.BoxModel
>
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returns
)DOM.BoxModel
(model
Box model for the node.
-
getContentQuads
public static Script<java.lang.String,JsonObject,java.lang.Number[][]> getContentQuads (java.lang.Integer nodeId, java.lang.Integer backendNodeId, java.lang.String objectId)
Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.
EXPERIMENTAL- Parameters:
nodeId
- Identifier of the node.
OPTIONALbackendNodeId
- Identifier of the backend node.
OPTIONALobjectId
- JavaScript object id of the node wrapper.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
, Number[][]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Number[][]>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsNumber[][] (quads
)
Quads that describe node layout relative to viewport.
-
getDocument
public static Script<java.lang.String,JsonObject,DOM.Node> getDocument (java.lang.Integer depth, java.lang.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.
OPTIONALpierce
- Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,DOM.Node
>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject,
will be returned.DOM.Node
>
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returns
)DOM.Node
(root
Resulting node.
-
getFlattenedDocument
public static Script<java.lang.String,JsonObject,DOM.Node[]> getFlattenedDocument (java.lang.Integer depth, java.lang.Boolean pierce)
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.
DEPRECATED- 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.
OPTIONALpierce
- Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,DOM.Node
[]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject,
will be returned.DOM.Node
[]>
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returns
)DOM.Node
[] (nodes
Resulting node.
-
getNodesForSubtreeByStyle
public static Script<java.lang.String,JsonObject,int[]> getNodesForSubtreeByStyle (int nodeId, DOM.CSSComputedStyleProperty[] computedStyles, java.lang.Boolean pierce)
Finds nodes with a given computed style in a subtree.
EXPERIMENTAL- 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).
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
, int[]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, int[]>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsint[] (nodeIds
)
Resulting nodes.
-
getNodeForLocation
public static Script<java.lang.String,JsonObject,Ret3<java.lang.Integer,java.lang.String,java.lang.Integer>> getNodeForLocation (int x, int y, java.lang.Boolean includeUserAgentShadowDOM, java.lang.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).
OPTIONALignorePointerEventsNone
- Whether to ignore pointer-events: none on elements and hit test them.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret3
>
ThisScript
may be executed (usingScript.exec()
), and aPromise
returned.
When thePromise
is awaited (usingPromise.await()
), theRet3
will subsequently be returned from that call.
The returned values are encapsulated in an instance ofRet3
Ret3.a: Integer (backendNodeId)
Resulting node.Ret3.b: String (frameId)
Frame this node belongs to.Ret3.c: Integer (nodeId)
Id of the node at given coordinates, only when enabled and requested document.
-
getOuterHTML
public static Script<java.lang.String,JsonObject,java.lang.String> getOuterHTML (java.lang.Integer nodeId, java.lang.Integer backendNodeId, java.lang.String objectId)
Returns node's HTML markup.- Parameters:
nodeId
- Identifier of the node.
OPTIONALbackendNodeId
- Identifier of the backend node.
OPTIONALobjectId
- JavaScript object id of the node wrapper.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
, String>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, String>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsString (outerHTML
)
Outer HTML markup.
-
getRelayoutBoundary
public static Script<java.lang.String,JsonObject,java.lang.Integer> getRelayoutBoundary (int nodeId)
Returns the id of the nearest ancestor that is a relayout boundary.
EXPERIMENTAL- Parameters:
nodeId
- Id of the node.- Returns:
- An instance of
Script
<String,JsonObject
, Integer>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Integer>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsInteger (nodeId
)
Relayout boundary node id for the given node.
-
getSearchResults
public static Script<java.lang.String,JsonObject,int[]> getSearchResults (java.lang.String searchId, int fromIndex, int toIndex)
Returns search results from givenfromIndex
to giventoIndex
from the search with the given identifier.
EXPERIMENTAL- 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:
- An instance of
Script
<String,JsonObject
, int[]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, int[]>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsint[] (nodeIds
)
Ids of the search result nodes.
-
hideHighlight
public static Script<java.lang.String,JsonObject,Ret0> hideHighlight()
Hides any highlight.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
highlightNode
public static Script<java.lang.String,JsonObject,Ret0> highlightNode()
Highlights DOM node.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
highlightRect
public static Script<java.lang.String,JsonObject,Ret0> highlightRect()
Highlights given rectangle.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
markUndoableState
public static Script<java.lang.String,JsonObject,Ret0> markUndoableState ()
Marks last undoable state.
EXPERIMENTAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
moveTo
public static Script<java.lang.String,JsonObject,java.lang.Integer> moveTo (int nodeId, int targetNodeId, java.lang.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 oftargetNodeId
).
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
, Integer>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Integer>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsInteger (nodeId
)
New id of the moved node.
-
performSearch
public static Script<java.lang.String,JsonObject,Ret2<java.lang.String,java.lang.Integer>> performSearch (java.lang.String query, java.lang.Boolean includeUserAgentShadowDOM)
Searches for a given string in the DOM tree. UsegetSearchResults
to access search results orcancelSearch
to end this search session.
EXPERIMENTAL- Parameters:
query
- Plain text or query selector or XPath search query.includeUserAgentShadowDOM
- True to search in user agent shadow DOM.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret2
>
ThisScript
may be executed (usingScript.exec()
), and aPromise
returned.
When thePromise
is awaited (usingPromise.await()
), theRet2
will subsequently be returned from that call.
The returned values are encapsulated in an instance ofRet2
Ret2.a: String (searchId)
Unique search session identifier.Ret2.b: Integer (resultCount)
Number of search results.
-
pushNodeByPathToFrontend
public static Script<java.lang.String,JsonObject,java.lang.Integer> pushNodeByPathToFrontend (java.lang.String path)
Requests that the node is sent to the caller given its path. // FIXME, use XPath
EXPERIMENTAL- Parameters:
path
- Path to node in the proprietary format.- Returns:
- An instance of
Script
<String,JsonObject
, Integer>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Integer>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsInteger (nodeId
)
Id of the node for given path.
-
pushNodesByBackendIdsToFrontend
public static Script<java.lang.String,JsonObject,int[]> pushNodesByBackendIdsToFrontend (int[] backendNodeIds)
Requests that a batch of nodes is sent to the caller given their backend node ids.
EXPERIMENTAL- Parameters:
backendNodeIds
- The array of backend node ids.- Returns:
- An instance of
Script
<String,JsonObject
, int[]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, int[]>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsint[] (nodeIds
)
The array of ids of pushed nodes that correspond to the backend ids specified in backendNodeIds.
-
querySelector
public static Script<java.lang.String,JsonObject,java.lang.Integer> querySelector (int nodeId, java.lang.String selector)
ExecutesquerySelector
on a given node.- Parameters:
nodeId
- Id of the node to query upon.selector
- Selector string.- Returns:
- An instance of
Script
<String,JsonObject
, Integer>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Integer>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsInteger (nodeId
)
Query selector result.
-
querySelectorAll
public static Script<java.lang.String,JsonObject,int[]> querySelectorAll (int nodeId, java.lang.String selector)
ExecutesquerySelectorAll
on a given node.- Parameters:
nodeId
- Id of the node to query upon.selector
- Selector string.- Returns:
- An instance of
Script
<String,JsonObject
, int[]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, int[]>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsint[] (nodeIds
)
Query selector result.
-
redo
public static Script<java.lang.String,JsonObject,Ret0> redo()
Re-does the last undone action.
EXPERIMENTAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
removeAttribute
public static Script<java.lang.String,JsonObject,Ret0> removeAttribute (int nodeId, java.lang.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.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
removeNode
public static Script<java.lang.String,JsonObject,Ret0> removeNode (int nodeId)
Removes node with given id.- Parameters:
nodeId
- Id of the node to remove.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
requestChildNodes
public static Script<java.lang.String,JsonObject,Ret0> requestChildNodes (int nodeId, java.lang.Integer depth, java.lang.Boolean pierce)
Requests that children of the node with given id are returned to the caller in form ofsetChildNodes
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.
OPTIONALpierce
- Whether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false).
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
requestNode
public static Script<java.lang.String,JsonObject,java.lang.Integer> requestNode (java.lang.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 ofsetChildNodes
notifications.- Parameters:
objectId
- JavaScript object id to convert into node.- Returns:
- An instance of
Script
<String,JsonObject
, Integer>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Integer>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsInteger (nodeId
)
Node id for given object.
-
resolveNode
public static Script<java.lang.String,JsonObject,RunTime.RemoteObject> resolveNode (java.lang.Integer nodeId, java.lang.Integer backendNodeId, java.lang.String objectGroup, java.lang.Integer executionContextId)
Resolves the JavaScript node object for a given NodeId or BackendNodeId.- Parameters:
nodeId
- Id of the node to resolve.
OPTIONALbackendNodeId
- Backend identifier of the node to resolve.
OPTIONALobjectGroup
- Symbolic group name that can be used to release multiple objects.
OPTIONALexecutionContextId
- Execution context in which to resolve the node.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,RunTime.RemoteObject
>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject,
will be returned.RunTime.RemoteObject
>
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returns
)RunTime.RemoteObject
(object
JavaScript object wrapper for given node.
-
setAttributeValue
public static Script<java.lang.String,JsonObject,Ret0> setAttributeValue (int nodeId, java.lang.String name, java.lang.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.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
setAttributesAsText
public static Script<java.lang.String,JsonObject,Ret0> setAttributesAsText (int nodeId, java.lang.String text, 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.- 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.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
setFileInputFiles
public static Script<java.lang.String,JsonObject,Ret0> setFileInputFiles (java.lang.String[] files, java.lang.Integer nodeId, java.lang.Integer backendNodeId, java.lang.String objectId)
Sets files for the given file input element.- Parameters:
files
- Array of file paths to set.nodeId
- Identifier of the node.
OPTIONALbackendNodeId
- Identifier of the backend node.
OPTIONALobjectId
- JavaScript object id of the node wrapper.
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
setNodeStackTracesEnabled
public static Script<java.lang.String,JsonObject,Ret0> setNodeStackTracesEnabled (boolean enable)
Sets if stack traces should be captured for Nodes. SeeNode.getNodeStackTraces
. Default is disabled.
EXPERIMENTAL- Parameters:
enable
- Enable or disable.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
getNodeStackTraces
public static Script<java.lang.String,JsonObject,RunTime.StackTrace> getNodeStackTraces (int nodeId)
Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation.
EXPERIMENTAL- Parameters:
nodeId
- Id of the node to get stack traces for.- Returns:
- An instance of
Script
<String,JsonObject
,RunTime.StackTrace
>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject,
will be returned.RunTime.StackTrace
>
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returns
)RunTime.StackTrace
(creation
Creation stack trace, if available.
-
getFileInfo
public static Script<java.lang.String,JsonObject,java.lang.String> getFileInfo (java.lang.String objectId)
Returns file information for the given File wrapper.
EXPERIMENTAL- Parameters:
objectId
- JavaScript object id of the node wrapper.- Returns:
- An instance of
Script
<String,JsonObject
, String>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, String>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsString (path
)
-
-
setInspectedNode
public static Script<java.lang.String,JsonObject,Ret0> setInspectedNode (int nodeId)
Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).
EXPERIMENTAL- Parameters:
nodeId
- DOM node id to be accessible by means of $x command line API.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
setNodeName
public static Script<java.lang.String,JsonObject,java.lang.Integer> setNodeName (int nodeId, java.lang.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:
- An instance of
Script
<String,JsonObject
, Integer>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Integer>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsInteger (nodeId
)
New node's id.
-
setNodeValue
public static Script<java.lang.String,JsonObject,Ret0> setNodeValue (int nodeId, java.lang.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.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
setOuterHTML
public static Script<java.lang.String,JsonObject,Ret0> setOuterHTML (int nodeId, java.lang.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.- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
undo
public static Script<java.lang.String,JsonObject,Ret0> undo()
Undoes the last performed action.
EXPERIMENTAL- Returns:
- An instance of
Script
<String,JsonObject
,Ret0
>
ThisScript
instance must be executed before the browser receives the invocation-request.
This Browser-Function does not have a return-value. You may choose to await thePromise
<JsonObject,
Ret0
>
to ensure the Browser Function has run to completion.
-
getFrameOwner
public static Script<java.lang.String,JsonObject,Ret2<java.lang.Integer,java.lang.Integer>> getFrameOwner (java.lang.String frameId)
Returns iframe node that owns iframe with the given domain.
EXPERIMENTAL- Parameters:
frameId
- -- Returns:
- An instance of
Script
<String,JsonObject
,Ret2
>
ThisScript
may be executed (usingScript.exec()
), and aPromise
returned.
When thePromise
is awaited (usingPromise.await()
), theRet2
will subsequently be returned from that call.
The returned values are encapsulated in an instance ofRet2
Ret2.a: Integer (backendNodeId)
Resulting node.Ret2.b: Integer (nodeId)
Id of the node at given coordinates, only when enabled and requested document.
-
getContainerForNode
public static Script<java.lang.String,JsonObject,java.lang.Integer> getContainerForNode (int nodeId, java.lang.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.
EXPERIMENTAL- Parameters:
nodeId
- -containerName
- -
OPTIONAL- Returns:
- An instance of
Script
<String,JsonObject
, Integer>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, Integer>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsInteger (nodeId
)
The container node for the given node, or null if not found.
-
getQueryingDescendantsForContainer
public static Script<java.lang.String,JsonObject,int[]> getQueryingDescendantsForContainer (int nodeId)
Returns the descendants of a container query container that have container queries against this container.
EXPERIMENTAL- Parameters:
nodeId
- Id of the container node to find querying descendants from.- Returns:
- An instance of
Script
<String,JsonObject
, int[]>
This script may be executed, usingScript.exec()
, and afterwards, aPromise
<JsonObject, int[]>
will be returned.
Finally, thePromise
may be awaited, usingPromise.await()
, and the returned result of this Browser Function may may be retrieved.
This Browser Function returnsint[] (nodeIds
)
Descendant nodes with container queries against the given container.
-
-