# `PlaywrightEx`
[🔗](https://github.com/probably-not/playwright_ex/blob/v0.5.0-fork.2/lib/playwright_ex.ex#L1)

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](readme.html) for getting started and more details.

# `guid`

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

# `send_opt`

```elixir
@type send_opt() :: {:connection, GenServer.name()} | {:timeout, timeout()}
```

# `subscribe_opt`

```elixir
@type subscribe_opt() :: {:connection, GenServer.name()} | {:pid, pid()}
```

# `unknown_opt`

```elixir
@type unknown_opt() :: {Keyword.key(), Keyword.value()}
```

# `launch_browser`

```elixir
@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` (`t:term/0`) - The Connection process name. Defaults to `PlaywrightEx.Supervisor.Connection`. The default value is `PlaywrightEx.Supervisor.Connection`.

* `:timeout` (`t:timeout/0`) - Required. Maximum time for the operation (milliseconds).

* `:channel` (`t:String.t/0`) - Browser distribution channel.

* `:executable_path` (`t:String.t/0`) - Path to a browser executable to run instead of the bundled one.

* `:headless` (`t:boolean/0`) - Whether to run browser in headless mode.

* `:slow_mo` - Slows down Playwright operations by the specified amount of milliseconds.

# `send`

```elixir
@spec send(%{guid: guid(), method: atom()}, [send_opt()]) ::
  %{result: map()} | %{error: map()}
```

Send message to playwright.

Don't use this! Prefer `Channels` functions.
If a function is missing, consider [opening a PR](https://github.com/ftes/playwright_ex/pulls) to add it.

## Options
* `:connection` (`t:term/0`) - The Connection process name. Defaults to `PlaywrightEx.Supervisor.Connection`. The default value is `PlaywrightEx.Supervisor.Connection`.

* `:timeout` (`t:timeout/0`) - Required. Maximum time for the operation (milliseconds).

# `subscribe`

```elixir
@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
* `:connection` (`t:term/0`) - The Connection process name. Defaults to `PlaywrightEx.Supervisor.Connection`. The default value is `PlaywrightEx.Supervisor.Connection`.

* `:pid` (`t:pid/0`) - The process to send messages to. Defaults to `self()`.

# `unsubscribe`

```elixir
@spec unsubscribe(guid(), [subscribe_opt()]) :: :ok
```

Unsubscribe from playwright responses concerning a resource, identified by its `guid`.

## Options
* `:connection` (`t:term/0`) - The Connection process name. Defaults to `PlaywrightEx.Supervisor.Connection`. The default value is `PlaywrightEx.Supervisor.Connection`.

* `:pid` (`t:pid/0`) - The process to send messages to. Defaults to `self()`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
