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
Subscribe to an event
Unsubscribes from an event
Unsubcribes to all events
Link to this section 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.
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.
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}}}
unsubscribe(pid, String.t, pid) :: any
Unsubscribes from an event.
Unsubcribes to all events.