Tungsten v0.1.0 Tungsten.CDP.DOM View Source

DOM

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.

Link to this section Summary

Functions

Link to this section Types

Link to this type

cdp_backend_node_id_type() View Source
cdp_backend_node_id_type() :: integer()

DOM.BackendNodeId

Unique DOM node identifier used to reference a node that may not have been pushed to the front-end.

Link to this type

cdp_backend_node_type() View Source
cdp_backend_node_type() :: %{
  node_type: integer(),
  node_name: String.t(),
  backend_node_id: cdp_backend_node_id_type()
}

DOM.BackendNode

Backend node with a friendly name.

Link to this type

cdp_box_model_type() View Source
cdp_box_model_type() :: %{
  :content => cdp_quad_type(),
  :padding => cdp_quad_type(),
  :border => cdp_quad_type(),
  :margin => cdp_quad_type(),
  :width => integer(),
  :height => integer(),
  optional(:shape_outside) => cdp_shape_outside_info_type()
}

DOM.BoxModel

Box model.

Link to this type

cdp_node_id_type() View Source
cdp_node_id_type() :: integer()

DOM.NodeId

Unique DOM node identifier.

Link to this type

cdp_node_type() View Source
cdp_node_type() :: %{
  :node_id => cdp_node_id_type(),
  optional(:parent_id) => cdp_node_id_type(),
  :backend_node_id => cdp_backend_node_id_type(),
  :node_type => integer(),
  :node_name => String.t(),
  :local_name => String.t(),
  :node_value => String.t(),
  optional(:child_node_count) => integer(),
  optional(:children) => [cdp_node_type()],
  optional(:attributes) => [String.t()],
  optional(:document_url) => String.t(),
  optional(:base_url) => String.t(),
  optional(:public_id) => String.t(),
  optional(:system_id) => String.t(),
  optional(:internal_subset) => String.t(),
  optional(:xml_version) => String.t(),
  optional(:name) => String.t(),
  optional(:value) => String.t(),
  optional(:pseudo_type) => cdp_pseudo_type_type(),
  optional(:shadow_root_type) => cdp_shadow_root_type_type(),
  optional(:frame_id) => Tungsten.CDP.Page.cdp_frame_id_type(),
  optional(:content_document) => cdp_node_type(),
  optional(:shadow_roots) => [cdp_node_type()],
  optional(:template_content) => cdp_node_type(),
  optional(:pseudo_elements) => [cdp_node_type()],
  optional(:imported_document) => cdp_node_type(),
  optional(:distributed_nodes) => [cdp_backend_node_type()],
  optional(:is_svg) => boolean()
}

DOM.Node

DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type.

Link to this type

cdp_pseudo_type_type() View Source
cdp_pseudo_type_type() ::
  :"input-list-button"
  | :resizer
  | :"scrollbar-corner"
  | :"scrollbar-track-piece"
  | :"scrollbar-track"
  | :"scrollbar-button"
  | :"scrollbar-thumb"
  | :scrollbar
  | :"first-line-inherited"
  | :selection
  | :backdrop
  | :after
  | :before
  | :"first-letter"
  | :"first-line"

DOM.PseudoType

Pseudo element type.

Link to this type

cdp_quad_type() View Source
cdp_quad_type() :: [integer() | float()]

DOM.Quad

An array of quad vertices, x immediately followed by y for each point, points clock-wise.

Link to this type

cdp_rect_type() View Source
cdp_rect_type() :: %{
  x: integer() | float(),
  y: integer() | float(),
  width: integer() | float(),
  height: integer() | float()
}

DOM.Rect

Rectangle.

Link to this type

cdp_rgba_type() View Source
cdp_rgba_type() :: %{
  :r => integer(),
  :g => integer(),
  :b => integer(),
  optional(:a) => integer() | float()
}

DOM.RGBA

A structure holding an RGBA color.

Link to this type

cdp_shadow_root_type_type() View Source
cdp_shadow_root_type_type() :: :closed | :open | :"user-agent"

DOM.ShadowRootType

Shadow root type.

Link to this type

cdp_shape_outside_info_type() View Source
cdp_shape_outside_info_type() :: %{
  bounds: cdp_quad_type(),
  shape: [any()],
  margin_shape: [any()]
}

DOM.ShapeOutsideInfo

CSS Shape Outside details.

Link to this section Functions

Link to this function

