Main entry point. Elixir client for the Playwright node.js driver.
Use launch_browser/2 to get started after adding PlaywrightEx.Supervisor to your supervision tree.
See the README for getting started and more details.
Summary
Functions
Launches a new browser instance, or returns the pre-launched browser when connected to a remote Playwright server.
Send message to playwright.
Subscribe to playwright responses concerning a resource, identified by its guid.
Messages in the format {:playwright_msg, %{} = msg} will be sent to pid.
Unsubscribe from playwright responses concerning a resource, identified by its guid.
Types
@type guid() :: String.t()
@type send_opt() :: {:connection, GenServer.name()} | {:timeout, timeout()}
@type subscribe_opt() :: {:connection, GenServer.name()} | {:pid, pid()}
@type unknown_opt() :: {Keyword.key(), Keyword.value()}
Functions
@spec launch_browser(atom(), [PlaywrightEx.BrowserType.launch_opt() | unknown_opt()]) :: {:ok, %{guid: guid()}} | {:error, any()}
Launches a new browser instance, or returns the pre-launched browser when connected to a remote Playwright server.
Options
:connection(term/0) - The Connection process name. Defaults toPlaywrightEx.Supervisor.Connection. The default value isPlaywrightEx.Supervisor.Connection.:timeout(timeout/0) - Required. Maximum time for the operation (milliseconds).:channel(String.t/0) - Browser distribution channel.:args(list ofString.t/0) - Additional command-line arguments passed to the browser.:executable_path(String.t/0) - Path to a browser executable to run instead of the bundled one.:ignore_all_default_args(boolean/0) - Whether to omit all Playwright default browser arguments.:ignore_default_args(list ofString.t/0) - Specific Playwright default browser arguments to omit.:handle_sigint(boolean/0) - Whether Playwright handles SIGINT.:handle_sigterm(boolean/0) - Whether Playwright handles SIGTERM.:handle_sighup(boolean/0) - Whether Playwright handles SIGHUP.:env- Environment variables as a map or Playwright name/value entries.:headless(boolean/0) - Whether to run browser in headless mode.:proxy(map/0) - Proxy settings for the browser process.:downloads_path(String.t/0) - Directory in which to place downloads.:traces_dir(String.t/0) - Directory in which to place tracing data.:artifacts_dir(String.t/0) - Directory in which to place browser artifacts.:chromium_sandbox(boolean/0) - Whether Chromium sandboxing is enabled.:firefox_user_prefs- Firefox preferences, preserved as an opaque JSON object.:cdp_port(non_neg_integer/0) - Chrome DevTools Protocol port.:slow_mo- Slows down Playwright operations by the specified amount of milliseconds.
Send message to playwright.
Don't use this! Prefer Channels functions.
If a function is missing, consider opening a PR to add it.
Options
@spec subscribe(guid(), [subscribe_opt()]) :: :ok
Subscribe to playwright responses concerning a resource, identified by its guid.
Messages in the format {:playwright_msg, %{} = msg} will be sent to pid.
Options
@spec unsubscribe(guid(), [subscribe_opt()]) :: :ok
Unsubscribe from playwright responses concerning a resource, identified by its guid.