# `PhoenixTest.Playwright.Config`
[🔗](https://github.com/ftes/phoenix_test_playwright/blob/v0.15.0/lib/phoenix_test/playwright/config.ex#L202)

Configuration options for the Playwright driver.

Most should be set globally in `config/tests.exs`.
Some can be overridden per test.

All options:
* `:accept_dialogs` (`t:boolean/0`) - Accept browser dialogs (`alert()`, `confirm()`, `prompt()`). The default value is `true`.

* `:assets_dir` (`t:binary/0`) - The directory where the JS assets are located and the Playwright CLI is installed.
  Playwright version `1.61.0` or newer is recommended.
  Alternatively, use `ws_endpoint` to connect to a remote Playwright server instead, in which case no local node and playwright is required and `assets_dir` is ignored. The default value is `"./assets"`.

* `:browser` (`:android | :chromium | :electron | :firefox | :webkit`) - The default value is `:chromium`.

* `:browser_context_opts` - Additional arguments passed to Playwright [Browser.newContext](https://playwright.dev/docs/api/class-browser#browser-new-context).
  E.g. `[http_credentials: %{username: "a", password: "b"}]`. The default value is `[]`.

* `:browser_launch_opts` (`t:keyword/0`) - Additional arguments passed to Playwright [browserType.launch](https://playwright.dev/docs/api/class-browsertype#browser-type-launch).
  E.g. `[args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]]`.
  Can't be used with remote browser (ws_endpoint). The default value is `[]`.

* `:browser_launch_timeout` (`t:non_neg_integer/0`) - The default value is `4000`.

* `:browser_page_opts` - Additional arguments passed to Playwright [Browser.newPage](https://playwright.dev/docs/api/class-browser#browser-new-page).
  (E.g. `[accept_downloads: false]`. The default value is `[]`.

* `:browser_pool` (`atom | false`) - Reuse a browser from this pool instead of launching a new browser per test suite.
  `false` to disable pooling and launch a new browser per test suite. The default value is `:default_pool`.

* `:browser_pool_checkout_timeout` (`t:non_neg_integer/0`) - The default value is `60000`.

* `:browser_pools` (list of non-empty `t:keyword/0`) - Supported keys:
    * `:id` (`t:atom/0`) - Required.

    * `:size` (`t:integer/0`) - The default value is `System.schedulers_online() / 2`.

    * `:browser` (`:android | :chromium | :electron | :firefox | :webkit`) - The default value is `:chromium`.

    * `:browser_launch_opts` (`t:keyword/0`) - Additional arguments passed to Playwright [browserType.launch](https://playwright.dev/docs/api/class-browsertype#browser-type-launch).
      E.g. `[args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream"]]`.
      Can't be used with remote browser (ws_endpoint). The default value is `[]`.

    * `:browser_launch_timeout` (`t:non_neg_integer/0`) - The default value is `4000`.

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

    * `:headless` (`t:boolean/0`) - The default value is `true`.

    * `:slow_mo` (`t:non_neg_integer/0`) - The default value is `0`.

  The default value is `[[id: :default_pool]]`.

* `:ecto_sandbox_stop_owner_delay` (`t:non_neg_integer/0`) - Delay in milliseconds before shutting down the Ecto sandbox owner after a
  test ends. Use this to allow LiveViews and other processes in your app
  time to stop using database connections before the sandbox owner is
  terminated. The default value is `0`.

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

* `:headless` (`t:boolean/0`) - The default value is `true`.

* `:js_logger` (`module | false`) - `false` to disable, or a module that implements the `PlaywrightEx.JsLogger` behaviour. The default value is `PhoenixTest.Playwright.JsLogger`.

* `:screenshot` (`boolean/0 | Keyword.t/0`) - Either a boolean or a keyword list:

    * `:full_page` (`t:boolean/0`) - The default value is `true`.

    * `:omit_background` (`t:boolean/0`) - The default value is `false`.

  The default value is `false`.

* `:screenshot_dir` (`t:String.t/0`) - Directory where `screenshot/3` saves files. See also `:snapshot_dir` for `assert_screenshot/3` reference images. The default value is `"screenshots"`.

* `:selector_engines` - Define custom Playwright [selector engines](https://playwright.dev/docs/extensibility#custom-selector-engines). The default value is `[]`.

* `:slow_mo` (`t:non_neg_integer/0`) - The default value is `0`.

* `:snapshot_dir` (`t:String.t/0`) - Directory where `assert_screenshot/3` reads and writes baseline images.

  Diff images on mismatch are written to `<snapshot_dir>/__diff__/`. Add that subdirectory to `.gitignore`:

  ```
  **/__diff__/
  ```

  The default value is `"test/snapshots"`.

* `:timeout` (`t:non_neg_integer/0`) - The default value is `2000`.

* `:trace` (`boolean/0 | :open`) - The default value is `false`.

* `:trace_dir` (`t:String.t/0`) - The default value is `"traces"`.

* `:ws_endpoint` (`t:String.t/0`) - WebSocket endpoint URL for connecting to a remote Playwright server.
  If provided, uses WebSocket transport instead of spawning a local Node.js process.
  Example: "ws://localhost:3000/ws"

  The remote server provides a single pre-launched browser, so `browser_pool` should
  be set to `false` (pooling has no effect with a remote server).

  This is useful for:
  - Alpine Linux containers (glibc issues with local Playwright driver)
  - Containerized CI environments with a separate Playwright server
  - Connecting to remote/shared Playwright instances

Options that be overridden per test module via the `use PhoenixTest.Playwright.Case` opts:
- `:browser_pool`
- `:browser`
- `:browser_launch_opts`
- `:browser_launch_timeout`
- `:executable_path`
- `:headless`
- `:slow_mo`

Options that be overridden per test via ExUnit `@tag`:
- `:accept_dialogs`
- `:ecto_sandbox_stop_owner_delay`
- `:screenshot`
- `:trace`
- `:browser_context_opts`
- `:browser_page_opts`

---

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