collect_class_names_from_subtree(session, parameters, options \\ []) View Source
collect_class_names_from_subtree(
  GenServer.server(),
  %{node_id: cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{class_names: [String.t()]}} | {:error, term()}

DOM.collectClassNamesFromSubtree

Collects class names for the node with given id and all of it's child nodes.

Link to this function

copy_to(session, parameters, options \\ []) View Source
copy_to(
  GenServer.server(),
  %{
    :node_id => cdp_node_id_type(),
    :target_node_id => cdp_node_id_type(),
    optional(:insert_before_node_id) => cdp_node_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_id: cdp_node_id_type()}} | {:error, term()}

DOM.copyTo

Creates a deep copy of the specified node and places it into the target container before the given anchor.

Link to this function

describe_node(session, parameters \\ %{}, options \\ []) View Source
describe_node(
  GenServer.server(),
  %{
    optional(:node_id) => cdp_node_id_type(),
    optional(:backend_node_id) => cdp_backend_node_id_type(),
    optional(:object_id) => Tungsten.CDP.Runtime.cdp_remote_object_id_type(),
    optional(:depth) => integer(),
    optional(:pierce) => boolean()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{node: cdp_node_type()}} | {:error, term()}

DOM.describeNode

Describes node given its id, does not require domain to be enabled. Does not start tracking any objects, can be used for automation.

Link to this function

disable(session, parameters \\ %{}, options \\ []) View Source
disable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

DOM.disable

Disables DOM agent for the given page.

Link to this function

discard_search_results(session, parameters, options \\ []) View Source
discard_search_results(
  GenServer.server(),
  %{search_id: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.discardSearchResults

Discards search results from the session with the given id. getSearchResults should no longer be called for that search.

Link to this function

enable(session, parameters \\ %{}, options \\ []) View Source
enable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

DOM.enable

Enables DOM agent for the given page.

Link to this function

focus(session, parameters \\ %{}, options \\ []) View Source
focus(
  GenServer.server(),
  %{
    optional(:node_id) => cdp_node_id_type(),
    optional(:backend_node_id) => cdp_backend_node_id_type(),
    optional(:object_id) => Tungsten.CDP.Runtime.cdp_remote_object_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.focus

Focuses the given element.

Link to this function

get_attributes(session, parameters, options \\ []) View Source
get_attributes(
  GenServer.server(),
  %{node_id: cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{attributes: [String.t()]}} | {:error, term()}

DOM.getAttributes

Returns attributes for the specified node.

Link to this function

get_box_model(session, parameters \\ %{}, options \\ []) View Source
get_box_model(
  GenServer.server(),
  %{
    optional(:node_id) => cdp_node_id_type(),
    optional(:backend_node_id) => cdp_backend_node_id_type(),
    optional(:object_id) => Tungsten.CDP.Runtime.cdp_remote_object_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{model: cdp_box_model_type()}} | {:error, term()}

DOM.getBoxModel

Returns boxes for the given node.

Link to this function

get_content_quads(session, parameters \\ %{}, options \\ []) View Source
get_content_quads(
  GenServer.server(),
  %{
    optional(:node_id) => cdp_node_id_type(),
    optional(:backend_node_id) => cdp_backend_node_id_type(),
    optional(:object_id) => Tungsten.CDP.Runtime.cdp_remote_object_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{quads: [cdp_quad_type()]}} | {:error, term()}

DOM.getContentQuads

Returns quads that describe node position on the page. This method might return multiple quads for inline nodes.

Link to this function

get_document(session, parameters \\ %{}, options \\ []) View Source
get_document(
  GenServer.server(),
  %{optional(:depth) => integer(), optional(:pierce) => boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{root: cdp_node_type()}} | {:error, term()}

DOM.getDocument

Returns the root DOM node (and optionally the subtree) to the caller.

Link to this function

get_file_info(session, parameters, options \\ []) View Source
get_file_info(
  GenServer.server(),
  %{object_id: Tungsten.CDP.Runtime.cdp_remote_object_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{path: String.t()}} | {:error, term()}

DOM.getFileInfo

Returns file information for the given File wrapper.

Link to this function

get_flattened_document(session, parameters \\ %{}, options \\ []) View Source
get_flattened_document(
  GenServer.server(),
  %{optional(:depth) => integer(), optional(:pierce) => boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{nodes: [cdp_node_type()]}} | {:error, term()}

DOM.getFlattenedDocument

Returns the root DOM node (and optionally the subtree) to the caller.

Link to this function

get_frame_owner(session, parameters, options \\ []) View Source
get_frame_owner(
  GenServer.server(),
  %{frame_id: Tungsten.CDP.Page.cdp_frame_id_type()},
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :backend_node_id => cdp_backend_node_id_type(),
     optional(:node_id) => cdp_node_id_type()
   }}
  | {:error, term()}

DOM.getFrameOwner

Returns iframe node that owns iframe with the given domain.

Link to this function

get_node_for_location(session, parameters, options \\ []) View Source
get_node_for_location(
  GenServer.server(),
  %{
    :x => integer(),
    :y => integer(),
    optional(:include_user_agent_shadow_dom) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :backend_node_id => cdp_backend_node_id_type(),
     optional(:node_id) => cdp_node_id_type()
   }}
  | {:error, term()}

DOM.getNodeForLocation

Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is either returned or not.

Link to this function

get_outer_html(session, parameters \\ %{}, options \\ []) View Source
get_outer_html(
  GenServer.server(),
  %{
    optional(:node_id) => cdp_node_id_type(),
    optional(:backend_node_id) => cdp_backend_node_id_type(),
    optional(:object_id) => Tungsten.CDP.Runtime.cdp_remote_object_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{outer_html: String.t()}} | {:error, term()}

DOM.getOuterHTML

Returns node's HTML markup.

Link to this function

get_relayout_boundary(session, parameters, options \\ []) View Source
get_relayout_boundary(
  GenServer.server(),
  %{node_id: cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_id: cdp_node_id_type()}} | {:error, term()}

DOM.getRelayoutBoundary

Returns the id of the nearest ancestor that is a relayout boundary.

Link to this function

get_search_results(session, parameters, options \\ []) View Source
get_search_results(
  GenServer.server(),
  %{search_id: String.t(), from_index: integer(), to_index: integer()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_ids: [cdp_node_id_type()]}} | {:error, term()}

DOM.getSearchResults

Returns search results from given fromIndex to given toIndex from the search with the given identifier.

Link to this function

hide_highlight(session, parameters \\ %{}, options \\ []) View Source
hide_highlight(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

DOM.hideHighlight

Hides any highlight.

Link to this function

highlight_node(session, parameters \\ %{}, options \\ []) View Source
highlight_node(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

DOM.highlightNode

Highlights DOM node.

Link to this function

highlight_rect(session, parameters \\ %{}, options \\ []) View Source
highlight_rect(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

DOM.highlightRect

Highlights given rectangle.

Link to this function

mark_undoable_state(session, parameters \\ %{}, options \\ []) View Source
mark_undoable_state(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.markUndoableState

Marks last undoable state.

Link to this function

move_to(session, parameters, options \\ []) View Source
move_to(
  GenServer.server(),
  %{
    :node_id => cdp_node_id_type(),
    :target_node_id => cdp_node_id_type(),
    optional(:insert_before_node_id) => cdp_node_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_id: cdp_node_id_type()}} | {:error, term()}

DOM.moveTo

Moves node into the new container, places it before the given anchor.

Link to this function

perform_search(session, parameters, options \\ []) View Source
perform_search(
  GenServer.server(),
  %{
    :query => String.t(),
    optional(:include_user_agent_shadow_dom) => boolean()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{search_id: String.t(), result_count: integer()}} | {:error, term()}

DOM.performSearch

Searches for a given string in the DOM tree. Use getSearchResults to access search results or cancelSearch to end this search session.

Link to this function

push_node_by_path_to_frontend(session, parameters, options \\ []) View Source
push_node_by_path_to_frontend(
  GenServer.server(),
  %{path: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_id: cdp_node_id_type()}} | {:error, term()}

DOM.pushNodeByPathToFrontend

Requests that the node is sent to the caller given its path. // FIXME, use XPath

Link to this function

push_nodes_by_backend_ids_to_frontend(session, parameters, options \\ []) View Source
push_nodes_by_backend_ids_to_frontend(
  GenServer.server(),
  %{backend_node_ids: [cdp_backend_node_id_type()]},
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_ids: [cdp_node_id_type()]}} | {:error, term()}

DOM.pushNodesByBackendIdsToFrontend

Requests that a batch of nodes is sent to the caller given their backend node ids.

Link to this function

query_selector(session, parameters, options \\ []) View Source
query_selector(
  GenServer.server(),
  %{node_id: cdp_node_id_type(), selector: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_id: cdp_node_id_type()}} | {:error, term()}

DOM.querySelector

Executes querySelector on a given node.

Link to this function

query_selector_all(session, parameters, options \\ []) View Source
query_selector_all(
  GenServer.server(),
  %{node_id: cdp_node_id_type(), selector: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_ids: [cdp_node_id_type()]}} | {:error, term()}

DOM.querySelectorAll

Executes querySelectorAll on a given node.

Link to this function

redo(session, parameters \\ %{}, options \\ []) View Source
redo(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

DOM.redo

Re-does the last undone action.

Link to this function

remove_attribute(session, parameters, options \\ []) View Source
remove_attribute(
  GenServer.server(),
  %{node_id: cdp_node_id_type(), name: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.removeAttribute

Removes attribute with given name from an element with given id.

Link to this function

remove_node(session, parameters, options \\ []) View Source
remove_node(
  GenServer.server(),
  %{node_id: cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.removeNode

Removes node with given id.

Link to this function

request_child_nodes(session, parameters, options \\ []) View Source
request_child_nodes(
  GenServer.server(),
  %{
    :node_id => cdp_node_id_type(),
    optional(:depth) => integer(),
    optional(:pierce) => boolean()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.requestChildNodes

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.

Link to this function

request_node(session, parameters, options \\ []) View Source
request_node(
  GenServer.server(),
  %{object_id: Tungsten.CDP.Runtime.cdp_remote_object_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_id: cdp_node_id_type()}} | {:error, term()}

DOM.requestNode

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.

Link to this function

resolve_node(session, parameters \\ %{}, options \\ []) View Source
resolve_node(
  GenServer.server(),
  %{
    optional(:node_id) => cdp_node_id_type(),
    optional(:backend_node_id) => Tungsten.CDP.DOM.cdp_backend_node_id_type(),
    optional(:object_group) => String.t(),
    optional(:execution_context_id) =>
      Tungsten.CDP.Runtime.cdp_execution_context_id_type()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{object: Tungsten.CDP.Runtime.cdp_remote_object_type()}}
  | {:error, term()}

DOM.resolveNode

Resolves the JavaScript node object for a given NodeId or BackendNodeId.

Link to this function

set_attribute_value(session, parameters, options \\ []) View Source
set_attribute_value(
  GenServer.server(),
  %{node_id: cdp_node_id_type(), name: String.t(), value: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.setAttributeValue

Sets attribute for an element with given id.

Link to this function

set_attributes_as_text(session, parameters, options \\ []) View Source
set_attributes_as_text(
  GenServer.server(),
  %{
    :node_id => cdp_node_id_type(),
    :text => String.t(),
    optional(:name) => String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.setAttributesAsText

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.

Link to this function

set_file_input_files(session, parameters, options \\ []) View Source
set_file_input_files(
  GenServer.server(),
  %{
    :files => [String.t()],
    optional(:node_id) => cdp_node_id_type(),
    optional(:backend_node_id) => cdp_backend_node_id_type(),
    optional(:object_id) => Tungsten.CDP.Runtime.cdp_remote_object_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.setFileInputFiles

Sets files for the given file input element.

Link to this function

set_inspected_node(session, parameters, options \\ []) View Source
set_inspected_node(
  GenServer.server(),
  %{node_id: cdp_node_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.setInspectedNode

Enables console to refer to the node with given id via $x (see Command Line API for more details $x functions).

Link to this function

set_node_name(session, parameters, options \\ []) View Source
set_node_name(
  GenServer.server(),
  %{node_id: cdp_node_id_type(), name: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{node_id: cdp_node_id_type()}} | {:error, term()}

DOM.setNodeName

Sets node name for a node with given id.

Link to this function

set_node_value(session, parameters, options \\ []) View Source
set_node_value(
  GenServer.server(),
  %{node_id: cdp_node_id_type(), value: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.setNodeValue

Sets node value for a node with given id.

Link to this function

set_outer_html(session, parameters, options \\ []) View Source
set_outer_html(
  GenServer.server(),
  %{node_id: cdp_node_id_type(), outer_html: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

DOM.setOuterHTML

Sets node HTML markup, returns new node id.

Link to this function

undo(session, parameters \\ %{}, options \\ []) View Source
undo(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

DOM.undo

Undoes the last performed action.