Chrome Remote Interface v0.0.4 ChromeRemoteInterface.PageSession View Source

This module is responsible for all things connected to a Page.

  • Spawning a process that manages the websocket connection
  • Handling request/response for RPC calls by maintaining unique message IDs
  • Forwarding Domain events to subscribers.

Link to this section Summary

Functions

Executes a raw JSON RPC command through Websockets

Executes a raw JSON RPC command through Websockets, but sends the response as a message to the requesting process

Executes an RPC command with the given options

Connect to a Page’s ‘webSocketDebuggerUrl’

Stop the websocket connection to the page

Link to this section Functions

Link to this function call(pid, method, params) View Source

Executes a raw JSON RPC command through Websockets.

Link to this function cast(pid, method, params, from \\ self()) View Source

Executes a raw JSON RPC command through Websockets, but sends the response as a message to the requesting process.

Link to this function execute_command(pid, method, params, opts) View Source

Executes an RPC command with the given options.

Options: :async - If a boolean, sends the response as a message to the current process. Else, if provided with a PID, it will send the response to that process instead.

Connect to a Page’s ‘webSocketDebuggerUrl’.

Stop the websocket connection to the page.

Link to this function subscribe(pid, event, subscriber_pid \\ self()) View Source
subscribe(pid, String.t, pid) :: any

Subscribe to an event.

Events that get fired will be returned to the subscribed process under the following format:

{:chrome_remote_interface, event_name, response}

Please note that you must also enable events for that domain!

Example:

iex> ChromeRemoteInterface.RPC.Page.enable(page_pid)
iex> ChromeRemoteInterface.PageSession.subscribe(page_pid, "Page.loadEventFired")
iex> ChromeRemoteInterface.RPC.Page.navigate(page_pid, %{url: "https://google.com"})
iex> flush()
{:chrome_remote_interface, "Page.loadEventFirst", %{"method" => "Page.loadEventFired",
   "params" => %{"timestamp" => 1012329.888558}}}
Link to this function unsubscribe(pid, event, subscriber_pid \\ self()) View Source
unsubscribe(pid, String.t, pid) :: any

Unsubscribes from an event.

Link to this function unsubscribe_all(pid, subscriber_pid \\ self()) View Source

Unsubcribes to all events.