CDPotion.Domain.DOM (cdpotion v0.1.4)
Summary
Types
Backend node with a friendly name.
Unique DOM node identifier used to reference a node that may not have been pushed to the front-end.
Box model.
Document compatibility mode.
description not provided :(
ContainerSelector logical axes
DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type.
Unique DOM node identifier.
ContainerSelector physical axes
Pseudo element type.
An array of quad vertices, x immediately followed by y for each point, points clock-wise.
Rectangle.
A structure holding an RGBA color.
Shadow root type.
CSS Shape Outside details.
Functions
Collects class names for the node with given id and all of it's child nodes.
Creates a deep copy of the specified node and places it into the target container before the given anchor.
Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation.
Disables DOM agent for the given page.
Discards search results from the session with the given id. getSearchResults
should no longer
be called for that search.
Enables DOM agent for the given page.
Focuses the given element.
Returns attributes for the specified node.
Returns boxes for the given node.
Returns the query container of the given node based on container query conditions: containerName, physical, and logical axes. If no axes are provided, the style container is returned, which is the direct parent or the closest element with a matching container-name.
Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.
Returns the root DOM node (and optionally the subtree) to the caller. Implicitly enables the DOM domain events for the current target.
Returns file information for the given File wrapper.
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 iframe node that owns iframe with the given domain.
Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.
Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation.
Finds nodes with a given computed style in a subtree.
Returns node's HTML markup.
Returns the descendants of a container query container that have container queries against this container.
Returns the id of the nearest ancestor that is a relayout boundary.
Returns search results from given fromIndex
to given toIndex
from the search with the given
identifier.
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.
Hides any highlight.
Highlights DOM node.
Highlights given rectangle.
Marks last undoable state.
Moves node into the new container, places it before the given anchor.
Searches for a given string in the DOM tree. Use getSearchResults
to access search results or
cancelSearch
to end this search session.
Requests that the node is sent to the caller given its path. // FIXME, use XPath
Requests that a batch of nodes is sent to the caller given their backend node ids.
Executes querySelector
on a given node.
Executes querySelectorAll
on a given node.
Re-does the last undone action.
Removes attribute with given name from an element with given id.
Removes node with given id.
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.
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.
Resolves the JavaScript node object for a given NodeId or BackendNodeId.
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.
Sets attribute for an element with given id.
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.
Sets files for the given file input element.
Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).
Sets node name for a node with given id.
Sets if stack traces should be captured for Nodes. See Node.getNodeStackTraces
. Default is disabled.
Sets node value for a node with given id.
Sets node HTML markup, returns new node id.
Undoes the last performed action.
Types
backend_node()
@type backend_node() :: %{ backendNodeId: backend_node_id(), nodeName: String.t(), nodeType: integer() }
Backend node with a friendly name.
backend_node_id()
@type backend_node_id() :: integer()
Unique DOM node identifier used to reference a node that may not have been pushed to the front-end.
box_model()
@type box_model() :: %{ border: quad(), content: quad(), height: integer(), margin: quad(), padding: quad(), shapeOutside: shape_outside_info() | nil, width: integer() }
Box model.
compatibility_mode()
@type compatibility_mode() :: :QuirksMode | :LimitedQuirksMode | :NoQuirksMode
Document compatibility mode.
css_computed_style_property()
description not provided :(
logical_axes()
@type logical_axes() :: :Inline | :Block | :Both
ContainerSelector logical axes
node_element()
@type node_element() :: %{ assignedSlot: backend_node() | nil, attributes: [String.t()] | nil, backendNodeId: backend_node_id(), baseURL: String.t() | nil, childNodeCount: integer() | nil, children: [node_element()] | nil, compatibilityMode: compatibility_mode() | nil, contentDocument: node_element() | nil, distributedNodes: [backend_node()] | nil, documentURL: String.t() | nil, frameId: CDPotion.Domain.Page.frame_id() | nil, importedDocument: node_element() | nil, internalSubset: String.t() | nil, isSVG: boolean() | nil, localName: String.t(), name: String.t() | nil, nodeId: node_id(), nodeName: String.t(), nodeType: integer(), nodeValue: String.t(), parentId: node_id() | nil, pseudoElements: [node_element()] | nil, pseudoIdentifier: String.t() | nil, pseudoType: pseudo_type() | nil, publicId: String.t() | nil, shadowRootType: shadow_root_type() | nil, shadowRoots: [node_element()] | nil, systemId: String.t() | nil, templateContent: node_element() | nil, value: String.t() | nil, xmlVersion: String.t() | nil }
DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type.
node_id()
@type node_id() :: integer()
Unique DOM node identifier.
physical_axes()
@type physical_axes() :: :Horizontal | :Vertical | :Both
ContainerSelector physical axes
pseudo_type()
@type pseudo_type() ::
:"first-line"
| :"first-letter"
| :before
| :after
| :marker
| :backdrop
| :selection
| :"target-text"
| :"spelling-error"
| :"grammar-error"
| :highlight
| :"first-line-inherited"
| :scrollbar
| :"scrollbar-thumb"
| :"scrollbar-button"
| :"scrollbar-track"
| :"scrollbar-track-piece"
| :"scrollbar-corner"
| :resizer
| :"input-list-button"
| :"view-transition"
| :"view-transition-group"
| :"view-transition-image-pair"
| :"view-transition-old"
| :"view-transition-new"
Pseudo element type.
quad()
@type quad() :: [number()]
An array of quad vertices, x immediately followed by y for each point, points clock-wise.
rect()
Rectangle.
rgba()
A structure holding an RGBA color.
shadow_root_type()
@type shadow_root_type() :: :"user-agent" | :open | :closed
Shadow root type.
shape_outside_info()
CSS Shape Outside details.
Functions
collect_class_names_from_subtree(node_id)
Collects class names for the node with given id and all of it's child nodes.
Parameters:
- (Required)
node_id
: Id of the node to collect class names.
copy_to(node_id, target_node_id, insert_before_node_id \\ nil)
Creates a deep copy of the specified node and places it into the target container before the given anchor.
Parameters:
- (Required)
node_id
: Id of the node to copy. - (Required)
target_node_id
: Id of the element to drop the copy into. - (Optional)
insert_before_node_id
: Drop the copy before this node (if absent, the copy becomes the last child oftargetNodeId
).
describe_node(node_id \\ nil, backend_node_id \\ nil, object_id \\ nil, depth \\ nil, pierce \\ nil)
@spec describe_node( node_id(), backend_node_id(), CDPotion.Domain.Runtime.remote_object_id(), integer(), boolean() ) :: {String.t(), map()}
Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation.
Parameters:
- (Optional)
node_id
: Identifier of the node. - (Optional)
backend_node_id
: Identifier of the backend node. - (Optional)
object_id
: JavaScript object id of the node wrapper. - (Optional)
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. - (Optional)
pierce
: Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
disable()
Disables DOM agent for the given page.
discard_search_results(search_id)
Discards search results from the session with the given id. getSearchResults
should no longer
be called for that search.
Parameters:
- (Required)
search_id
: Unique search session identifier.
enable(include_whitespace \\ nil)
Enables DOM agent for the given page.
Parameters:
- (Optional)
include_whitespace
: Whether to include whitespaces in the children array of returned Nodes.
focus(node_id \\ nil, backend_node_id \\ nil, object_id \\ nil)
@spec focus( node_id(), backend_node_id(), CDPotion.Domain.Runtime.remote_object_id() ) :: {String.t(), map()}
Focuses the given element.
Parameters:
- (Optional)
node_id
: Identifier of the node. - (Optional)
backend_node_id
: Identifier of the backend node. - (Optional)
object_id
: JavaScript object id of the node wrapper.
get_attributes(node_id)
Returns attributes for the specified node.
Parameters:
- (Required)
node_id
: Id of the node to retrieve attibutes for.
get_box_model(node_id \\ nil, backend_node_id \\ nil, object_id \\ nil)
@spec get_box_model( node_id(), backend_node_id(), CDPotion.Domain.Runtime.remote_object_id() ) :: {String.t(), map()}
Returns boxes for the given node.
Parameters:
- (Optional)
node_id
: Identifier of the node. - (Optional)
backend_node_id
: Identifier of the backend node. - (Optional)
object_id
: JavaScript object id of the node wrapper.
get_container_for_node(node_id, container_name \\ nil, physical_axes \\ nil, logical_axes \\ nil)
@spec get_container_for_node( node_id(), String.t(), physical_axes(), logical_axes() ) :: {String.t(), map()}
Returns the query container of the given node based on container query conditions: containerName, physical, and logical axes. If no axes are provided, the style container is returned, which is the direct parent or the closest element with a matching container-name.
Parameters:
- (Required)
node_id
: description not provided :( - (Optional)
container_name
: description not provided :( - (Optional)
physical_axes
: description not provided :( - (Optional)
logical_axes
: description not provided :(
get_content_quads(node_id \\ nil, backend_node_id \\ nil, object_id \\ nil)
@spec get_content_quads( node_id(), backend_node_id(), CDPotion.Domain.Runtime.remote_object_id() ) :: {String.t(), map()}
Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.
Parameters:
- (Optional)
node_id
: Identifier of the node. - (Optional)
backend_node_id
: Identifier of the backend node. - (Optional)
object_id
: JavaScript object id of the node wrapper.
get_document(depth \\ nil, pierce \\ nil)
Returns the root DOM node (and optionally the subtree) to the caller. Implicitly enables the DOM domain events for the current target.
Parameters:
- (Optional)
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. - (Optional)
pierce
: Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
get_file_info(object_id)
@spec get_file_info(CDPotion.Domain.Runtime.remote_object_id()) :: {String.t(), map()}
Returns file information for the given File wrapper.
Parameters:
- (Required)
object_id
: JavaScript object id of the node wrapper.
get_flattened_document(depth \\ nil, pierce \\ nil)
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:
- (Optional)
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. - (Optional)
pierce
: Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
get_frame_owner(frame_id)
@spec get_frame_owner(CDPotion.Domain.Page.frame_id()) :: {String.t(), map()}
Returns iframe node that owns iframe with the given domain.
Parameters:
- (Required)
frame_id
: description not provided :(
get_node_for_location(x, y, include_user_agent_shadow_dom \\ nil, ignore_pointer_events_none \\ nil)
Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.
Parameters:
- (Required)
x
: X coordinate. - (Required)
y
: Y coordinate. - (Optional)
include_user_agent_shadow_dom
: False to skip to the nearest non-UA shadow root ancestor (default: false). - (Optional)
ignore_pointer_events_none
: Whether to ignore pointer-events: none on elements and hit test them.
get_node_stack_traces(node_id)
Gets stack traces associated with a Node. As of now, only provides stack trace for Node creation.
Parameters:
- (Required)
node_id
: Id of the node to get stack traces for.
get_nodes_for_subtree_by_style(node_id, computed_styles, pierce \\ nil)
@spec get_nodes_for_subtree_by_style( node_id(), [css_computed_style_property()], boolean() ) :: {String.t(), map()}
Finds nodes with a given computed style in a subtree.
Parameters:
- (Required)
node_id
: Node ID pointing to the root of a subtree. - (Required)
computed_styles
: The style to filter nodes by (includes nodes if any of properties matches). - (Optional)
pierce
: Whether or not iframes and shadow roots in the same target should be traversed when returning the results (default is false).
get_outer_html(node_id \\ nil, backend_node_id \\ nil, object_id \\ nil)
@spec get_outer_html( node_id(), backend_node_id(), CDPotion.Domain.Runtime.remote_object_id() ) :: {String.t(), map()}
Returns node's HTML markup.
Parameters:
- (Optional)
node_id
: Identifier of the node. - (Optional)
backend_node_id
: Identifier of the backend node. - (Optional)
object_id
: JavaScript object id of the node wrapper.
get_querying_descendants_for_container(node_id)
Returns the descendants of a container query container that have container queries against this container.
Parameters:
- (Required)
node_id
: Id of the container node to find querying descendants from.
get_relayout_boundary(node_id)
Returns the id of the nearest ancestor that is a relayout boundary.
Parameters:
- (Required)
node_id
: Id of the node.
get_search_results(search_id, from_index, to_index)
Returns search results from given fromIndex
to given toIndex
from the search with the given
identifier.
Parameters:
- (Required)
search_id
: Unique search session identifier. - (Required)
from_index
: Start index of the search result to be returned. - (Required)
to_index
: End index of the search result to be returned.
get_top_layer_elements()
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.
hide_highlight()
Hides any highlight.
highlight_node()
Highlights DOM node.
highlight_rect()
Highlights given rectangle.
mark_undoable_state()
Marks last undoable state.
move_to(node_id, target_node_id, insert_before_node_id \\ nil)
Moves node into the new container, places it before the given anchor.
Parameters:
- (Required)
node_id
: Id of the node to move. - (Required)
target_node_id
: Id of the element to drop the moved node into. - (Optional)
insert_before_node_id
: Drop node before this one (if absent, the moved node becomes the last child oftargetNodeId
).
perform_search(query, include_user_agent_shadow_dom \\ nil)
Searches for a given string in the DOM tree. Use getSearchResults
to access search results or
cancelSearch
to end this search session.
Parameters:
- (Required)
query
: Plain text or query selector or XPath search query. - (Optional)
include_user_agent_shadow_dom
: True to search in user agent shadow DOM.
push_node_by_path_to_frontend(path)
Requests that the node is sent to the caller given its path. // FIXME, use XPath
Parameters:
- (Required)
path
: Path to node in the proprietary format.
push_nodes_by_backend_ids_to_frontend(backend_node_ids)
@spec push_nodes_by_backend_ids_to_frontend([backend_node_id()]) :: {String.t(), map()}
Requests that a batch of nodes is sent to the caller given their backend node ids.
Parameters:
- (Required)
backend_node_ids
: The array of backend node ids.
query_selector(node_id, selector)
Executes querySelector
on a given node.
Parameters:
- (Required)
node_id
: Id of the node to query upon. - (Required)
selector
: Selector string.
query_selector_all(node_id, selector)
Executes querySelectorAll
on a given node.
Parameters:
- (Required)
node_id
: Id of the node to query upon. - (Required)
selector
: Selector string.
redo()
Re-does the last undone action.
remove_attribute(node_id, name)
Removes attribute with given name from an element with given id.
Parameters:
- (Required)
node_id
: Id of the element to remove attribute from. - (Required)
name
: Name of the attribute to remove.
remove_node(node_id)
Removes node with given id.
Parameters:
- (Required)
node_id
: Id of the node to remove.
request_child_nodes(node_id, depth \\ nil, pierce \\ nil)
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:
- (Required)
node_id
: Id of the node to get children for. - (Optional)
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. - (Optional)
pierce
: Whether or not iframes and shadow roots should be traversed when returning the sub-tree (default is false).
request_node(object_id)
@spec request_node(CDPotion.Domain.Runtime.remote_object_id()) :: {String.t(), map()}
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:
- (Required)
object_id
: JavaScript object id to convert into node.
resolve_node(node_id \\ nil, backend_node_id \\ nil, object_group \\ nil, execution_context_id \\ nil)
@spec resolve_node( node_id(), backend_node_id(), String.t(), CDPotion.Domain.Runtime.execution_context_id() ) :: {String.t(), map()}
Resolves the JavaScript node object for a given NodeId or BackendNodeId.
Parameters:
- (Optional)
node_id
: Id of the node to resolve. - (Optional)
backend_node_id
: Backend identifier of the node to resolve. - (Optional)
object_group
: Symbolic group name that can be used to release multiple objects. - (Optional)
execution_context_id
: Execution context in which to resolve the node.
scroll_into_view_if_needed(node_id \\ nil, backend_node_id \\ nil, object_id \\ nil, rect \\ nil)
@spec scroll_into_view_if_needed( node_id(), backend_node_id(), CDPotion.Domain.Runtime.remote_object_id(), rect() ) :: {String.t(), map()}
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:
- (Optional)
node_id
: Identifier of the node. - (Optional)
backend_node_id
: Identifier of the backend node. - (Optional)
object_id
: JavaScript object id of the node wrapper. - (Optional)
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.
set_attribute_value(node_id, name, value)
Sets attribute for an element with given id.
Parameters:
- (Required)
node_id
: Id of the element to set attribute for. - (Required)
name
: Attribute name. - (Required)
value
: Attribute value.
set_attributes_as_text(node_id, text, name \\ nil)
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:
- (Required)
node_id
: Id of the element to set attributes for. - (Required)
text
: Text with a number of attributes. Will parse this text using HTML parser. - (Optional)
name
: Attribute name to replace with new attributes derived from text in case text parsed successfully.
set_file_input_files(files, node_id \\ nil, backend_node_id \\ nil, object_id \\ nil)
@spec set_file_input_files( [String.t()], node_id(), backend_node_id(), CDPotion.Domain.Runtime.remote_object_id() ) :: {String.t(), map()}
Sets files for the given file input element.
Parameters:
- (Required)
files
: Array of file paths to set. - (Optional)
node_id
: Identifier of the node. - (Optional)
backend_node_id
: Identifier of the backend node. - (Optional)
object_id
: JavaScript object id of the node wrapper.
set_inspected_node(node_id)
Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).
Parameters:
- (Required)
node_id
: DOM node id to be accessible by means of $x command line API.
set_node_name(node_id, name)
Sets node name for a node with given id.
Parameters:
- (Required)
node_id
: Id of the node to set name for. - (Required)
name
: New node's name.
set_node_stack_traces_enabled(enable)
Sets if stack traces should be captured for Nodes. See Node.getNodeStackTraces
. Default is disabled.
Parameters:
- (Required)
enable
: Enable or disable.
set_node_value(node_id, value)
Sets node value for a node with given id.
Parameters:
- (Required)
node_id
: Id of the node to set value for. - (Required)
value
: New node's value.
set_outer_html(node_id, outer_html)
Sets node HTML markup, returns new node id.
Parameters:
- (Required)
node_id
: Id of the node to set markup for. - (Required)
outer_html
: Outer HTML markup to set.
undo()
Undoes the last performed action.