Playwriter.Transport.Behaviour behaviour (Playwriter v0.1.0)

Copy Markdown View Source

Behaviour defining the transport interface for Playwright communication.

Transports abstract how Playwriter communicates with Playwright:

Summary

Callbacks

Get page content

Check if transport is healthy

Create a new browser context

Create a new page in a context

Send a message to Playwright and wait for response

Start the transport connection

Stop the transport

Types

browser_type()

@type browser_type() :: :chromium | :firefox | :webkit

guid()

@type guid() :: String.t()

message()

@type message() :: map()

result()

@type result() :: {:ok, map()} | {:error, term()}

transport()

@type transport() :: pid() | GenServer.server()

Callbacks

click(transport, guid, t, keyword)

@callback click(transport(), guid(), String.t(), keyword()) :: :ok | {:error, term()}

Click an element

close_browser(transport, guid)

@callback close_browser(transport(), guid()) :: :ok | {:error, term()}

Close a browser

close_context(transport, guid)

@callback close_context(transport(), guid()) :: :ok | {:error, term()}

Close a context

close_page(transport, guid)

@callback close_page(transport(), guid()) :: :ok | {:error, term()}

Close a page

content(transport, guid)

@callback content(transport(), guid()) :: {:ok, String.t()} | {:error, term()}

Get page content

fill(transport, guid, t, t, keyword)

@callback fill(transport(), guid(), String.t(), String.t(), keyword()) ::
  :ok | {:error, term()}

Fill an input

goto(transport, guid, t, keyword)

@callback goto(transport(), guid(), String.t(), keyword()) :: result()

Navigate to a URL

healthy?(transport)

@callback healthy?(transport()) :: boolean()

Check if transport is healthy

launch_browser(transport, browser_type, keyword)

@callback launch_browser(transport(), browser_type(), keyword()) ::
  {:ok, guid()} | {:error, term()}

Launch a browser instance

new_context(transport, guid, keyword)

@callback new_context(transport(), guid(), keyword()) :: {:ok, guid()} | {:error, term()}

Create a new browser context

new_page(transport, guid)

@callback new_page(transport(), guid()) :: {:ok, map()} | {:error, term()}

Create a new page in a context

screenshot(transport, guid, keyword)

@callback screenshot(transport(), guid(), keyword()) :: {:ok, binary()} | {:error, term()}

Take a screenshot

send_message(transport, message, timeout)

@callback send_message(transport(), message(), timeout()) :: result()

Send a message to Playwright and wait for response

start_link(keyword)

@callback start_link(keyword()) :: {:ok, pid()} | {:error, term()}

Start the transport connection

stop(transport)

@callback stop(transport()) :: :ok

Stop the transport