Tungsten v0.1.0 Tungsten.CDP.Target View Source

Target

Supports additional targets discovery and allows to attach to them.

Link to this section Summary

Link to this section Types

Link to this type

cdp_browser_context_id_type() View Source
cdp_browser_context_id_type() :: String.t()

Target.BrowserContextID

This type has no documentation

Link to this type

cdp_remote_location_type() View Source
cdp_remote_location_type() :: %{host: String.t(), port: integer()}

Target.RemoteLocation

This type has no documentation

Link to this type

cdp_session_id_type() View Source
cdp_session_id_type() :: String.t()

Target.SessionID

Unique identifier of attached debugging session.

Link to this type

cdp_target_id_type() View Source
cdp_target_id_type() :: String.t()

Target.TargetID

This type has no documentation

Link to this type

cdp_target_info_type() View Source
cdp_target_info_type() :: %{
  :target_id => cdp_target_id_type(),
  :type => String.t(),
  :title => String.t(),
  :url => String.t(),
  :attached => boolean(),
  optional(:opener_id) => cdp_target_id_type(),
  optional(:browser_context_id) => cdp_browser_context_id_type()
}

Target.TargetInfo

This type has no documentation

Link to this section Functions

Link to this function

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

Target.activateTarget

Activates (focuses) the target.

Link to this function

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

Target.attachToBrowserTarget

Attaches to the browser target, only uses flat sessionId mode.

Link to this function

attach_to_target(session, parameters, options \\ []) View Source
attach_to_target(
  GenServer.server(),
  %{:target_id => cdp_target_id_type(), optional(:flatten) => boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{session_id: cdp_session_id_type()}} | {:error, term()}

Target.attachToTarget

Attaches to the target with given id.

Link to this function

close_target(session, parameters, options \\ []) View Source
close_target(
  GenServer.server(),
  %{target_id: cdp_target_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{success: boolean()}} | {:error, term()}

Target.closeTarget

Closes the target. If the target is a page that gets closed too.

Link to this function

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

Target.createBrowserContext

Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.

Link to this function

create_target(session, parameters, options \\ []) View Source
create_target(
  GenServer.server(),
  %{
    :url => String.t(),
    optional(:width) => integer(),
    optional(:height) => integer(),
    optional(:browser_context_id) => cdp_browser_context_id_type(),
    optional(:enable_begin_frame_control) => boolean()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{target_id: cdp_target_id_type()}} | {:error, term()}

Target.createTarget

Creates a new page.

Link to this function

detach_from_target(session, parameters \\ %{}, options \\ []) View Source
detach_from_target(
  GenServer.server(),
  %{
    optional(:session_id) => cdp_session_id_type(),
    optional(:target_id) => cdp_target_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Target.detachFromTarget

Detaches session with given id.

Link to this function

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

Target.disposeBrowserContext

Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.

Link to this function

expose_dev_tools_protocol(session, parameters, options \\ []) View Source
expose_dev_tools_protocol(
  GenServer.server(),
  %{:target_id => cdp_target_id_type(), optional(:binding_name) => String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Target.exposeDevToolsProtocol

Inject object to the target's main frame that provides a communication channel with browser target.

Injected object will be available as window[bindingName].

The object has the follwing API:

  • binding.send(json) - a method to send messages over the remote debugging protocol
  • binding.onmessage = json => handleMessage(json) - a callback that will be called for the protocol notifications and command responses.
Link to this function

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

Target.getBrowserContexts

Returns all browser contexts created with Target.createBrowserContext method.

Link to this function

get_target_info(session, parameters \\ %{}, options \\ []) View Source
get_target_info(
  GenServer.server(),
  %{optional(:target_id) => cdp_target_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{target_info: cdp_target_info_type()}} | {:error, term()}

Target.getTargetInfo

Returns information about a target.

Link to this function

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

Target.getTargets

Retrieves a list of available targets.

Link to this function

send_message_to_target(session, parameters, options \\ []) View Source
send_message_to_target(
  GenServer.server(),
  %{
    :message => String.t(),
    optional(:session_id) => cdp_session_id_type(),
    optional(:target_id) => cdp_target_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Target.sendMessageToTarget

Sends protocol message over session with given id.

Link to this function

set_auto_attach(session, parameters, options \\ []) View Source
set_auto_attach(
  GenServer.server(),
  %{
    :auto_attach => boolean(),
    :wait_for_debugger_on_start => boolean(),
    optional(:flatten) => boolean()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Target.setAutoAttach

Controls whether to automatically attach to new targets which are considered to be related to this one. When turned on, attaches to all existing related targets as well. When turned off, automatically detaches from all currently attached targets.

Link to this function

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

Target.setDiscoverTargets

Controls whether to discover available targets and notify via targetCreated/targetInfoChanged/targetDestroyed events.

Link to this function

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

Target.setRemoteLocations

Enables target discovery for the specified locations, when setDiscoverTargets was set to true.