# `Playwright.Page`
[🔗](https://github.com/ftes/playwright_ex/blob/v1.65.0-rc.3/lib/playwright/api/page.ex#L7)

Page provides methods to interact with a single tab in a [`Browser`](`Playwright.Browser`), or an
[extension background page](https://developer.chrome.com/extensions/background_pages) in Chromium. One [`Browser`](`Playwright.Browser`)
instance might have multiple [`Page`](`Playwright.Page`) instances.

This example creates a page, navigates it to a URL, and then saves a screenshot:

```elixir
# Or Playwright.chromium/1 or Playwright.firefox/1.
browser = Playwright.webkit(playwright) |> BrowserType.launch!()
context = Browser.new_context!(browser)
page = BrowserContext.new_page!(context)
Page.goto!(page, "https://example.com")
Page.screenshot!(page, path: "screenshot.png")
Browser.close!(browser)
```

The Page class emits various events (described below) which can be handled with `Playwright.Page.on/3`, `Playwright.Page.once/3` or `Playwright.Page.off/3`.

This example logs a message for a single page `load` event:

```elixir
Page.once(page, :load, fn _page -> IO.puts("Page loaded!") end)
```

To unsubscribe from events use the `remove_listener/3` method:

```elixir
log_request = fn intercepted_request ->
  IO.puts("A request was made: #{Request.url(intercepted_request)}")
end

Page.on(page, :request, log_request)
# Sometime later...
Page.remove_listener(page, :request, log_request)
```

*Since Playwright 1.8.*

The examples alias the modules they use (`alias Playwright.{Locator, Page}`).

## Events

### `:close`

Emitted when the page closes.

### `:console`

Emitted when JavaScript within the page calls one of console API methods, e.g. `console.log` or `console.dir`.

The arguments passed into `console.log` are available on the [`ConsoleMessage`](`Playwright.ConsoleMessage`) event handler argument.

**Usage**

```elixir
Page.on(page, :console, fn msg ->
  values = for arg <- ConsoleMessage.args(msg), do: JSHandle.json_value!(arg)
  IO.puts(inspect(values))
end)

Page.evaluate!(page, "() => console.log('hello', 5, { foo: 'bar' })")
```

### `:crash`

Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes,
ongoing and subsequent operations will fail.

The most common way to deal with crashes is to catch an exception:

```elixir
try do
  # Crash might happen during a click.
  Page.click!(page, "button")
  # Or while waiting for an event.
  Page.wait_for_event!(page, :popup)
rescue
  e ->
    # When the page crashes, exception message contains "crash".
    Exception.message(e)
end
```

### `:dialog`

Emitted when a JavaScript dialog appears, such as `alert`, `prompt`, `confirm` or `beforeunload`. Listener **must** either `Playwright.Dialog.accept/2` or `Playwright.Dialog.dismiss/1` the dialog - otherwise the page will [freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking) waiting for the dialog, and actions like click will never finish.

**Usage**

```elixir
Page.on(page, :dialog, &Dialog.accept!/1)
```

> #### Note {: .info}
>
> When no [`Page.on(:dialog)`](Playwright.Page.html#module-dialog) or [`BrowserContext.on(:dialog)`](Playwright.BrowserContext.html#module-dialog) listeners are present, all dialogs are automatically dismissed.

### `:dialog_closed`

*Since Playwright 1.63.* Emitted when a JavaScript dialog has been closed, either by `Playwright.Dialog.accept/2`, by `Playwright.Dialog.dismiss/1`, or manually by the user in the headed browser.

### `:dom_content_loaded`

*Since Playwright 1.9.* Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded)
event is dispatched.

### `:download`

Emitted when attachment download started. User can access basic file operations on downloaded content via the passed
[`Download`](`Playwright.Download`) instance.

### `:file_chooser`

*Since Playwright 1.9.* Emitted when a file chooser is supposed to appear, such as after clicking the  `<input type=file>`. Playwright can
respond to it via setting the input files using `Playwright.FileChooser.set_files/3` that can be uploaded after that.

```elixir
Page.on(page, :file_chooser, fn file_chooser ->
  FileChooser.set_files!(file_chooser, Path.join(__DIR__, "/tmp/myfile.pdf"))
end)
```

### `:frame_attached`

*Since Playwright 1.9.* Emitted when a frame is attached.

### `:frame_detached`

*Since Playwright 1.9.* Emitted when a frame is detached.

### `:frame_navigated`

*Since Playwright 1.9.* Emitted when a frame is navigated to a new url.

### `:load`

Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.

### `:page_error`

*Since Playwright 1.9.* Emitted when an uncaught exception happens within the page.

```elixir
# Log all uncaught errors to the terminal
Page.on(page, :page_error, fn exception ->
  IO.puts("Uncaught exception: \"#{Exception.message(exception)}\"")
end)

# Navigate to a page with an exception.
Page.goto!(page, ~s{data:text/html,<script>throw new Error("Test")</script>})
```

### `:popup`

Emitted when the page opens a new tab or window. This event is emitted in addition to the
[`BrowserContext.on(:page)`](Playwright.BrowserContext.html#module-page), but only for popups relevant to this page.

The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
popup with `window.open('http://example.com')`, this event will fire when the network request to "http://example.com" is
done and its response has started loading in the popup. If you would like to route/listen to this network request, use `Playwright.BrowserContext.route/4` and [`BrowserContext.on(:request)`](Playwright.BrowserContext.html#module-request) respectively instead of similar methods on the [`Page`](`Playwright.Page`).

```elixir
# Start waiting for popup before clicking: a promise, awaited after.
popup_promise = Page.wait_for_event(page, :popup)
Page.get_by_text(page, "open the popup") |> Locator.click!()
popup = Promise.await!(popup_promise)
IO.puts(Page.evaluate!(popup, "location.href"))
```

> #### Note {: .info}
>
> Use `Playwright.Page.wait_for_load_state/3` to wait until the page gets to a particular state (you should not need it in most
> cases).

### `:request`

Emitted when a page issues a request. The [`Request`](`Playwright.Request`) object is read-only. In order to intercept and mutate requests, see
`Playwright.Page.route/4` or `Playwright.BrowserContext.route/4`.

### `:request_failed`

*Since Playwright 1.9.* Emitted when a request fails, for example by timing out.

```elixir
Page.on(page, :request_failed, fn request ->
  IO.puts(Request.url(request) <> " " <> Request.failure(request).errorText)
end)
```

> #### Note {: .info}
>
> HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
> with [`Page.on(:request_finished)`](Playwright.Page.html#module-request_finished) event and not with [`Page.on(:request_failed)`](Playwright.Page.html#module-request_failed). A request will only be considered
> failed when the client cannot get an HTTP response from the server, e.g. due to network error net::ERR_FAILED.

### `:request_finished`

*Since Playwright 1.9.* Emitted when a request finishes successfully after downloading the response body. For a successful response, the
sequence of events is `request`, `response` and `requestfinished`.

### `:response`

Emitted when [`Response`](`Playwright.Response`) status and headers are received for a request. For a successful response, the sequence of events
is `request`, `response` and `requestfinished`.

### `:web_socket`

*Since Playwright 1.9.* Emitted when [`WebSocket`](`Playwright.WebSocket`) request is sent.

### `:worker`

Emitted when a dedicated [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) is spawned by the
page.

# `add_init_script_options`

```elixir
@type add_init_script_options() ::
  [{:expose_functions, boolean()}] | %{optional(:expose_functions) =&gt; boolean()}
```

Options of `add_init_script/4`, see its docs.

# `add_locator_handler_options`

```elixir
@type add_locator_handler_options() ::
  [no_wait_after: boolean(), times: integer()]
  | %{optional(:no_wait_after) =&gt; boolean(), optional(:times) =&gt; integer()}
```

Options of `add_locator_handler/4`, see its docs.

# `add_script_tag_options`

```elixir
@type add_script_tag_options() ::
  [content: String.t(), path: String.t(), type: String.t(), url: String.t()]
  | %{
      optional(:content) =&gt; String.t(),
      optional(:path) =&gt; String.t(),
      optional(:type) =&gt; String.t(),
      optional(:url) =&gt; String.t()
    }
```

Options of `add_script_tag/2`, see its docs.

# `add_style_tag_options`

```elixir
@type add_style_tag_options() ::
  [content: String.t(), path: String.t(), url: String.t()]
  | %{
      optional(:content) =&gt; String.t(),
      optional(:path) =&gt; String.t(),
      optional(:url) =&gt; String.t()
    }
```

Options of `add_style_tag/2`, see its docs.

# `aria_snapshot_json_options`

```elixir
@type aria_snapshot_json_options() ::
  [
    boxes: boolean(),
    depth: integer(),
    mode: :ai | :default,
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:boxes) =&gt; boolean(),
      optional(:depth) =&gt; integer(),
      optional(:mode) =&gt; :ai | :default,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `aria_snapshot_json/2`, see its docs.

# `aria_snapshot_options`

```elixir
@type aria_snapshot_options() ::
  [
    boxes: boolean(),
    depth: integer(),
    mode: :ai | :default,
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:boxes) =&gt; boolean(),
      optional(:depth) =&gt; integer(),
      optional(:mode) =&gt; :ai | :default,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `aria_snapshot/2`, see its docs.

# `check_options`

```elixir
@type check_options() ::
  [
    force: boolean(),
    no_wait_after: boolean(),
    position: %{x: number(), y: number()},
    scroll: :auto | :none,
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity,
    trial: boolean()
  ]
  | %{
      optional(:force) =&gt; boolean(),
      optional(:no_wait_after) =&gt; boolean(),
      optional(:position) =&gt; %{x: number(), y: number()},
      optional(:scroll) =&gt; :auto | :none,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:trial) =&gt; boolean()
    }
```

Options of `check/3`, see its docs.

# `click_options`

```elixir
@type click_options() ::
  [
    button: :left | :right | :middle,
    click_count: integer(),
    delay: number(),
    force: boolean(),
    modifiers: [:alt | :control | :control_or_meta | :meta | :shift],
    no_wait_after: boolean(),
    position: %{x: number(), y: number()},
    scroll: :auto | :none,
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity,
    trial: boolean()
  ]
  | %{
      optional(:button) =&gt; :left | :right | :middle,
      optional(:click_count) =&gt; integer(),
      optional(:delay) =&gt; number(),
      optional(:force) =&gt; boolean(),
      optional(:modifiers) =&gt; [
        :alt | :control | :control_or_meta | :meta | :shift
      ],
      optional(:no_wait_after) =&gt; boolean(),
      optional(:position) =&gt; %{x: number(), y: number()},
      optional(:scroll) =&gt; :auto | :none,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:trial) =&gt; boolean()
    }
```

Options of `click/3`, see its docs.

# `close_options`

```elixir
@type close_options() ::
  [reason: String.t(), run_before_unload: boolean()]
  | %{
      optional(:reason) =&gt; String.t(),
      optional(:run_before_unload) =&gt; boolean()
    }
```

Options of `close/2`, see its docs.

# `console_messages_options`

```elixir
@type console_messages_options() ::
  [{:filter, :all | :since_navigation}]
  | %{optional(:filter) =&gt; :all | :since_navigation}
```

Options of `console_messages/2`, see its docs.

# `content_options`

```elixir
@type content_options() ::
  [{:include_shadow, boolean()}] | %{optional(:include_shadow) =&gt; boolean()}
```

Options of `content/2`, see its docs.

# `dblclick_options`

```elixir
@type dblclick_options() ::
  [
    button: :left | :right | :middle,
    delay: number(),
    force: boolean(),
    modifiers: [:alt | :control | :control_or_meta | :meta | :shift],
    no_wait_after: boolean(),
    position: %{x: number(), y: number()},
    scroll: :auto | :none,
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity,
    trial: boolean()
  ]
  | %{
      optional(:button) =&gt; :left | :right | :middle,
      optional(:delay) =&gt; number(),
      optional(:force) =&gt; boolean(),
      optional(:modifiers) =&gt; [
        :alt | :control | :control_or_meta | :meta | :shift
      ],
      optional(:no_wait_after) =&gt; boolean(),
      optional(:position) =&gt; %{x: number(), y: number()},
      optional(:scroll) =&gt; :auto | :none,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:trial) =&gt; boolean()
    }
```

Options of `dblclick/3`, see its docs.

# `dispatch_event_options`

```elixir
@type dispatch_event_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `dispatch_event/5`, see its docs.

# `drag_and_drop_options`

```elixir
@type drag_and_drop_options() ::
  [
    force: boolean(),
    no_wait_after: boolean(),
    scroll: :auto | :none,
    signal: Playwright.AbortSignal.t(),
    source_position: %{x: number(), y: number()},
    steps: integer(),
    strict: boolean(),
    target_position: %{x: number(), y: number()},
    timeout: number() | :infinity,
    trial: boolean()
  ]
  | %{
      optional(:force) =&gt; boolean(),
      optional(:no_wait_after) =&gt; boolean(),
      optional(:scroll) =&gt; :auto | :none,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:source_position) =&gt; %{x: number(), y: number()},
      optional(:steps) =&gt; integer(),
      optional(:strict) =&gt; boolean(),
      optional(:target_position) =&gt; %{x: number(), y: number()},
      optional(:timeout) =&gt; number() | :infinity,
      optional(:trial) =&gt; boolean()
    }
```

Options of `drag_and_drop/4`, see its docs.

# `emulate_media_options`

```elixir
@type emulate_media_options() ::
  [
    color_scheme: :null | :light | :dark | :no_preference,
    contrast: :null | :no_preference | :more,
    forced_colors: :null | :active | :none,
    media: :null | :screen | :print,
    reduced_motion: :null | :reduce | :no_preference
  ]
  | %{
      optional(:color_scheme) =&gt; :null | :light | :dark | :no_preference,
      optional(:contrast) =&gt; :null | :no_preference | :more,
      optional(:forced_colors) =&gt; :null | :active | :none,
      optional(:media) =&gt; :null | :screen | :print,
      optional(:reduced_motion) =&gt; :null | :reduce | :no_preference
    }
```

Options of `emulate_media/2`, see its docs.

# `evaluate_handle_options`

```elixir
@type evaluate_handle_options() ::
  [{:expose_functions, boolean()}] | %{optional(:expose_functions) =&gt; boolean()}
```

Options of `evaluate_handle/4`, see its docs.

# `evaluate_options`

```elixir
@type evaluate_options() ::
  [{:expose_functions, boolean()}] | %{optional(:expose_functions) =&gt; boolean()}
```

Options of `evaluate/4`, see its docs.

# `event`

```elixir
@type event() ::
  :close
  | :console
  | :crash
  | :dialog
  | :dialog_closed
  | :dom_content_loaded
  | :download
  | :file_chooser
  | :frame_attached
  | :frame_detached
  | :frame_navigated
  | :load
  | :page_error
  | :popup
  | :request
  | :request_failed
  | :request_finished
  | :response
  | :web_socket
  | :worker
```

An event name, see the module docs.

# `expect_console_message_options`

```elixir
@type expect_console_message_options() ::
  [
    predicate: (Playwright.ConsoleMessage.t() -&gt; boolean()),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; (Playwright.ConsoleMessage.t() -&gt; boolean()),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_console_message/3`, see its docs.

# `expect_download_options`

```elixir
@type expect_download_options() ::
  [
    predicate: (Playwright.Download.t() -&gt; boolean()),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; (Playwright.Download.t() -&gt; boolean()),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_download/3`, see its docs.

# `expect_event_options`

```elixir
@type expect_event_options() ::
  [
    predicate: fun(),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; fun(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_event/4`, see its docs.

# `expect_file_chooser_options`

```elixir
@type expect_file_chooser_options() ::
  [
    predicate: (Playwright.FileChooser.t() -&gt; boolean()),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; (Playwright.FileChooser.t() -&gt; boolean()),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_file_chooser/3`, see its docs.

# `expect_navigation_options`

```elixir
@type expect_navigation_options() ::
  [
    timeout: number() | :infinity,
    url:
      String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
    wait_until: :load | :domcontentloaded | :networkidle | :commit,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:timeout) =&gt; number() | :infinity,
      optional(:url) =&gt;
        String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
      optional(:wait_until) =&gt;
        :load | :domcontentloaded | :networkidle | :commit,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_navigation/3`, see its docs.

# `expect_popup_options`

```elixir
@type expect_popup_options() ::
  [
    predicate: (t() -&gt; boolean()),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; (t() -&gt; boolean()),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_popup/3`, see its docs.

# `expect_request_finished_options`

```elixir
@type expect_request_finished_options() ::
  [
    predicate: (Playwright.Request.t() -&gt; boolean()),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; (Playwright.Request.t() -&gt; boolean()),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_request_finished/3`, see its docs.

# `expect_request_options`

```elixir
@type expect_request_options() ::
  [timeout: number() | :infinity, signal: Playwright.AbortSignal.t()]
  | %{
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_request/4`, see its docs.

# `expect_response_options`

```elixir
@type expect_response_options() ::
  [timeout: number() | :infinity, signal: Playwright.AbortSignal.t()]
  | %{
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_response/4`, see its docs.

# `expect_websocket_options`

```elixir
@type expect_websocket_options() ::
  [
    predicate: (Playwright.WebSocket.t() -&gt; boolean()),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; (Playwright.WebSocket.t() -&gt; boolean()),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_websocket/3`, see its docs.

# `expect_worker_options`

```elixir
@type expect_worker_options() ::
  [
    predicate: (Playwright.Worker.t() -&gt; boolean()),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; (Playwright.Worker.t() -&gt; boolean()),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `expect_worker/3`, see its docs.

# `fill_options`

```elixir
@type fill_options() ::
  [
    force: boolean(),
    no_wait_after: boolean(),
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:force) =&gt; boolean(),
      optional(:no_wait_after) =&gt; boolean(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `fill/4`, see its docs.

# `focus_options`

```elixir
@type focus_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `focus/3`, see its docs.

# `get_attribute_options`

```elixir
@type get_attribute_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `get_attribute/4`, see its docs.

# `get_by_alt_text_options`

```elixir
@type get_by_alt_text_options() ::
  [{:exact, boolean()}] | %{optional(:exact) =&gt; boolean()}
```

Options of `get_by_alt_text/3`, see its docs.

# `get_by_label_options`

```elixir
@type get_by_label_options() ::
  [{:exact, boolean()}] | %{optional(:exact) =&gt; boolean()}
```

Options of `get_by_label/3`, see its docs.

# `get_by_placeholder_options`

```elixir
@type get_by_placeholder_options() ::
  [{:exact, boolean()}] | %{optional(:exact) =&gt; boolean()}
```

Options of `get_by_placeholder/3`, see its docs.

# `get_by_role_options`

```elixir
@type get_by_role_options() ::
  [
    checked: boolean(),
    description: String.t() | Regex.t() | Playwright.RegExp.t(),
    disabled: boolean(),
    exact: boolean(),
    expanded: boolean(),
    include_hidden: boolean(),
    level: integer(),
    name: String.t() | Regex.t() | Playwright.RegExp.t(),
    pressed: boolean(),
    selected: boolean()
  ]
  | %{
      optional(:checked) =&gt; boolean(),
      optional(:description) =&gt; String.t() | Regex.t() | Playwright.RegExp.t(),
      optional(:disabled) =&gt; boolean(),
      optional(:exact) =&gt; boolean(),
      optional(:expanded) =&gt; boolean(),
      optional(:include_hidden) =&gt; boolean(),
      optional(:level) =&gt; integer(),
      optional(:name) =&gt; String.t() | Regex.t() | Playwright.RegExp.t(),
      optional(:pressed) =&gt; boolean(),
      optional(:selected) =&gt; boolean()
    }
```

Options of `get_by_role/3`, see its docs.

# `get_by_text_options`

```elixir
@type get_by_text_options() ::
  [{:exact, boolean()}] | %{optional(:exact) =&gt; boolean()}
```

Options of `get_by_text/3`, see its docs.

# `get_by_title_options`

```elixir
@type get_by_title_options() ::
  [{:exact, boolean()}] | %{optional(:exact) =&gt; boolean()}
```

Options of `get_by_title/3`, see its docs.

# `go_back_options`

```elixir
@type go_back_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity,
    wait_until: :load | :domcontentloaded | :networkidle | :commit
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:wait_until) =&gt;
        :load | :domcontentloaded | :networkidle | :commit
    }
```

Options of `go_back/2`, see its docs.

# `go_forward_options`

```elixir
@type go_forward_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity,
    wait_until: :load | :domcontentloaded | :networkidle | :commit
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:wait_until) =&gt;
        :load | :domcontentloaded | :networkidle | :commit
    }
```

Options of `go_forward/2`, see its docs.

# `goto_options`

```elixir
@type goto_options() ::
  [
    referer: String.t(),
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity,
    wait_until: :load | :domcontentloaded | :networkidle | :commit
  ]
  | %{
      optional(:referer) =&gt; String.t(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:wait_until) =&gt;
        :load | :domcontentloaded | :networkidle | :commit
    }
```

Options of `goto/3`, see its docs.

# `hover_options`

```elixir
@type hover_options() ::
  [
    force: boolean(),
    modifiers: [:alt | :control | :control_or_meta | :meta | :shift],
    no_wait_after: boolean(),
    position: %{x: number(), y: number()},
    scroll: :auto | :none,
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity,
    trial: boolean()
  ]
  | %{
      optional(:force) =&gt; boolean(),
      optional(:modifiers) =&gt; [
        :alt | :control | :control_or_meta | :meta | :shift
      ],
      optional(:no_wait_after) =&gt; boolean(),
      optional(:position) =&gt; %{x: number(), y: number()},
      optional(:scroll) =&gt; :auto | :none,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:trial) =&gt; boolean()
    }
```

Options of `hover/3`, see its docs.

# `inner_html_options`

```elixir
@type inner_html_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `inner_html/3`, see its docs.

# `inner_text_options`

```elixir
@type inner_text_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `inner_text/3`, see its docs.

# `input_value_options`

```elixir
@type input_value_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `input_value/3`, see its docs.

# `is_checked_options`

```elixir
@type is_checked_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `is_checked/3`, see its docs.

# `is_disabled_options`

```elixir
@type is_disabled_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `is_disabled/3`, see its docs.

# `is_editable_options`

```elixir
@type is_editable_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `is_editable/3`, see its docs.

# `is_enabled_options`

```elixir
@type is_enabled_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `is_enabled/3`, see its docs.

# `is_hidden_options`

```elixir
@type is_hidden_options() ::
  [strict: boolean(), timeout: number() | :infinity]
  | %{
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `is_hidden/3`, see its docs.

# `is_visible_options`

```elixir
@type is_visible_options() ::
  [strict: boolean(), timeout: number() | :infinity]
  | %{
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `is_visible/3`, see its docs.

# `locator_options`

```elixir
@type locator_options() ::
  [
    has: Playwright.Locator.t(),
    has_not: Playwright.Locator.t(),
    has_not_text: String.t() | Regex.t() | Playwright.RegExp.t(),
    has_text: String.t() | Regex.t() | Playwright.RegExp.t()
  ]
  | %{
      optional(:has) =&gt; Playwright.Locator.t(),
      optional(:has_not) =&gt; Playwright.Locator.t(),
      optional(:has_not_text) =&gt; String.t() | Regex.t() | Playwright.RegExp.t(),
      optional(:has_text) =&gt; String.t() | Regex.t() | Playwright.RegExp.t()
    }
```

Options of `locator/3`, see its docs.

# `page_errors_options`

```elixir
@type page_errors_options() ::
  [{:filter, :all | :since_navigation}]
  | %{optional(:filter) =&gt; :all | :since_navigation}
```

Options of `page_errors/2`, see its docs.

# `pdf_options`

```elixir
@type pdf_options() ::
  [
    display_header_footer: boolean(),
    footer_template: String.t(),
    format: String.t(),
    header_template: String.t(),
    height: String.t() | number(),
    landscape: boolean(),
    margin: %{
      optional(:top) =&gt; String.t() | number(),
      optional(:right) =&gt; String.t() | number(),
      optional(:bottom) =&gt; String.t() | number(),
      optional(:left) =&gt; String.t() | number()
    },
    outline: boolean(),
    page_ranges: String.t(),
    path: String.t(),
    prefer_css_page_size: boolean(),
    print_background: boolean(),
    scale: number(),
    tagged: boolean(),
    width: String.t() | number()
  ]
  | %{
      optional(:display_header_footer) =&gt; boolean(),
      optional(:footer_template) =&gt; String.t(),
      optional(:format) =&gt; String.t(),
      optional(:header_template) =&gt; String.t(),
      optional(:height) =&gt; String.t() | number(),
      optional(:landscape) =&gt; boolean(),
      optional(:margin) =&gt; %{
        optional(:top) =&gt; String.t() | number(),
        optional(:right) =&gt; String.t() | number(),
        optional(:bottom) =&gt; String.t() | number(),
        optional(:left) =&gt; String.t() | number()
      },
      optional(:outline) =&gt; boolean(),
      optional(:page_ranges) =&gt; String.t(),
      optional(:path) =&gt; String.t(),
      optional(:prefer_css_page_size) =&gt; boolean(),
      optional(:print_background) =&gt; boolean(),
      optional(:scale) =&gt; number(),
      optional(:tagged) =&gt; boolean(),
      optional(:width) =&gt; String.t() | number()
    }
```

Options of `pdf/2`, see its docs.

# `press_options`

```elixir
@type press_options() ::
  [
    delay: number(),
    no_wait_after: boolean(),
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:delay) =&gt; number(),
      optional(:no_wait_after) =&gt; boolean(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `press/4`, see its docs.

# `query_selector_options`

```elixir
@type query_selector_options() ::
  [{:strict, boolean()}] | %{optional(:strict) =&gt; boolean()}
```

Options of `query_selector/3`, see its docs.

# `reload_options`

```elixir
@type reload_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity,
    wait_until: :load | :domcontentloaded | :networkidle | :commit
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:wait_until) =&gt;
        :load | :domcontentloaded | :networkidle | :commit
    }
```

Options of `reload/2`, see its docs.

# `remove_all_listeners_options`

```elixir
@type remove_all_listeners_options() ::
  [{:behavior, :wait | :ignore_errors | :default}]
  | %{optional(:behavior) =&gt; :wait | :ignore_errors | :default}
```

Options of `remove_all_listeners/3`, see its docs.

# `route_from_har_options`

```elixir
@type route_from_har_options() ::
  [
    not_found: :abort | :fallback,
    update: boolean(),
    update_content: :embed | :attach,
    update_mode: :full | :minimal,
    url: String.t() | Regex.t() | Playwright.RegExp.t()
  ]
  | %{
      optional(:not_found) =&gt; :abort | :fallback,
      optional(:update) =&gt; boolean(),
      optional(:update_content) =&gt; :embed | :attach,
      optional(:update_mode) =&gt; :full | :minimal,
      optional(:url) =&gt; String.t() | Regex.t() | Playwright.RegExp.t()
    }
```

Options of `route_from_har/3`, see its docs.

# `route_options`

```elixir
@type route_options() :: [{:times, integer()}] | %{optional(:times) =&gt; integer()}
```

Options of `route/4`, see its docs.

# `screenshot_options`

```elixir
@type screenshot_options() ::
  [
    animations: :disabled | :allow,
    caret: :hide | :initial,
    clip: %{x: number(), y: number(), width: number(), height: number()},
    full_page: boolean(),
    mask: [Playwright.Locator.t()],
    mask_color: String.t(),
    omit_background: boolean(),
    path: String.t(),
    quality: integer(),
    scale: :css | :device,
    signal: Playwright.AbortSignal.t(),
    style: String.t(),
    timeout: number() | :infinity,
    type: :png | :jpeg | :webp
  ]
  | %{
      optional(:animations) =&gt; :disabled | :allow,
      optional(:caret) =&gt; :hide | :initial,
      optional(:clip) =&gt; %{
        x: number(),
        y: number(),
        width: number(),
        height: number()
      },
      optional(:full_page) =&gt; boolean(),
      optional(:mask) =&gt; [Playwright.Locator.t()],
      optional(:mask_color) =&gt; String.t(),
      optional(:omit_background) =&gt; boolean(),
      optional(:path) =&gt; String.t(),
      optional(:quality) =&gt; integer(),
      optional(:scale) =&gt; :css | :device,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:style) =&gt; String.t(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:type) =&gt; :png | :jpeg | :webp
    }
```

Options of `screenshot/2`, see its docs.

# `select_option_options`

```elixir
@type select_option_options() ::
  [
    force: boolean(),
    no_wait_after: boolean(),
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:force) =&gt; boolean(),
      optional(:no_wait_after) =&gt; boolean(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `select_option/4`, see its docs.

# `set_checked_options`

```elixir
@type set_checked_options() ::
  [
    force: boolean(),
    no_wait_after: boolean(),
    position: %{x: number(), y: number()},
    scroll: :auto | :none,
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity,
    trial: boolean()
  ]
  | %{
      optional(:force) =&gt; boolean(),
      optional(:no_wait_after) =&gt; boolean(),
      optional(:position) =&gt; %{x: number(), y: number()},
      optional(:scroll) =&gt; :auto | :none,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:trial) =&gt; boolean()
    }
```

Options of `set_checked/4`, see its docs.

# `set_content_options`

```elixir
@type set_content_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity,
    wait_until: :load | :domcontentloaded | :networkidle | :commit
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:wait_until) =&gt;
        :load | :domcontentloaded | :networkidle | :commit
    }
```

Options of `set_content/3`, see its docs.

# `set_input_files_options`

```elixir
@type set_input_files_options() ::
  [
    no_wait_after: boolean(),
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:no_wait_after) =&gt; boolean(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `set_input_files/4`, see its docs.

# `t`

```elixir
@type t() :: %Playwright.Page{
  conn: term(),
  guid: term(),
  initializer: term(),
  table: term(),
  type: term()
}
```

A `Page` handle. Compare handles with `==`, their fields are internal.

# `tap_options`

```elixir
@type tap_options() ::
  [
    force: boolean(),
    modifiers: [:alt | :control | :control_or_meta | :meta | :shift],
    no_wait_after: boolean(),
    position: %{x: number(), y: number()},
    scroll: :auto | :none,
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity,
    trial: boolean()
  ]
  | %{
      optional(:force) =&gt; boolean(),
      optional(:modifiers) =&gt; [
        :alt | :control | :control_or_meta | :meta | :shift
      ],
      optional(:no_wait_after) =&gt; boolean(),
      optional(:position) =&gt; %{x: number(), y: number()},
      optional(:scroll) =&gt; :auto | :none,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:trial) =&gt; boolean()
    }
```

Options of `tap/3`, see its docs.

# `text_content_options`

```elixir
@type text_content_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `text_content/3`, see its docs.

# `type_options`

```elixir
@type type_options() ::
  [
    delay: number(),
    no_wait_after: boolean(),
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:delay) =&gt; number(),
      optional(:no_wait_after) =&gt; boolean(),
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `type/4`, see its docs.

# `uncheck_options`

```elixir
@type uncheck_options() ::
  [
    force: boolean(),
    no_wait_after: boolean(),
    position: %{x: number(), y: number()},
    scroll: :auto | :none,
    signal: Playwright.AbortSignal.t(),
    strict: boolean(),
    timeout: number() | :infinity,
    trial: boolean()
  ]
  | %{
      optional(:force) =&gt; boolean(),
      optional(:no_wait_after) =&gt; boolean(),
      optional(:position) =&gt; %{x: number(), y: number()},
      optional(:scroll) =&gt; :auto | :none,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:trial) =&gt; boolean()
    }
```

Options of `uncheck/3`, see its docs.

# `unroute_all_options`

```elixir
@type unroute_all_options() ::
  [{:behavior, :wait | :ignore_errors | :default}]
  | %{optional(:behavior) =&gt; :wait | :ignore_errors | :default}
```

Options of `unroute_all/2`, see its docs.

# `wait_for_event_options`

```elixir
@type wait_for_event_options() ::
  [
    predicate: fun(),
    timeout: number() | :infinity,
    signal: Playwright.AbortSignal.t()
  ]
  | %{
      optional(:predicate) =&gt; fun(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:signal) =&gt; Playwright.AbortSignal.t()
    }
```

Options of `wait_for_event/3`, see its docs.

# `wait_for_function_options`

```elixir
@type wait_for_function_options() ::
  [
    polling: number() | :raf,
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:polling) =&gt; number() | :raf,
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `wait_for_function/4`, see its docs.

# `wait_for_load_state_options`

```elixir
@type wait_for_load_state_options() ::
  [signal: Playwright.AbortSignal.t(), timeout: number() | :infinity]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `wait_for_load_state/3`, see its docs.

# `wait_for_navigation_options`

```elixir
@type wait_for_navigation_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity,
    url:
      String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
    wait_until: :load | :domcontentloaded | :networkidle | :commit
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:url) =&gt;
        String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
      optional(:wait_until) =&gt;
        :load | :domcontentloaded | :networkidle | :commit
    }
```

Options of `wait_for_navigation/2`, see its docs.

# `wait_for_request_options`

```elixir
@type wait_for_request_options() ::
  [signal: Playwright.AbortSignal.t(), timeout: number() | :infinity]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `wait_for_request/3`, see its docs.

# `wait_for_response_options`

```elixir
@type wait_for_response_options() ::
  [signal: Playwright.AbortSignal.t(), timeout: number() | :infinity]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `wait_for_response/3`, see its docs.

# `wait_for_selector_options`

```elixir
@type wait_for_selector_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    state: :attached | :detached | :visible | :hidden,
    strict: boolean(),
    timeout: number() | :infinity
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:state) =&gt; :attached | :detached | :visible | :hidden,
      optional(:strict) =&gt; boolean(),
      optional(:timeout) =&gt; number() | :infinity
    }
```

Options of `wait_for_selector/3`, see its docs.

# `wait_for_url_options`

```elixir
@type wait_for_url_options() ::
  [
    signal: Playwright.AbortSignal.t(),
    timeout: number() | :infinity,
    wait_until: :load | :domcontentloaded | :networkidle | :commit
  ]
  | %{
      optional(:signal) =&gt; Playwright.AbortSignal.t(),
      optional(:timeout) =&gt; number() | :infinity,
      optional(:wait_until) =&gt;
        :load | :domcontentloaded | :networkidle | :commit
    }
```

Options of `wait_for_url/3`, see its docs.

# `add_init_script`

```elixir
@spec add_init_script(
  t(),
  String.t()
  | %{optional(:path) =&gt; String.t(), optional(:content) =&gt; String.t()},
  term() | nil,
  add_init_script_options()
) :: {:ok, Playwright.Disposable.t()} | {:error, Playwright.error()}
```

Adds a script which would be evaluated in one of the following scenarios:

* Whenever the page is navigated.
* Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly
  attached frame.

The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
the JavaScript environment, e.g. to seed `Math.random`.

**Usage**

An example of overriding `Math.random` before the page loads:

```js
// preload.js
Math.random = () => 42;
```

```elixir
# In your playwright script, assuming the preload.js file is in same directory
Page.add_init_script!(page, %{path: "./preload.js"})
```

```elixir
Page.add_init_script!(page, "mock => { window.mock = mock; }", mock)
```

> #### Note {: .info}
>
> The order of evaluation of multiple scripts installed via `Playwright.BrowserContext.add_init_script/4` and
> `Playwright.Page.add_init_script/4` is not defined.

*Since Playwright 1.8.*

## Arguments

* `script` - Script to be evaluated in the page.
  * `:path` - Path to the JavaScript file. If `path` is a relative path, then it is resolved relative to the
    current working directory. Optional.
  * `:content` - Raw script content. Optional.
* `arg` - Optional argument to pass to `script` (only supported when passing a function).

## Options

* `:expose_functions` (`t:boolean/0`) - *Since Playwright 1.62.* When set to `true`, functions passed inside `arg` are exposed in the page and can be called from the init script. Calling one returns a `Promise` of its result. Under the hood, each function is exposed via `Playwright.Page.expose_function/3`, so it is technically accessible from all frames of the page. Unlike functions passed to `Playwright.Page.evaluate/4`, functions passed to an init script are exposed in every new document, so they survive navigations. Defaults to `false`, in which case functions are not serializable and are silently dropped.

# `add_init_script!`

```elixir
@spec add_init_script!(
  t(),
  String.t()
  | %{optional(:path) =&gt; String.t(), optional(:content) =&gt; String.t()},
  term() | nil,
  add_init_script_options()
) :: Playwright.Disposable.t()
```

Like `add_init_script/4`, but returns the value and raises on error.

# `add_locator_handler`

```elixir
@spec add_locator_handler(
  t(),
  Playwright.Locator.t(),
  (Playwright.Locator.t() -&gt; term()),
  add_locator_handler_options()
) :: :ok | {:error, Playwright.error()}
```

When testing a web page, sometimes unexpected overlays like a "Sign up" dialog appear and block actions you want to automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, making them tricky to handle in automated tests.

This method lets you set up a special function, called a handler, that activates when it detects that overlay is visible. The handler's job is to remove the overlay, allowing your test to continue as if the overlay wasn't there.

Things to keep in mind:

* When an overlay is shown predictably, we recommend explicitly waiting for it in your test and dismissing it as a part of your normal test flow, instead of using `Playwright.Page.add_locator_handler/4`.
* Playwright checks for the overlay every time before executing or retrying an action that requires an [actionability check](https://playwright.dev/docs/actionability), or before performing an auto-waiting assertion check. When overlay is visible, Playwright calls the handler first, and then proceeds with the action/assertion. Note that the handler is only called when you perform an action/assertion - if the overlay becomes visible but you don't perform any actions, the handler will not be triggered.
* After executing the handler, Playwright will ensure that overlay that triggered the handler is not visible anymore. You can opt-out of this behavior with `:no_wait_after`.
* The execution time of the handler counts towards the timeout of the action/assertion that executed the handler. If your handler takes too long, it might cause timeouts.
* You can register multiple handlers. However, only a single handler will be running at a time. Make sure the actions within a handler don't depend on another handler.

> #### Warning {: .warning}
>
> Running the handler will alter your page state mid-test. For example it will change the currently focused element and move the mouse. Make sure that actions that run after the handler are self-contained and do not rely on the focus and mouse state being unchanged.
>
> For example, consider a test that calls `Playwright.Locator.focus/2` followed by `Playwright.Keyboard.press/3`. If your handler clicks a button between these two actions, the focused element most likely will be wrong, and key press will happen on the unexpected element. Use `Playwright.Locator.press/3` instead to avoid this problem.
>
> Another example is a series of mouse actions, where `Playwright.Mouse.move/4` is followed by `Playwright.Mouse.down/2`. Again, when the handler runs between these two actions, the mouse position will be wrong during the mouse down. Prefer self-contained actions like `Playwright.Locator.click/2` that do not rely on the state being unchanged by a handler.

**Usage**

An example that closes a "Sign up to the newsletter" dialog when it appears:

```elixir
# Setup the handler.
Page.add_locator_handler!(page, Page.get_by_text(page, "Sign up to the newsletter"), fn ->
  Page.get_by_role(page, :button, name: "No thanks") |> Locator.click!()
end)

# Write the test as usual.
Page.goto!(page, "https://example.com")
Page.get_by_role(page, :button, name: "Start here") |> Locator.click!()
```

An example that skips the "Confirm your security details" page when it is shown:

```elixir
# Setup the handler.
Page.add_locator_handler!(page, Page.get_by_text(page, "Confirm your security details"), fn ->
  Page.get_by_role(page, :button, name: "Remind me later") |> Locator.click!()
end)

# Write the test as usual.
Page.goto!(page, "https://example.com")
Page.get_by_role(page, :button, name: "Start here") |> Locator.click!()
```

An example with a custom callback on every actionability check. It uses a `<body>` locator that is always visible, so the handler is called before every actionability check. It is important to specify `:no_wait_after`, because the handler does not hide the `<body>` element.

```elixir
# Setup the handler.
Page.add_locator_handler!(
  page,
  Page.locator(page, "body"),
  fn -> Page.evaluate!(page, "() => window.removeObstructionsForTestIfNeeded()") end,
  no_wait_after: true
)

# Write the test as usual.
Page.goto!(page, "https://example.com")
Page.get_by_role(page, :button, name: "Start here") |> Locator.click!()
```

Handler takes the original locator as an argument. You can also automatically remove the handler after a number of invocations by setting `:times`:

```elixir
Page.add_locator_handler!(page, Page.get_by_label(page, "Close"), &Locator.click!/1, times: 1)
```

*Since Playwright 1.42.*

## Arguments

* `locator` - Locator that triggers the handler.
* `handler` - Function that should be run once `locator` appears. This function should get rid of the element that blocks actions like click.

## Options

* `:no_wait_after` (`t:boolean/0`) - *Since Playwright 1.44.* By default, after calling the handler Playwright will wait until the overlay becomes hidden, and only then Playwright will continue with the action/assertion that triggered the handler. This option allows to opt-out of this behavior, so that overlay can stay visible after the handler has run.
* `:times` (`t:integer/0`) - *Since Playwright 1.44.* Specifies the maximum number of times this handler should be called. Unlimited by default.

# `add_locator_handler!`

```elixir
@spec add_locator_handler!(
  t(),
  Playwright.Locator.t(),
  (Playwright.Locator.t() -&gt; term()),
  add_locator_handler_options()
) :: :ok
```

Like `add_locator_handler/4`, but returns the value and raises on error.

# `add_script_tag`

```elixir
@spec add_script_tag(t(), add_script_tag_options()) ::
  {:ok, Playwright.ElementHandle.t()} | {:error, Playwright.error()}
```

Adds a `<script>` tag into the page with the desired url or content. Returns the added tag when the script's onload
fires or when the script content was injected into frame.

*Since Playwright 1.8.*

## Options

* `:content` (`t:String.t/0`) - Raw JavaScript content to be injected into frame.
* `:path` (`t:String.t/0`) - Path to the JavaScript file to be injected into frame. If `:path` is a relative path, then it is resolved relative to the
  current working directory.
* `:type` (`t:String.t/0`) - Script type. Use 'module' in order to load a JavaScript ES6 module. See
  [script](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) for more details.
* `:url` (`t:String.t/0`) - URL of a script to be added.

# `add_script_tag!`

```elixir
@spec add_script_tag!(t(), add_script_tag_options()) :: Playwright.ElementHandle.t()
```

Like `add_script_tag/2`, but returns the value and raises on error.

# `add_style_tag`

```elixir
@spec add_style_tag(t(), add_style_tag_options()) ::
  {:ok, Playwright.ElementHandle.t()} | {:error, Playwright.error()}
```

Adds a `<link rel="stylesheet">` tag into the page with the desired url or a `<style type="text/css">` tag with the
content. Returns the added tag when the stylesheet's onload fires or when the CSS content was injected into frame.

*Since Playwright 1.8.*

## Options

* `:content` (`t:String.t/0`) - Raw CSS content to be injected into frame.
* `:path` (`t:String.t/0`) - Path to the CSS file to be injected into frame. If `:path` is a relative path, then it is resolved relative to the
  current working directory.
* `:url` (`t:String.t/0`) - URL of the `<link>` tag.

# `add_style_tag!`

```elixir
@spec add_style_tag!(t(), add_style_tag_options()) :: Playwright.ElementHandle.t()
```

Like `add_style_tag/2`, but returns the value and raises on error.

# `aria_snapshot`

```elixir
@spec aria_snapshot(t(), aria_snapshot_options()) ::
  {:ok, String.t()} | {:error, Playwright.error()}
```

Captures the aria snapshot of the page. Read more about [aria snapshots](https://playwright.dev/docs/aria-snapshots).

*Since Playwright 1.59.*

## Options

* `:boxes` (`t:boolean/0`) - *Since Playwright 1.60.* When `true`, appends each element's bounding box as `[box=x,y,width,height]` to the snapshot. Coordinates are
  relative to the viewport, in CSS pixels, as returned by [`Element.getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
  Defaults to `false`.
* `:depth` (`t:integer/0`) - When specified, limits the depth of the snapshot.
* `:mode` (`:ai` | `:default`) - When set to `:ai`, returns a snapshot optimized for AI consumption: including element references like `[ref=e2]` and snapshots of `<iframe>`s. Defaults to `:default`.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `aria_snapshot!`

```elixir
@spec aria_snapshot!(t(), aria_snapshot_options()) :: String.t()
```

Like `aria_snapshot/2`, but returns the value and raises on error.

# `aria_snapshot_json`

```elixir
@spec aria_snapshot_json(t(), aria_snapshot_json_options()) ::
  {:ok, term()} | {:error, Playwright.error()}
```

Captures the aria snapshot of the page as a free form JSON object.
Returns the same tree as `Playwright.Page.aria_snapshot/2`, serialized as a JSON value instead of YAML markup.
See `Playwright.Locator.aria_snapshot_json/2` for the details of the format.

*Since Playwright 1.63.*

## Options

* `:boxes` (`t:boolean/0`) - When `true`, includes each element's bounding box as a `box` property with `x`, `y`, `width` and `height`. Coordinates are
  relative to the viewport, in CSS pixels, as returned by [`Element.getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).
  Defaults to `false`.
* `:depth` (`t:integer/0`) - When specified, limits the depth of the snapshot.
* `:mode` (`:ai` | `:default`) - When set to `:ai`, returns a snapshot optimized for AI consumption: including element references like `[ref=e2]` and snapshots of `<iframe>`s. Defaults to `:default`.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `aria_snapshot_json!`

```elixir
@spec aria_snapshot_json!(t(), aria_snapshot_json_options()) :: term()
```

Like `aria_snapshot_json/2`, but returns the value and raises on error.

# `bring_to_front`

```elixir
@spec bring_to_front(t()) :: :ok | {:error, Playwright.error()}
```

Brings page to front (activates tab).

*Since Playwright 1.8.*

# `bring_to_front!`

```elixir
@spec bring_to_front!(t()) :: :ok
```

Like `bring_to_front/1`, but returns the value and raises on error.

# `cancel_pick_locator`

```elixir
@spec cancel_pick_locator(t()) :: :ok | {:error, Playwright.error()}
```

Cancels an ongoing `Playwright.Page.pick_locator/1` call by deactivating pick locator mode.
If no pick locator mode is active, this method is a no-op.

*Since Playwright 1.59.*

# `cancel_pick_locator!`

```elixir
@spec cancel_pick_locator!(t()) :: :ok
```

Like `cancel_pick_locator/1`, but returns the value and raises on error.

# `check`

```elixir
@spec check(t(), String.t(), check_options()) :: :ok | {:error, Playwright.error()}
```

This method checks an element matching `selector` by performing the following steps:

1. Find an element matching `selector`. If there is none, wait until a matching element is attached to
   the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method fails. If the element is already
   checked, this method returns immediately.
1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless `:force` option is
   set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `Playwright.Page.mouse/1` to click in the center of the element.
1. Ensure that the element is now checked. If not, this method fails.

When all steps combined have not finished during the specified `:timeout`, this method fails with a
[`TimeoutError`](`Playwright.TimeoutError`). Passing zero timeout disables this.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.check/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:force` (`t:boolean/0`) - Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:position` (`t:map/0`) - *Since Playwright 1.11.* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
  element.
  * `:x`
  * `:y`
* `:scroll` (`:auto` | `:none`) - *Since Playwright 1.62.* Controls whether Playwright scrolls the element into view before performing the action. Defaults to `:auto`,
  which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to
  `:none`, Playwright does not scroll the element and the action fails if the element is not already in the viewport.
  This is useful to assert that an element is reachable by the user without additional scrolling.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:trial` (`t:boolean/0`) - *Since Playwright 1.11.* When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it.

# `check!`

```elixir
@spec check!(t(), String.t(), check_options()) :: :ok
```

Like `check/3`, but returns the value and raises on error.

# `clear_console_messages`

```elixir
@spec clear_console_messages(t()) :: :ok | {:error, Playwright.error()}
```

Clears all stored console messages from this page. Subsequent calls to `Playwright.Page.console_messages/2` will only return messages logged after the clear.

*Since Playwright 1.59.*

# `clear_console_messages!`

```elixir
@spec clear_console_messages!(t()) :: :ok
```

Like `clear_console_messages/1`, but returns the value and raises on error.

# `clear_page_errors`

```elixir
@spec clear_page_errors(t()) :: :ok | {:error, Playwright.error()}
```

Clears all stored page errors from this page. Subsequent calls to `Playwright.Page.page_errors/2` will only return errors thrown after the clear.

*Since Playwright 1.59.*

# `clear_page_errors!`

```elixir
@spec clear_page_errors!(t()) :: :ok
```

Like `clear_page_errors/1`, but returns the value and raises on error.

# `click`

```elixir
@spec click(t(), String.t(), click_options()) :: :ok | {:error, Playwright.error()}
```

This method clicks an element matching `selector` by performing the following steps:

1. Find an element matching `selector`. If there is none, wait until a matching element is attached to
   the DOM.
1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless `:force` option is
   set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `Playwright.Page.mouse/1` to click in the center of the element, or the specified `:position`.
1. Wait for initiated navigations to either succeed or fail, unless `:no_wait_after` option is set.

When all steps combined have not finished during the specified `:timeout`, this method fails with a
[`TimeoutError`](`Playwright.TimeoutError`). Passing zero timeout disables this.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.click/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:button` (`:left` | `:right` | `:middle`) - Defaults to `:left`.
* `:click_count` (`t:integer/0`) - defaults to 1. See [`UIEvent.detail`](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail).
* `:delay` (`t:number/0`) - Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
* `:force` (`t:boolean/0`) - Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:modifiers` (list of `:alt` | `:control` | `:control_or_meta` | `:meta` | `:shift`) - Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
  modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
  and Linux and to "Meta" on macOS.
* `:no_wait_after` (`t:boolean/0`) - Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
  opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating
  to inaccessible pages. Defaults to `false`.
* `:position` (`t:map/0`) - A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
  element.
  * `:x`
  * `:y`
* `:scroll` (`:auto` | `:none`) - *Since Playwright 1.62.* Controls whether Playwright scrolls the element into view before performing the action. Defaults to `:auto`,
  which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to
  `:none`, Playwright does not scroll the element and the action fails if the element is not already in the viewport.
  This is useful to assert that an element is reachable by the user without additional scrolling.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:trial` (`t:boolean/0`) - *Since Playwright 1.11.* When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `:modifiers` will be pressed regardless of `:trial` to allow testing elements which are only visible when those keys are pressed.

# `click!`

```elixir
@spec click!(t(), String.t(), click_options()) :: :ok
```

Like `click/3`, but returns the value and raises on error.

# `clock`

```elixir
@spec clock(t()) :: Playwright.Clock.t()
```

Playwright has ability to mock clock and passage of time.

*Since Playwright 1.45.*

# `close`

```elixir
@spec close(t(), close_options()) :: :ok | {:error, Playwright.error()}
```

If `:run_before_unload` is `false`, does not run any unload handlers and waits for the page to be closed. If
`:run_before_unload` is `true` the method will run unload handlers, but will **not** wait for the page to close.

By default, `Playwright.Page.close/2` **does not** run `beforeunload` handlers.

> #### Note {: .info}
>
> if `:run_before_unload` is passed as true, a `beforeunload` dialog might be summoned and should be handled
> manually via [`Page.on(:dialog)`](Playwright.Page.html#module-dialog) event.

*Since Playwright 1.8.*

## Options

* `:reason` (`t:String.t/0`) - *Since Playwright 1.40.* The reason to be reported to the operations interrupted by the page closure.
* `:run_before_unload` (`t:boolean/0`) - Defaults to `false`. Whether to run the
  [before unload](https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload) page handlers.

# `close!`

```elixir
@spec close!(t(), close_options()) :: :ok
```

Like `close/2`, but returns the value and raises on error.

# `console_messages`

```elixir
@spec console_messages(t(), console_messages_options()) ::
  {:ok, [Playwright.ConsoleMessage.t()]} | {:error, Playwright.error()}
```

Returns up to (currently) 200 last console messages from this page. See [`Page.on(:console)`](Playwright.Page.html#module-console) for more details.

*Since Playwright 1.56.*

## Options

* `:filter` (`:all` | `:since_navigation`) - *Since Playwright 1.59.* Controls which messages are returned:

# `console_messages!`

```elixir
@spec console_messages!(t(), console_messages_options()) :: [
  Playwright.ConsoleMessage.t()
]
```

Like `console_messages/2`, but returns the value and raises on error.

# `content`

```elixir
@spec content(t(), content_options()) ::
  {:ok, String.t()} | {:error, Playwright.error()}
```

Gets the full HTML contents of the page, including the doctype.

*Since Playwright 1.8.*

## Options

* `:include_shadow` (`t:boolean/0`) - *Since Playwright 1.64.* When true, contents of open shadow roots are included as [declarative shadow DOM](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM#declaratively_with_html),
  i.e. `<template shadowrootmode="open">` elements nested inside their host elements. Closed shadow roots are never included. Defaults to `false`.

# `content!`

```elixir
@spec content!(t(), content_options()) :: String.t()
```

Like `content/2`, but returns the value and raises on error.

# `context`

```elixir
@spec context(t()) :: Playwright.BrowserContext.t()
```

Get the browser context that the page belongs to.

*Since Playwright 1.8.*

# `coverage`

```elixir
@spec coverage(t()) :: Playwright.Coverage.t()
```

> #### Note {: .info}
>
> Only available for Chromium atm.

Browser-specific Coverage implementation. See [`Coverage`](`Playwright.Coverage`) for more details.

*Since Playwright 1.8.*

# `dblclick`

```elixir
@spec dblclick(t(), String.t(), dblclick_options()) ::
  :ok | {:error, Playwright.error()}
```

This method double clicks an element matching `selector` by performing the following steps:

1. Find an element matching `selector`. If there is none, wait until a matching element is attached to
   the DOM.
1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless `:force` option is
   set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `Playwright.Page.mouse/1` to double click in the center of the element, or the specified `:position`.

When all steps combined have not finished during the specified `:timeout`, this method fails with a
[`TimeoutError`](`Playwright.TimeoutError`). Passing zero timeout disables this.

> #### Note {: .info}
>
> `Playwright.Page.dblclick/3` dispatches two `click` events and a single `dblclick` event.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.dblclick/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:button` (`:left` | `:right` | `:middle`) - Defaults to `:left`.
* `:delay` (`t:number/0`) - Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
* `:force` (`t:boolean/0`) - Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:modifiers` (list of `:alt` | `:control` | `:control_or_meta` | `:meta` | `:shift`) - Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
  modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
  and Linux and to "Meta" on macOS.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:position` (`t:map/0`) - A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
  element.
  * `:x`
  * `:y`
* `:scroll` (`:auto` | `:none`) - *Since Playwright 1.62.* Controls whether Playwright scrolls the element into view before performing the action. Defaults to `:auto`,
  which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to
  `:none`, Playwright does not scroll the element and the action fails if the element is not already in the viewport.
  This is useful to assert that an element is reachable by the user without additional scrolling.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:trial` (`t:boolean/0`) - *Since Playwright 1.11.* When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `:modifiers` will be pressed regardless of `:trial` to allow testing elements which are only visible when those keys are pressed.

# `dblclick!`

```elixir
@spec dblclick!(t(), String.t(), dblclick_options()) :: :ok
```

Like `dblclick/3`, but returns the value and raises on error.

# `dispatch_event`

```elixir
@spec dispatch_event(
  t(),
  String.t(),
  String.t(),
  term() | nil,
  dispatch_event_options()
) ::
  :ok | {:error, Playwright.error()}
```

The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click`
is dispatched. This is equivalent to calling
[element.click()](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click).

**Usage**

```elixir
Page.dispatch_event!(page, "button#submit", "click")
```

Under the hood, it creates an instance of an event based on the given `type`, initializes it with
`event_init` properties and dispatches it on the element. Events are `composed`, `cancelable` and bubble by
default.

Since `event_init` is event-specific, please refer to the events documentation for the lists of initial
properties:

* [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent/DeviceMotionEvent)
* [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent/DeviceOrientationEvent)
* [DragEvent](https://developer.mozilla.org/en-US/docs/Web/API/DragEvent/DragEvent)
* [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event/Event)
* [FocusEvent](https://developer.mozilla.org/en-US/docs/Web/API/FocusEvent/FocusEvent)
* [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent)
* [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
* [PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent)
* [TouchEvent](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent)
* [WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent)

You can also specify [`JSHandle`](`Playwright.JSHandle`) as the property value if you want live objects to be passed into the event:

```elixir
# Note you can only create DataTransfer in Chromium and Firefox
data_transfer = Page.evaluate_handle!(page, "() => new DataTransfer()")
Page.dispatch_event!(page, "#source", "dragstart", %{dataTransfer: data_transfer})
```

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.dispatch_event/4` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* `type` - DOM event type: `"click"`, `"dragstart"`, etc.
* `event_init` - Optional event-specific initialization properties.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `dispatch_event!`

```elixir
@spec dispatch_event!(
  t(),
  String.t(),
  String.t(),
  term() | nil,
  dispatch_event_options()
) :: :ok
```

Like `dispatch_event/5`, but returns the value and raises on error.

# `drag_and_drop`

```elixir
@spec drag_and_drop(t(), String.t(), String.t(), drag_and_drop_options()) ::
  :ok | {:error, Playwright.error()}
```

This method drags the source element to the target element.
It will first move to the source element, perform a `mousedown`,
then move to the target element and perform a `mouseup`.

**Usage**

```elixir
Page.drag_and_drop!(page, "#source", "#target")
# or specify exact positions relative to the top-left corners of the elements:
Page.drag_and_drop!(page, "#source", "#target",
  source_position: %{x: 34, y: 7},
  target_position: %{x: 10, y: 20}
)
```

*Since Playwright 1.13.*

## Arguments

* `source` - A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will be used.
* `target` - A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:force` (`t:boolean/0`) - Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:scroll` (`:auto` | `:none`) - *Since Playwright 1.62.* Controls whether Playwright scrolls the element into view before performing the action. Defaults to `:auto`,
  which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to
  `:none`, Playwright does not scroll the element and the action fails if the element is not already in the viewport.
  This is useful to assert that an element is reachable by the user without additional scrolling.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:source_position` (`t:map/0`) - *Since Playwright 1.14.* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not specified, some visible point of the element is used.
  * `:x`
  * `:y`
* `:steps` (`t:integer/0`) - *Since Playwright 1.57.* Defaults to 1. Sends `n` interpolated `mousemove` events to represent travel between the `mousedown` and `mouseup` of the drag. When set to 1, emits a single `mousemove` event at the destination location.
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:target_position` (`t:map/0`) - *Since Playwright 1.14.* Drops on the target element at this point relative to the top-left corner of the element's padding box. If not specified, some visible point of the element is used.
  * `:x`
  * `:y`
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:trial` (`t:boolean/0`) - When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it.

# `drag_and_drop!`

```elixir
@spec drag_and_drop!(t(), String.t(), String.t(), drag_and_drop_options()) :: :ok
```

Like `drag_and_drop/4`, but returns the value and raises on error.

# `emulate_media`

```elixir
@spec emulate_media(t(), emulate_media_options()) ::
  :ok | {:error, Playwright.error()}
```

This method changes the `CSS media type` through the `:media` option, and/or the `'prefers-colors-scheme'` media feature, using the `:color_scheme` option.

**Usage**

```elixir
Page.evaluate!(page, "() => matchMedia('screen').matches")
# => true
Page.evaluate!(page, "() => matchMedia('print').matches")
# => false

Page.emulate_media!(page, media: :print)
Page.evaluate!(page, "() => matchMedia('screen').matches")
# => false
Page.evaluate!(page, "() => matchMedia('print').matches")
# => true

# `:null` (JS `null`) removes the emulation, leaving `:media` out keeps it.
Page.emulate_media!(page, media: :null)
Page.evaluate!(page, "() => matchMedia('screen').matches")
# => true
Page.evaluate!(page, "() => matchMedia('print').matches")
# => false
```

```elixir
Page.emulate_media!(page, color_scheme: :dark)
Page.evaluate!(page, "() => matchMedia('(prefers-color-scheme: dark)').matches")
# => true
Page.evaluate!(page, "() => matchMedia('(prefers-color-scheme: light)').matches")
# => false
```

*Since Playwright 1.8.*

## Options

* `:color_scheme` (`:null` | `:light` | `:dark` | `:no_preference`) - *Since Playwright 1.9.* Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) media feature, supported values are `:light` and `:dark`. Passing
  `:null` disables color scheme emulation. `:no_preference` is deprecated.
* `:contrast` (`:null` | `:no_preference` | `:more`) - *Since Playwright 1.51.* Emulates `'prefers-contrast'` media feature, supported values are `:no_preference`, `:more`. Passing `:null` disables contrast emulation.
* `:forced_colors` (`:null` | `:active` | `:none`) - *Since Playwright 1.15.* Emulates `'forced-colors'` media feature, supported values are `:active` and `:none`. Passing `:null` disables forced colors emulation.
* `:media` (`:null` | `:screen` | `:print`) - *Since Playwright 1.9.* Changes the CSS media type of the page. The only allowed values are `:screen`, `:print` and `:null`.
  Passing `:null` disables CSS media emulation.
* `:reduced_motion` (`:null` | `:reduce` | `:no_preference`) - *Since Playwright 1.12.* Emulates `'prefers-reduced-motion'` media feature, supported values are `:reduce`, `:no_preference`. Passing `:null` disables reduced motion emulation.

# `emulate_media!`

```elixir
@spec emulate_media!(t(), emulate_media_options()) :: :ok
```

Like `emulate_media/2`, but returns the value and raises on error.

# `eval_on_selector`

```elixir
@spec eval_on_selector(t(), String.t(), String.t(), term() | nil) ::
  {:ok, term()} | {:error, Playwright.error()}
```

The method finds an element matching the specified selector within the page and passes it as a first argument to
`expression`. If no elements match the selector, the method fails. Returns the value of
`expression`.

If `expression` returns a `Promise`, then `Playwright.Page.eval_on_selector/4` would wait for the promise to resolve and
return its value.

**Usage**

```elixir
search_value = Page.eval_on_selector!(page, "#search", "el => el.value")
preload_href = Page.eval_on_selector!(page, "link[rel=preload]", "el => el.href")
html = Page.eval_on_selector!(page, ".main-container", "(e, suffix) => e.outerHTML + suffix", "hello")
```

> #### Discouraged {: .warning}
>
> This method does not wait for the element to pass actionability
> checks and therefore can lead to the flaky tests. Use `Playwright.Locator.evaluate/4`,
> other [`Locator`](`Playwright.Locator`) helper methods or web-first assertions instead.

*Since Playwright 1.9.*

## Arguments

* `selector` - A selector to query for.
* `expression` - Function to be evaluated in the page context.
* `arg` - Optional argument to pass to `expression`.

# `eval_on_selector!`

```elixir
@spec eval_on_selector!(t(), String.t(), String.t(), term() | nil) :: term()
```

Like `eval_on_selector/4`, but returns the value and raises on error.

# `eval_on_selector_all`

```elixir
@spec eval_on_selector_all(t(), String.t(), String.t(), term() | nil) ::
  {:ok, term()} | {:error, Playwright.error()}
```

The method finds all elements matching the specified selector within the page and passes an array of matched elements as
a first argument to `expression`. Returns the result of `expression` invocation.

If `expression` returns a `Promise`, then `Playwright.Page.eval_on_selector_all/4` would wait for the promise to resolve and
return its value.

**Usage**

```elixir
div_counts = Page.eval_on_selector_all!(page, "div", "(divs, min) => divs.length >= min", 10)
```

> #### Discouraged {: .warning}
>
> In most cases, `Playwright.Locator.evaluate_all/3`,
> other [`Locator`](`Playwright.Locator`) helper methods and web-first assertions do a better job.

*Since Playwright 1.9.*

## Arguments

* `selector` - A selector to query for.
* `expression` - Function to be evaluated in the page context.
* `arg` - Optional argument to pass to `expression`.

# `eval_on_selector_all!`

```elixir
@spec eval_on_selector_all!(t(), String.t(), String.t(), term() | nil) :: term()
```

Like `eval_on_selector_all/4`, but returns the value and raises on error.

# `evaluate`

```elixir
@spec evaluate(t(), String.t(), term() | nil, evaluate_options()) ::
  {:ok, term()} | {:error, Playwright.error()}
```

Returns the value of the `expression` invocation.

If the function passed to the `Playwright.Page.evaluate/4` returns a `Promise`, then `Playwright.Page.evaluate/4` would wait
for the promise to resolve and return its value.

If the function passed to the `Playwright.Page.evaluate/4` returns a non-`Serializable` value, then
`Playwright.Page.evaluate/4` returns `nil`. Playwright also supports transferring some
additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.

**Usage**

Passing argument to `expression`:

```elixir
result = Page.evaluate!(page, "([x, y]) => Promise.resolve(x * y)", [7, 8])
# prints "56"
IO.puts(result)
```

A string can also be passed in instead of a function:

```elixir
# prints "3"
IO.puts(Page.evaluate!(page, "1 + 2"))
x = 10
# prints "11"
IO.puts(Page.evaluate!(page, "1 + #{x}"))
```

[`ElementHandle`](`Playwright.ElementHandle`) instances can be passed as an argument to the `Playwright.Page.evaluate/4`:

```elixir
body_handle = Page.evaluate_handle!(page, "document.body")
html = Page.evaluate!(page, "([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
JSHandle.dispose!(body_handle)
```

*Since Playwright 1.8.*

## Arguments

* `expression` - Function to be evaluated in the page context.
* `arg` - Optional argument to pass to `expression`.

## Options

* `:expose_functions` (`t:boolean/0`) - *Since Playwright 1.62.* When set to `true`, functions passed inside `arg` are exposed in the page and can be called from the page function. Calling one returns a `Promise` of its result. Under the hood, each function is exposed via `Playwright.Page.expose_function/3`, so it is technically accessible from all frames of the page. Exposed functions are cleared upon the top-level navigation. Defaults to `false`, in which case functions are not serializable and passing one fails.

# `evaluate!`

```elixir
@spec evaluate!(t(), String.t(), term() | nil, evaluate_options()) :: term()
```

Like `evaluate/4`, but returns the value and raises on error.

# `evaluate_handle`

```elixir
@spec evaluate_handle(t(), String.t(), term() | nil, evaluate_handle_options()) ::
  {:ok, Playwright.JSHandle.t()} | {:error, Playwright.error()}
```

Returns the value of the `expression` invocation as a [`JSHandle`](`Playwright.JSHandle`).

The only difference between `Playwright.Page.evaluate/4` and `Playwright.Page.evaluate_handle/4` is that `Playwright.Page.evaluate_handle/4` returns [`JSHandle`](`Playwright.JSHandle`).

If the function passed to the `Playwright.Page.evaluate_handle/4` returns a `Promise`, then `Playwright.Page.evaluate_handle/4` would wait for the
promise to resolve and return its value.

**Usage**

```elixir
# Handle for the window object.
a_window_handle = Page.evaluate_handle!(page, "() => Promise.resolve(window)")
```

A string can also be passed in instead of a function:

```elixir
# Handle for the "document"
a_handle = Page.evaluate_handle!(page, "document")
```

[`JSHandle`](`Playwright.JSHandle`) instances can be passed as an argument to the `Playwright.Page.evaluate_handle/4`:

```elixir
a_handle = Page.evaluate_handle!(page, "() => document.body")
result_handle = Page.evaluate_handle!(page, "body => body.innerHTML", a_handle)
IO.puts(JSHandle.json_value!(result_handle))
JSHandle.dispose!(result_handle)
```

*Since Playwright 1.8.*

## Arguments

* `expression` - Function to be evaluated in the page context.
* `arg` - Optional argument to pass to `expression`.

## Options

* `:expose_functions` (`t:boolean/0`) - *Since Playwright 1.62.* When set to `true`, functions passed inside `arg` are exposed in the page and can be called from the page function. Calling one returns a `Promise` of its result. Under the hood, each function is exposed via `Playwright.Page.expose_function/3`, so it is technically accessible from all frames of the page. Exposed functions are cleared upon the top-level navigation. Defaults to `false`, in which case functions are not serializable and passing one fails.

# `evaluate_handle!`

```elixir
@spec evaluate_handle!(t(), String.t(), term() | nil, evaluate_handle_options()) ::
  Playwright.JSHandle.t()
```

Like `evaluate_handle/4`, but returns the value and raises on error.

# `expect_console_message`

```elixir
@spec expect_console_message(
  t(),
  (-&gt; term()),
  expect_console_message_options() | fun()
) ::
  {:ok, Playwright.ConsoleMessage.t()} | {:error, Playwright.error()}
```

Performs action and waits for a [`ConsoleMessage`](`Playwright.ConsoleMessage`) to be logged by in the page. If predicate is provided, it passes
[`ConsoleMessage`](`Playwright.ConsoleMessage`) value into the `:predicate` function and waits for `predicate(message)` to return a truthy value.
Will fail if the page is closed before the [`Page.on(:console)`](Playwright.Page.html#module-console) event is fired.

*Since Playwright 1.9.*

## Arguments

* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`(Playwright.ConsoleMessage.t() -> boolean())`) - Receives the [`ConsoleMessage`](`Playwright.ConsoleMessage`) object and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed by using the `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_console_message!`

```elixir
@spec expect_console_message!(
  t(),
  (-&gt; term()),
  expect_console_message_options() | fun()
) ::
  Playwright.ConsoleMessage.t()
```

Like `expect_console_message/3`, but returns the value and raises on error.

# `expect_download`

```elixir
@spec expect_download(t(), (-&gt; term()), expect_download_options() | fun()) ::
  {:ok, Playwright.Download.t()} | {:error, Playwright.error()}
```

Performs action and waits for a new [`Download`](`Playwright.Download`). If predicate is provided, it passes
[`Download`](`Playwright.Download`) value into the `:predicate` function and waits for `predicate(download)` to return a truthy value.
Will fail if the page is closed before the download event is fired.

*Since Playwright 1.9.*

## Arguments

* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`(Playwright.Download.t() -> boolean())`) - Receives the [`Download`](`Playwright.Download`) object and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed by using the `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_download!`

```elixir
@spec expect_download!(t(), (-&gt; term()), expect_download_options() | fun()) ::
  Playwright.Download.t()
```

Like `expect_download/3`, but returns the value and raises on error.

# `expect_event`

```elixir
@spec expect_event(
  t(),
  event() | String.t(),
  (-&gt; term()),
  expect_event_options() | fun()
) ::
  {:ok, term()} | {:error, Playwright.error()}
```

Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
value. Will fail if the page is closed before the event is fired. Returns the event data value.

**Usage**

```elixir
# Start waiting for download before clicking: a promise, awaited after.
download_promise = Page.wait_for_event(page, :download)
Page.get_by_text(page, "Download file") |> Locator.click!()
download = Promise.await!(download_promise)
```

*Since Playwright 1.8.*

## Arguments

* `event` - Event name, same one typically passed into `Playwright.Page.on/3`.
* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`t:fun/0`) - Receives the event data and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed with `Playwright.Page.set_default_timeout/2` or `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_event!`

```elixir
@spec expect_event!(
  t(),
  event() | String.t(),
  (-&gt; term()),
  expect_event_options() | fun()
) :: term()
```

Like `expect_event/4`, but returns the value and raises on error.

# `expect_file_chooser`

```elixir
@spec expect_file_chooser(t(), (-&gt; term()), expect_file_chooser_options() | fun()) ::
  {:ok, Playwright.FileChooser.t()} | {:error, Playwright.error()}
```

Performs action and waits for a new [`FileChooser`](`Playwright.FileChooser`) to be created. If predicate is provided, it passes
[`FileChooser`](`Playwright.FileChooser`) value into the `:predicate` function and waits for `predicate(fileChooser)` to return a truthy value.
Will fail if the page is closed before the file chooser is opened.

*Since Playwright 1.9.*

## Arguments

* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`(Playwright.FileChooser.t() -> boolean())`) - Receives the [`FileChooser`](`Playwright.FileChooser`) object and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed by using the `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_file_chooser!`

```elixir
@spec expect_file_chooser!(t(), (-&gt; term()), expect_file_chooser_options() | fun()) ::
  Playwright.FileChooser.t()
```

Like `expect_file_chooser/3`, but returns the value and raises on error.

# `expect_navigation`

> This function is deprecated. This method is inherently racy, please use Playwright.Page.wait_for_url/3 instead.

```elixir
@spec expect_navigation(t(), (-&gt; term()), expect_navigation_options()) ::
  {:ok, nil | Playwright.Response.t()} | {:error, Playwright.error()}
```

Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the navigation
returns the response of the last redirect. In case of navigation to a different anchor or navigation due to
History API usage, the navigation returns `nil`.

**Usage**

This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly
cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`.
Consider this example:

```elixir
# Start waiting for navigation before clicking: a promise, awaited after.
navigation_promise = Page.wait_for_navigation(page)
Page.get_by_text(page, "Navigate after timeout") |> Locator.click!()
Promise.await!(navigation_promise)
```

> #### Note {: .info}
>
> Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered
> a navigation.

*Since Playwright 1.8.*

## Arguments

* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:url` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0` | `(URI.t() -> boolean())`) - A glob pattern, regex pattern, or predicate receiving `URI` to match while waiting for the navigation. Note that if
  the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
  equal to the string.
* `:wait_until` (`:load` | `:domcontentloaded` | `:networkidle` | `:commit`) - When to consider operation succeeded, defaults to `:load`. Events can be either:

  * `:domcontentloaded` - consider operation to be finished when the `DOMContentLoaded` event is fired.
  * `:load` - consider operation to be finished when the `load` event is fired.
  * `:networkidle` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
  * `:commit` - consider operation to be finished when network response is received and the document started loading.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_navigation!`

> This function is deprecated. This method is inherently racy, please use Playwright.Page.wait_for_url/3 instead.

```elixir
@spec expect_navigation!(t(), (-&gt; term()), expect_navigation_options()) ::
  nil | Playwright.Response.t()
```

Like `expect_navigation/3`, but returns the value and raises on error.

# `expect_popup`

```elixir
@spec expect_popup(t(), (-&gt; term()), expect_popup_options() | fun()) ::
  {:ok, t()} | {:error, Playwright.error()}
```

Performs action and waits for a popup [`Page`](`Playwright.Page`). If predicate is provided, it passes
`Popup` value into the `:predicate` function and waits for `predicate(page)` to return a truthy value.
Will fail if the page is closed before the popup event is fired.

*Since Playwright 1.9.*

## Arguments

* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`(Playwright.Page.t() -> boolean())`) - Receives the [`Page`](`Playwright.Page`) object and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed by using the `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_popup!`

```elixir
@spec expect_popup!(t(), (-&gt; term()), expect_popup_options() | fun()) :: t()
```

Like `expect_popup/3`, but returns the value and raises on error.

# `expect_request`

```elixir
@spec expect_request(
  t(),
  String.t()
  | Regex.t()
  | Playwright.RegExp.t()
  | (Playwright.Request.t() -&gt; boolean()),
  (-&gt; term()),
  expect_request_options()
) :: {:ok, Playwright.Request.t()} | {:error, Playwright.error()}
```

Waits for the matching request and returns it. See [waiting for event](https://playwright.dev/docs/events#waiting-for-event) for more details about events.

**Usage**

```elixir
# Start waiting for request before clicking: a promise, awaited after.
request_promise = Page.wait_for_request(page, "https://example.com/resource")
Page.get_by_text(page, "trigger request") |> Locator.click!()
first_request = Promise.await!(request_promise)

# Alternative way with a predicate.
request_promise =
  Page.wait_for_request(page, fn request ->
    Request.url(request) == "https://example.com/" and Request.method(request) == "GET"
  end)

Page.get_by_text(page, "trigger request") |> Locator.click!()
second_request = Promise.await!(request_promise)
```

*Since Playwright 1.8.*

## Arguments

* `url_or_predicate` - Request URL string, regex or predicate receiving [`Request`](`Playwright.Request`) object.
  When a `:base_url` via the context options was provided and the passed URL is a path,
  it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

* `:timeout` (`t:number/0` | `:infinity`) - Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be
  changed by using the `Playwright.Page.set_default_timeout/2` method.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_request!`

```elixir
@spec expect_request!(
  t(),
  String.t()
  | Regex.t()
  | Playwright.RegExp.t()
  | (Playwright.Request.t() -&gt; boolean()),
  (-&gt; term()),
  expect_request_options()
) :: Playwright.Request.t()
```

Like `expect_request/4`, but returns the value and raises on error.

# `expect_request_finished`

```elixir
@spec expect_request_finished(
  t(),
  (-&gt; term()),
  expect_request_finished_options() | fun()
) ::
  {:ok, Playwright.Request.t()} | {:error, Playwright.error()}
```

Performs action and waits for a [`Request`](`Playwright.Request`) to finish loading. If predicate is provided, it passes
[`Request`](`Playwright.Request`) value into the `:predicate` function and waits for `predicate(request)` to return a truthy value.
Will fail if the page is closed before the [`Page.on(:request_finished)`](Playwright.Page.html#module-request_finished) event is fired.

*Since Playwright 1.12.*

## Arguments

* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`(Playwright.Request.t() -> boolean())`) - Receives the [`Request`](`Playwright.Request`) object and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed by using the `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_request_finished!`

```elixir
@spec expect_request_finished!(
  t(),
  (-&gt; term()),
  expect_request_finished_options() | fun()
) ::
  Playwright.Request.t()
```

Like `expect_request_finished/3`, but returns the value and raises on error.

# `expect_response`

```elixir
@spec expect_response(
  t(),
  String.t()
  | Regex.t()
  | Playwright.RegExp.t()
  | (Playwright.Response.t() -&gt; boolean()),
  (-&gt; term()),
  expect_response_options()
) :: {:ok, Playwright.Response.t()} | {:error, Playwright.error()}
```

Returns the matched response. See [waiting for event](https://playwright.dev/docs/events#waiting-for-event) for more details about events.

**Usage**

```elixir
# Start waiting for response before clicking: a promise, awaited after.
response_promise = Page.wait_for_response(page, "https://example.com/resource")
Page.get_by_text(page, "trigger response") |> Locator.click!()
first_response = Promise.await!(response_promise)

# Alternative way with a predicate.
response_promise =
  Page.wait_for_response(page, fn response ->
    Response.url(response) == "https://example.com/" and Response.status(response) == 200 and
      Request.method(Response.request(response)) == "GET"
  end)

Page.get_by_text(page, "trigger response") |> Locator.click!()
second_response = Promise.await!(response_promise)
```

*Since Playwright 1.8.*

## Arguments

* `url_or_predicate` - Request URL string, regex or predicate receiving [`Response`](`Playwright.Response`) object.
  When a `:base_url` via the context options was provided and the passed URL is a path,
  it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

* `:timeout` (`t:number/0` | `:infinity`) - Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be
  changed by using the `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_response!`

```elixir
@spec expect_response!(
  t(),
  String.t()
  | Regex.t()
  | Playwright.RegExp.t()
  | (Playwright.Response.t() -&gt; boolean()),
  (-&gt; term()),
  expect_response_options()
) :: Playwright.Response.t()
```

Like `expect_response/4`, but returns the value and raises on error.

# `expect_websocket`

```elixir
@spec expect_websocket(t(), (-&gt; term()), expect_websocket_options() | fun()) ::
  {:ok, Playwright.WebSocket.t()} | {:error, Playwright.error()}
```

Performs action and waits for a new [`WebSocket`](`Playwright.WebSocket`). If predicate is provided, it passes
[`WebSocket`](`Playwright.WebSocket`) value into the `:predicate` function and waits for `predicate(webSocket)` to return a truthy value.
Will fail if the page is closed before the WebSocket event is fired.

*Since Playwright 1.9.*

## Arguments

* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`(Playwright.WebSocket.t() -> boolean())`) - Receives the [`WebSocket`](`Playwright.WebSocket`) object and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed by using the `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_websocket!`

```elixir
@spec expect_websocket!(t(), (-&gt; term()), expect_websocket_options() | fun()) ::
  Playwright.WebSocket.t()
```

Like `expect_websocket/3`, but returns the value and raises on error.

# `expect_worker`

```elixir
@spec expect_worker(t(), (-&gt; term()), expect_worker_options() | fun()) ::
  {:ok, Playwright.Worker.t()} | {:error, Playwright.error()}
```

Performs action and waits for a new [`Worker`](`Playwright.Worker`). If predicate is provided, it passes
[`Worker`](`Playwright.Worker`) value into the `:predicate` function and waits for `predicate(worker)` to return a truthy value.
Will fail if the page is closed before the worker event is fired.

*Since Playwright 1.9.*

## Arguments

* `action` - A function that performs the action triggering the wait. It runs once the wait is set up; its result is ignored and what it raises propagates.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`(Playwright.Worker.t() -> boolean())`) - Receives the [`Worker`](`Playwright.Worker`) object and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed by using the `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

# `expect_worker!`

```elixir
@spec expect_worker!(t(), (-&gt; term()), expect_worker_options() | fun()) ::
  Playwright.Worker.t()
```

Like `expect_worker/3`, but returns the value and raises on error.

# `expose_binding`

```elixir
@spec expose_binding(t(), String.t(), fun()) ::
  {:ok, Playwright.Disposable.t()} | {:error, Playwright.error()}
```

The method adds a function called `name` on the `window` object of every frame in this page. When called, the
function executes `callback` and returns a `Promise` which resolves to the return value of `callback`.
If `callback` returns a `Playwright.Promise`, it is awaited.

The first argument of the `callback` function contains information about the caller: `{ browserContext:
BrowserContext, page: Page, frame: Frame }`.

See `Playwright.BrowserContext.expose_binding/3` for the context-wide version.

> #### Note {: .info}
>
> Functions installed via `Playwright.Page.expose_binding/3` survive navigations.

**Usage**

An example of exposing page URL to all frames in a page:

```elixir
# Or Playwright.chromium/1 or Playwright.firefox/1.
browser = Playwright.webkit(playwright) |> BrowserType.launch!(headless: false)
context = Browser.new_context!(browser)
page = BrowserContext.new_page!(context)
Page.expose_binding!(page, "pageURL", fn %{page: page} -> Page.url(page) end)

Page.set_content!(page, """
<script>
  async function onClick() {
    document.querySelector('div').textContent = await window.pageURL();
  }
</script>
<button onclick="onClick()">Click me</button>
<div></div>
""")

Page.click!(page, "button")
```

*Since Playwright 1.8.*

## Arguments

* `name` - Name of the function on the window object.
* `callback` - Callback function that will be called in the Playwright's context.

# `expose_binding!`

```elixir
@spec expose_binding!(t(), String.t(), fun()) :: Playwright.Disposable.t()
```

Like `expose_binding/3`, but returns the value and raises on error.

# `expose_function`

```elixir
@spec expose_function(t(), String.t(), fun()) ::
  {:ok, Playwright.Disposable.t()} | {:error, Playwright.error()}
```

The method adds a function called `name` on the `window` object of every frame in the page. When called, the
function executes `callback` and returns a `Promise` which resolves to the return value of `callback`.

If `callback` returns a `Playwright.Promise`, it is awaited.

See `Playwright.BrowserContext.expose_function/3` for context-wide exposed function.

> #### Note {: .info}
>
> Functions installed via `Playwright.Page.expose_function/3` survive navigations.

**Usage**

An example of adding a `sha256` function to the page:

```elixir
# Or Playwright.chromium/1 or Playwright.firefox/1.
browser = Playwright.webkit(playwright) |> BrowserType.launch!(headless: false)
page = Browser.new_page!(browser)

Page.expose_function!(page, "sha256", fn text ->
  :crypto.hash(:sha256, text) |> Base.encode16(case: :lower)
end)

Page.set_content!(page, """
<script>
  async function onClick() {
    document.querySelector('div').textContent = await window.sha256('PLAYWRIGHT');
  }
</script>
<button onclick="onClick()">Click me</button>
<div></div>
""")

Page.click!(page, "button")
```

*Since Playwright 1.8.*

## Arguments

* `name` - Name of the function on the window object
* `callback` - Callback function which will be called in Playwright's context.

# `expose_function!`

```elixir
@spec expose_function!(t(), String.t(), fun()) :: Playwright.Disposable.t()
```

Like `expose_function/3`, but returns the value and raises on error.

# `fill`

```elixir
@spec fill(t(), String.t(), String.t(), fill_options()) ::
  :ok | {:error, Playwright.error()}
```

This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.

If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method fails. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.

To send fine-grained keyboard events, use `Playwright.Locator.press_sequentially/3`.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.fill/3` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* `value` - Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.

## Options

* `:force` (`t:boolean/0`) - *Since Playwright 1.13.* Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `fill!`

```elixir
@spec fill!(t(), String.t(), String.t(), fill_options()) :: :ok
```

Like `fill/4`, but returns the value and raises on error.

# `focus`

```elixir
@spec focus(t(), String.t(), focus_options()) :: :ok | {:error, Playwright.error()}
```

This method fetches an element with `selector` and focuses it. If there's no element matching
`selector`, the method waits until a matching element appears in the DOM.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.focus/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `focus!`

```elixir
@spec focus!(t(), String.t(), focus_options()) :: :ok
```

Like `focus/3`, but returns the value and raises on error.

# `frame`

```elixir
@spec frame(
  t(),
  String.t()
  | %{
      optional(:name) =&gt; String.t(),
      optional(:url) =&gt;
        String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean())
    }
) :: nil | Playwright.Frame.t()
```

Returns frame matching the specified criteria. Either `name` or `url` must be specified.

**Usage**

```elixir
frame = Page.frame(page, "frame-name")
```

```elixir
frame = Page.frame(page, %{url: ~r/.*domain.*/})
```

*Since Playwright 1.8.*

## Arguments

* `frame_selector` - Frame name or other frame lookup options.
  * `:name` - Frame name specified in the `iframe`'s `name` attribute. Optional.
  * `:url` - A glob pattern, regex pattern, URL pattern, or predicate receiving
    frame's `url` as a `URI` object. Optional.

# `frame_locator`

```elixir
@spec frame_locator(t(), String.t() | nil) :: Playwright.FrameLocator.t()
```

When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements
in that iframe.

When called without `selector`, the search starts in any frame on the page - the main frame or any of
the iframes - so that you don't need to locate each iframe first. Note that the rest of the locator is resolved
inside a single frame, just like any other locator. If it matches elements inside multiple frames, the call fails.

**Usage**

Following snippet locates element with text "Submit" in the iframe with id `my-frame`,
like `<iframe id="my-frame">`:

```elixir
locator = Page.frame_locator(page, "#my-iframe") |> FrameLocator.get_by_text("Submit")
Locator.click!(locator)
```

Following snippet locates a button, either in the main frame or in one of the iframes:

```elixir
locator = Page.frame_locator(page) |> FrameLocator.get_by_role(:button)
Locator.click!(locator)
```

*Since Playwright 1.17.*

## Arguments

* `selector` - A selector that matches the frame element. When not specified, locator is matched in any frame on the page.

# `frames`

```elixir
@spec frames(t()) :: [Playwright.Frame.t()]
```

An array of all frames attached to the page.

*Since Playwright 1.8.*

# `get_attribute`

```elixir
@spec get_attribute(t(), String.t(), String.t(), get_attribute_options()) ::
  {:ok, nil | String.t()} | {:error, Playwright.error()}
```

Returns element attribute value.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.get_attribute/3` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* `name` - Attribute name to get the value for.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `get_attribute!`

```elixir
@spec get_attribute!(t(), String.t(), String.t(), get_attribute_options()) ::
  nil | String.t()
```

Like `get_attribute/4`, but returns the value and raises on error.

# `get_by_alt_text`

```elixir
@spec get_by_alt_text(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t(),
  get_by_alt_text_options()
) ::
  Playwright.Locator.t()
```

Allows locating elements by their alt text.

**Usage**

For example, this method will find the image by alt text "Playwright logo":

```html
<img alt='Playwright logo'>
```

```elixir
Page.get_by_alt_text(page, "Playwright logo") |> Locator.click!()
```

*Since Playwright 1.27.*

## Arguments

* `text` - Text to locate the element for.

## Options

* `:exact` (`t:boolean/0`) - Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

# `get_by_label`

```elixir
@spec get_by_label(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t(),
  get_by_label_options()
) ::
  Playwright.Locator.t()
```

Allows locating input elements by the text of the associated `<label>` or `aria-labelledby` element, or by the `aria-label` attribute.

**Usage**

For example, this method will find inputs by label "Username" and "Password" in the following DOM:

```html
<input aria-label="Username">
<label for="password-input">Password:</label>
<input id="password-input">
```

```elixir
Page.get_by_label(page, "Username") |> Locator.fill!("john")
Page.get_by_label(page, "Password") |> Locator.fill!("secret")
```

*Since Playwright 1.27.*

## Arguments

* `text` - Text to locate the element for.

## Options

* `:exact` (`t:boolean/0`) - Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

# `get_by_placeholder`

```elixir
@spec get_by_placeholder(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t(),
  get_by_placeholder_options()
) :: Playwright.Locator.t()
```

Allows locating input elements by the placeholder text.

**Usage**

For example, consider the following DOM structure.

```html
<input type="email" placeholder="name@example.com" />
```

You can fill the input after locating it by the placeholder text:

```elixir
Page.get_by_placeholder(page, "name@example.com") |> Locator.fill!("playwright@microsoft.com")
```

*Since Playwright 1.27.*

## Arguments

* `text` - Text to locate the element for.

## Options

* `:exact` (`t:boolean/0`) - Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

# `get_by_ref`

```elixir
@spec get_by_ref(t(), String.t()) :: Playwright.Locator.t()
```

Locate element by its aria ref. Refs like `[ref=e2]` are reported by `Playwright.Page.aria_snapshot/2` when called with
the `"ai"` mode, and resolve against the latest snapshot taken in the element's frame.

**Usage**

Consider the following aria snapshot.

```yaml
- button "Submit" [ref=e2]
```

You can locate the button by its ref:

```elixir
Page.get_by_ref(page, "e2") |> Locator.click!()
```

*Since Playwright 1.64.*

## Arguments

* `ref` - Aria ref of the element, for example `e2` or `f1e3`.

# `get_by_role`

```elixir
@spec get_by_role(
  t(),
  :alert
  | :alertdialog
  | :application
  | :article
  | :banner
  | :blockquote
  | :button
  | :caption
  | :cell
  | :checkbox
  | :code
  | :columnheader
  | :combobox
  | :complementary
  | :contentinfo
  | :definition
  | :deletion
  | :dialog
  | :directory
  | :document
  | :emphasis
  | :feed
  | :figure
  | :form
  | :generic
  | :grid
  | :gridcell
  | :group
  | :heading
  | :img
  | :insertion
  | :link
  | :list
  | :listbox
  | :listitem
  | :log
  | :main
  | :marquee
  | :math
  | :meter
  | :menu
  | :menubar
  | :menuitem
  | :menuitemcheckbox
  | :menuitemradio
  | :navigation
  | :none
  | :note
  | :option
  | :paragraph
  | :presentation
  | :progressbar
  | :radio
  | :radiogroup
  | :region
  | :row
  | :rowgroup
  | :rowheader
  | :scrollbar
  | :search
  | :searchbox
  | :separator
  | :slider
  | :spinbutton
  | :status
  | :strong
  | :subscript
  | :superscript
  | :switch
  | :tab
  | :table
  | :tablist
  | :tabpanel
  | :term
  | :textbox
  | :time
  | :timer
  | :toolbar
  | :tooltip
  | :tree
  | :treegrid
  | :treeitem
  | String.t(),
  get_by_role_options()
) :: Playwright.Locator.t()
```

Allows locating elements by their [ARIA role](https://www.w3.org/TR/wai-aria-1.2/#roles), [ARIA attributes](https://www.w3.org/TR/wai-aria-1.2/#aria-attributes) and [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).

**Usage**

Consider the following DOM structure.

```html
<h3>Sign up</h3>
<label>
  <input type="checkbox" /> Subscribe
</label>
<br/>
<button>Submit</button>
```

You can locate each element by its implicit role:

```elixir
Page.get_by_role(page, :heading, name: "Sign up") |> Expect.to_be_visible!()

Page.get_by_role(page, :checkbox, name: "Subscribe") |> Locator.check!()

Page.get_by_role(page, :button, name: ~r/submit/i) |> Locator.click!()
```

**Details**

Role selector **does not replace** accessibility audits and conformance tests, but rather gives early feedback about the ARIA guidelines.

Many html elements have an implicitly [defined role](https://w3c.github.io/html-aam/#html-element-role-mappings) that is recognized by the role selector. You can find all the [supported roles here](https://www.w3.org/TR/wai-aria-1.2/#role_definitions). ARIA guidelines **do not recommend** duplicating implicit roles and attributes by setting `role` and/or `aria-*` attributes to default values.

*Since Playwright 1.27.*

## Arguments

* `role` - Required aria role.

  In Elixir, a role is an atom of the typespec (`:button`) or a string, also one the typespec lacks (`"mark"`): the JS client takes any string.

## Options

* `:checked` (`t:boolean/0`) - An attribute that is usually set by `aria-checked` or native `<input type=checkbox>` controls.

  Learn more about [`aria-checked`](https://www.w3.org/TR/wai-aria-1.2/#aria-checked).
* `:description` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0`) - *Since Playwright 1.60.* Option to match the [accessible description](https://w3c.github.io/accname/#dfn-accessible-description). By default, matching is case-insensitive and searches for a substring, use `:exact` to control this behavior.

  Learn more about [accessible description](https://w3c.github.io/accname/#dfn-accessible-description).
* `:disabled` (`t:boolean/0`) - An attribute that is usually set by `aria-disabled` or `disabled`.

  > #### Note {: .info}
  >
  > Unlike most other attributes, `disabled` is inherited through the DOM hierarchy.
  > Learn more about [`aria-disabled`](https://www.w3.org/TR/wai-aria-1.2/#aria-disabled).
* `:exact` (`t:boolean/0`) - *Since Playwright 1.28.* Whether `:name` and `:description` are matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when the value is a regular expression. Note that exact match still trims whitespace.
* `:expanded` (`t:boolean/0`) - An attribute that is usually set by `aria-expanded`.

  Learn more about [`aria-expanded`](https://www.w3.org/TR/wai-aria-1.2/#aria-expanded).
* `:include_hidden` (`t:boolean/0`) - Option that controls whether hidden elements are matched. By default, only non-hidden elements, as [defined by ARIA](https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion), are matched by role selector.

  Learn more about [`aria-hidden`](https://www.w3.org/TR/wai-aria-1.2/#aria-hidden).
* `:level` (`t:integer/0`) - A number attribute that is usually present for roles `heading`, `listitem`, `row`, `treeitem`, with default values for `<h1>-<h6>` elements.

  Learn more about [`aria-level`](https://www.w3.org/TR/wai-aria-1.2/#aria-level).
* `:name` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0`) - Option to match the [accessible name](https://w3c.github.io/accname/#dfn-accessible-name). By default, matching is case-insensitive and searches for a substring, use `:exact` to control this behavior.

  Learn more about [accessible name](https://w3c.github.io/accname/#dfn-accessible-name).
* `:pressed` (`t:boolean/0`) - An attribute that is usually set by `aria-pressed`.

  Learn more about [`aria-pressed`](https://www.w3.org/TR/wai-aria-1.2/#aria-pressed).
* `:selected` (`t:boolean/0`) - An attribute that is usually set by `aria-selected`.

  Learn more about [`aria-selected`](https://www.w3.org/TR/wai-aria-1.2/#aria-selected).

# `get_by_test_id`

```elixir
@spec get_by_test_id(t(), String.t() | Regex.t() | Playwright.RegExp.t()) ::
  Playwright.Locator.t()
```

Locate element by the test id.

**Usage**

Consider the following DOM structure.

```html
<button data-testid="directions">Itinéraire</button>
```

You can locate the element by its test id:

```elixir
Page.get_by_test_id(page, "directions") |> Locator.click!()
```

**Details**

By default, the `data-testid` attribute is used as a test id. Use `Playwright.Selectors.set_test_id_attribute/2` to configure a different test id attribute if necessary.

```elixir
# Set a custom test id attribute:
Playwright.selectors(playwright) |> Selectors.set_test_id_attribute("data-pw")
```

*Since Playwright 1.27.*

## Arguments

* `test_id` - Id to locate the element by.

# `get_by_text`

```elixir
@spec get_by_text(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t(),
  get_by_text_options()
) ::
  Playwright.Locator.t()
```

Allows locating elements that contain given text.

See also `Playwright.Locator.filter/2` that allows to match by another criteria, like an accessible role, and then filter by the text content.

**Usage**

Consider the following DOM structure:

```html
<div>Hello <span>world</span></div>
<div>Hello</div>
```

You can locate by text substring, exact string, or a regular expression:

```elixir
# Matches <span>
Page.get_by_text(page, "world")

# Matches first <div>
Page.get_by_text(page, "Hello world")

# Matches second <div>
Page.get_by_text(page, "Hello", exact: true)

# Matches both <div>s
Page.get_by_text(page, ~r/Hello/)

# Matches second <div>
Page.get_by_text(page, ~r/^hello$/i)
```

**Details**

Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.

Input elements of the type `button` and `submit` are matched by their `value` instead of the text content. For example, locating by text `"Log in"` matches `<input type=button value="Log in">`.

*Since Playwright 1.27.*

## Arguments

* `text` - Text to locate the element for.

## Options

* `:exact` (`t:boolean/0`) - Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

# `get_by_title`

```elixir
@spec get_by_title(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t(),
  get_by_title_options()
) ::
  Playwright.Locator.t()
```

Allows locating elements by their title attribute.

**Usage**

Consider the following DOM structure.

```html
<span title='Issues count'>25 issues</span>
```

You can check the issues count after locating it by the title text:

```elixir
Page.get_by_title(page, "Issues count") |> Expect.to_have_text!("25 issues")
```

*Since Playwright 1.27.*

## Arguments

* `text` - Text to locate the element for.

## Options

* `:exact` (`t:boolean/0`) - Whether to find an exact match: case-sensitive and whole-string. Default to false. Ignored when locating by a regular expression. Note that exact match still trims whitespace.

# `go_back`

```elixir
@spec go_back(t(), go_back_options()) ::
  {:ok, nil | Playwright.Response.t()} | {:error, Playwright.error()}
```

Returns the main resource response. In case of multiple redirects, the navigation returns the response of the
last redirect. If cannot go back, returns `nil`.

Navigate to the previous page in history.

> #### Warning {: .warning}
>
> **Testing Back/Forward Cache (BFCache) is not supported.**
> By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `Playwright.Page.go_back/2` or `Playwright.Page.go_forward/2` to trigger a BFCache restore will result in timeouts and a desynchronized [`Page`](`Playwright.Page`) state.

*Since Playwright 1.8.*

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:wait_until` (`:load` | `:domcontentloaded` | `:networkidle` | `:commit`) - When to consider operation succeeded, defaults to `:load`. Events can be either:

  * `:domcontentloaded` - consider operation to be finished when the `DOMContentLoaded` event is fired.
  * `:load` - consider operation to be finished when the `load` event is fired.
  * `:networkidle` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
  * `:commit` - consider operation to be finished when network response is received and the document started loading.

# `go_back!`

```elixir
@spec go_back!(t(), go_back_options()) :: nil | Playwright.Response.t()
```

Like `go_back/2`, but returns the value and raises on error.

# `go_forward`

```elixir
@spec go_forward(t(), go_forward_options()) ::
  {:ok, nil | Playwright.Response.t()} | {:error, Playwright.error()}
```

Returns the main resource response. In case of multiple redirects, the navigation returns the response of the
last redirect. If cannot go forward, returns `nil`.

Navigate to the next page in history.

> #### Warning {: .warning}
>
> **Testing Back/Forward Cache (BFCache) is not supported.**
> By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `Playwright.Page.go_back/2` or `Playwright.Page.go_forward/2` to trigger a BFCache restore will result in timeouts and a desynchronized [`Page`](`Playwright.Page`) state.

*Since Playwright 1.8.*

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:wait_until` (`:load` | `:domcontentloaded` | `:networkidle` | `:commit`) - When to consider operation succeeded, defaults to `:load`. Events can be either:

  * `:domcontentloaded` - consider operation to be finished when the `DOMContentLoaded` event is fired.
  * `:load` - consider operation to be finished when the `load` event is fired.
  * `:networkidle` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
  * `:commit` - consider operation to be finished when network response is received and the document started loading.

# `go_forward!`

```elixir
@spec go_forward!(t(), go_forward_options()) :: nil | Playwright.Response.t()
```

Like `go_forward/2`, but returns the value and raises on error.

# `goto`

```elixir
@spec goto(t(), String.t(), goto_options()) ::
  {:ok, nil | Playwright.Response.t()} | {:error, Playwright.error()}
```

Returns the main resource response. In case of multiple redirects, the navigation returns the first
non-redirect response.

The method will fail if:

* there's an SSL error (e.g. in case of self-signed certificates).
* target URL is invalid.
* the `:timeout` is exceeded during navigation.
* the remote server does not respond or is unreachable.
* the main resource failed to load.

The method will not fail when any valid HTTP status code is returned by the remote server, including 404 "Not
Found" and 500 "Internal Server Error".  The status code for such responses can be retrieved by calling
`Playwright.Response.status/1`.

> #### Note {: .info}
>
> The method either fails or returns a main resource response. The only exceptions are navigation to
> `about:blank` or navigation to the same URL with a different hash, which would succeed and return `nil`.

> #### Note {: .info}
>
> Headless mode doesn't support navigation to a PDF document. See the
> [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).

*Since Playwright 1.8.*

## Arguments

* `url` - URL to navigate page to. The url should include scheme, e.g. `https://`.
  When a `:base_url` via the context options was provided and the passed URL is a path,
  it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.

## Options

* `:referer` (`t:String.t/0`) - Referer header value. If provided it will take preference over the referer header value set by
  `Playwright.Page.set_extra_http_headers/2`.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:wait_until` (`:load` | `:domcontentloaded` | `:networkidle` | `:commit`) - When to consider operation succeeded, defaults to `:load`. Events can be either:

  * `:domcontentloaded` - consider operation to be finished when the `DOMContentLoaded` event is fired.
  * `:load` - consider operation to be finished when the `load` event is fired.
  * `:networkidle` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
  * `:commit` - consider operation to be finished when network response is received and the document started loading.

# `goto!`

```elixir
@spec goto!(t(), String.t(), goto_options()) :: nil | Playwright.Response.t()
```

Like `goto/3`, but returns the value and raises on error.

# `hide_highlight`

```elixir
@spec hide_highlight(t()) :: :ok | {:error, Playwright.error()}
```

Hide all locator highlight overlays previously added by `Playwright.Locator.highlight/2` on this page.

*Since Playwright 1.60.*

# `hide_highlight!`

```elixir
@spec hide_highlight!(t()) :: :ok
```

Like `hide_highlight/1`, but returns the value and raises on error.

# `hover`

```elixir
@spec hover(t(), String.t(), hover_options()) :: :ok | {:error, Playwright.error()}
```

This method hovers over an element matching `selector` by performing the following steps:

1. Find an element matching `selector`. If there is none, wait until a matching element is attached to
   the DOM.
1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless `:force` option is
   set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `Playwright.Page.mouse/1` to hover over the center of the element, or the specified `:position`.

When all steps combined have not finished during the specified `:timeout`, this method fails with a
[`TimeoutError`](`Playwright.TimeoutError`). Passing zero timeout disables this.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.hover/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:force` (`t:boolean/0`) - Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:modifiers` (list of `:alt` | `:control` | `:control_or_meta` | `:meta` | `:shift`) - Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
  modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
  and Linux and to "Meta" on macOS.
* `:no_wait_after` (`t:boolean/0`) - *Since Playwright 1.28.* This option has no effect.
* `:position` (`t:map/0`) - A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
  element.
  * `:x`
  * `:y`
* `:scroll` (`:auto` | `:none`) - *Since Playwright 1.62.* Controls whether Playwright scrolls the element into view before performing the action. Defaults to `:auto`,
  which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to
  `:none`, Playwright does not scroll the element and the action fails if the element is not already in the viewport.
  This is useful to assert that an element is reachable by the user without additional scrolling.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:trial` (`t:boolean/0`) - *Since Playwright 1.11.* When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `:modifiers` will be pressed regardless of `:trial` to allow testing elements which are only visible when those keys are pressed.

# `hover!`

```elixir
@spec hover!(t(), String.t(), hover_options()) :: :ok
```

Like `hover/3`, but returns the value and raises on error.

# `inner_html`

```elixir
@spec inner_html(t(), String.t(), inner_html_options()) ::
  {:ok, String.t()} | {:error, Playwright.error()}
```

Returns `element.innerHTML`.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.inner_html/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `inner_html!`

```elixir
@spec inner_html!(t(), String.t(), inner_html_options()) :: String.t()
```

Like `inner_html/3`, but returns the value and raises on error.

# `inner_text`

```elixir
@spec inner_text(t(), String.t(), inner_text_options()) ::
  {:ok, String.t()} | {:error, Playwright.error()}
```

Returns `element.innerText`.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.inner_text/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `inner_text!`

```elixir
@spec inner_text!(t(), String.t(), inner_text_options()) :: String.t()
```

Like `inner_text/3`, but returns the value and raises on error.

# `input_value`

```elixir
@spec input_value(t(), String.t(), input_value_options()) ::
  {:ok, String.t()} | {:error, Playwright.error()}
```

Returns `input.value` for the selected `<input>` or `<textarea>` or `<select>` element.

Fails for non-input elements. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), returns the value of the control.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.input_value/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.13.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `input_value!`

```elixir
@spec input_value!(t(), String.t(), input_value_options()) :: String.t()
```

Like `input_value/3`, but returns the value and raises on error.

# `is_checked`

```elixir
@spec is_checked(t(), String.t(), is_checked_options()) ::
  {:ok, boolean()} | {:error, Playwright.error()}
```

Returns whether the element is checked. Fails if the element is not a checkbox or radio input.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.is_checked/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `is_checked!`

```elixir
@spec is_checked!(t(), String.t(), is_checked_options()) :: boolean()
```

Like `is_checked/3`, but returns the value and raises on error.

# `is_closed`

```elixir
@spec is_closed(t()) :: boolean()
```

Indicates that the page has been closed.

*Since Playwright 1.8.*

# `is_disabled`

```elixir
@spec is_disabled(t(), String.t(), is_disabled_options()) ::
  {:ok, boolean()} | {:error, Playwright.error()}
```

Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled).

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.is_disabled/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `is_disabled!`

```elixir
@spec is_disabled!(t(), String.t(), is_disabled_options()) :: boolean()
```

Like `is_disabled/3`, but returns the value and raises on error.

# `is_editable`

```elixir
@spec is_editable(t(), String.t(), is_editable_options()) ::
  {:ok, boolean()} | {:error, Playwright.error()}
```

Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable).

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.is_editable/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `is_editable!`

```elixir
@spec is_editable!(t(), String.t(), is_editable_options()) :: boolean()
```

Like `is_editable/3`, but returns the value and raises on error.

# `is_enabled`

```elixir
@spec is_enabled(t(), String.t(), is_enabled_options()) ::
  {:ok, boolean()} | {:error, Playwright.error()}
```

Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled).

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.is_enabled/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `is_enabled!`

```elixir
@spec is_enabled!(t(), String.t(), is_enabled_options()) :: boolean()
```

Like `is_enabled/3`, but returns the value and raises on error.

# `is_hidden`

```elixir
@spec is_hidden(t(), String.t(), is_hidden_options()) ::
  {:ok, boolean()} | {:error, Playwright.error()}
```

Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible).  `selector` that does not match any elements is considered hidden.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.is_hidden/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - This option is ignored. `Playwright.Page.is_hidden/3` does not wait for the
  element to become hidden and returns immediately.

# `is_hidden!`

```elixir
@spec is_hidden!(t(), String.t(), is_hidden_options()) :: boolean()
```

Like `is_hidden/3`, but returns the value and raises on error.

# `is_visible`

```elixir
@spec is_visible(t(), String.t(), is_visible_options()) ::
  {:ok, boolean()} | {:error, Playwright.error()}
```

Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not match any elements is considered not visible.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.is_visible/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - This option is ignored. `Playwright.Page.is_visible/3` does not wait
  for the element to become visible and returns immediately.

# `is_visible!`

```elixir
@spec is_visible!(t(), String.t(), is_visible_options()) :: boolean()
```

Like `is_visible/3`, but returns the value and raises on error.

# `keyboard`

```elixir
@spec keyboard(t()) :: Playwright.Keyboard.t()
```

*Since Playwright 1.8.*

# `local_storage`

```elixir
@spec local_storage(t()) :: Playwright.WebStorage.t()
```

Provides access to the page's `localStorage` for the current origin. See [`WebStorage`](`Playwright.WebStorage`).

```elixir
Page.local_storage(page) |> WebStorage.set_item!("token", "abc")
token = Page.local_storage(page) |> WebStorage.get_item!("token")
```

*Since Playwright 1.61.*

# `locator`

```elixir
@spec locator(t(), String.t(), locator_options()) :: Playwright.Locator.t()
```

The method returns an element locator that can be used to perform actions on this page / frame.
Locator is resolved to the element immediately before performing an action, so a series of actions on the same locator can in fact be performed on different DOM elements. That would happen if the DOM structure between those actions has changed.

[Learn more about locators](https://playwright.dev/docs/locators).

*Since Playwright 1.14.*

## Arguments

* `selector` - A selector to use when resolving DOM element.

## Options

* `:has` (`t:Playwright.Locator.t/0`) - Narrows down the results of the method to those which contain elements matching this relative locator.
  For example, `article` that has `text=Playwright` matches `<article><div>Playwright</div></article>`.

  Inner locator **must be relative** to the outer locator and is queried starting with the outer locator match, not the document root. For example, you can find `content` that has `div` in `<article><content><div>Playwright</div></content></article>`. However, looking for `content` that has `article div` will fail, because the inner locator must be relative and should not use any elements outside the `content`.

  Note that outer and inner locators must belong to the same frame. Inner locator must not contain [`FrameLocator`](`Playwright.FrameLocator`)s.
* `:has_not` (`t:Playwright.Locator.t/0`) - *Since Playwright 1.33.* Matches elements that do not contain an element that matches an inner locator. Inner locator is queried against the outer one.
  For example, `article` that does not have `div` matches `<article><span>Playwright</span></article>`.

  Note that outer and inner locators must belong to the same frame. Inner locator must not contain [`FrameLocator`](`Playwright.FrameLocator`)s.
* `:has_not_text` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0`) - *Since Playwright 1.33.* Matches elements that do not contain specified text somewhere inside, possibly in a child or a descendant element. When passed a `string`, matching is case-insensitive and searches for a substring.
* `:has_text` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0`) - Matches elements containing specified text somewhere inside, possibly in a child or a descendant element. When passed a `string`, matching is case-insensitive and searches for a substring.
  For example, `"Playwright"` matches `<article><div>Playwright</div></article>`.

# `main_frame`

```elixir
@spec main_frame(t()) :: Playwright.Frame.t()
```

The page's main frame. Page is guaranteed to have a main frame which persists during navigations.

*Since Playwright 1.8.*

# `mouse`

```elixir
@spec mouse(t()) :: Playwright.Mouse.t()
```

*Since Playwright 1.8.*

# `opener`

```elixir
@spec opener(t()) :: {:ok, nil | t()} | {:error, Playwright.error()}
```

Returns the opener for popup pages and `nil` for others. If the opener has been closed already the returns `nil`.

*Since Playwright 1.8.*

# `opener!`

```elixir
@spec opener!(t()) :: nil | t()
```

Like `opener/1`, but returns the value and raises on error.

# `page_errors`

```elixir
@spec page_errors(t(), page_errors_options()) ::
  {:ok, [Exception.t()]} | {:error, Playwright.error()}
```

Returns up to (currently) 200 last page errors from this page. See [`Page.on(:page_error)`](Playwright.Page.html#module-page_error) for more details.

*Since Playwright 1.56.*

## Options

* `:filter` (`:all` | `:since_navigation`) - *Since Playwright 1.59.* Controls which errors are returned:

# `page_errors!`

```elixir
@spec page_errors!(t(), page_errors_options()) :: [Exception.t()]
```

Like `page_errors/2`, but returns the value and raises on error.

# `pause`

```elixir
@spec pause(t()) :: :ok | {:error, Playwright.error()}
```

Pauses script execution. Playwright will stop executing the script and wait for the user to either press the 'Resume'
button in the page overlay or to call `playwright.resume()` in the DevTools console.

User can inspect selectors or perform manual steps while paused. Resume will continue running the original script from
the place it was paused.

> #### Note {: .info}
>
> This method requires Playwright to be started in a headed mode, with a falsy `headless` option.

*Since Playwright 1.9.*

# `pause!`

```elixir
@spec pause!(t()) :: :ok
```

Like `pause/1`, but returns the value and raises on error.

# `pdf`

```elixir
@spec pdf(t(), pdf_options()) :: {:ok, binary()} | {:error, Playwright.error()}
```

Returns the PDF buffer.

`Playwright.Page.pdf/2` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call
`Playwright.Page.emulate_media/2` before calling `Playwright.Page.pdf/2`:

> #### Note {: .info}
>
> By default, `Playwright.Page.pdf/2` generates a pdf with modified colors for printing. Use the
> [`-webkit-print-color-adjust`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to
> force rendering of exact colors.

**Usage**

```elixir
# Generates a PDF with "screen" media type.
Page.emulate_media!(page, media: :screen)
Page.pdf!(page, path: "page.pdf")
```

The `:width`, `:height`, and `:margin` options accept values labeled with units. Unlabeled
values are treated as pixels.

A few examples:

* `Page.pdf(page, width: 100)` - prints with width set to 100 pixels
* `Page.pdf(page, width: "100px")` - prints with width set to 100 pixels
* `Page.pdf(page, width: "10cm")` - prints with width set to 10 centimeters.

All possible units are:

* `px` - pixel
* `in` - inch
* `cm` - centimeter
* `mm` - millimeter

The `:format` options are:

* `Letter`: 8.5in x 11in
* `Legal`: 8.5in x 14in
* `Tabloid`: 11in x 17in
* `Ledger`: 17in x 11in
* `A0`: 33.1in x 46.8in
* `A1`: 23.4in x 33.1in
* `A2`: 16.54in x 23.4in
* `A3`: 11.7in x 16.54in
* `A4`: 8.27in x 11.7in
* `A5`: 5.83in x 8.27in
* `A6`: 4.13in x 5.83in

> #### Note {: .info}
>
> `:header_template` and `:footer_template` markup have the following limitations: > 1. Script tags inside
> templates are not evaluated. > 2. Page styles are not visible inside templates.

*Since Playwright 1.8.*

## Options

* `:display_header_footer` (`t:boolean/0`) - Display header and footer. Defaults to `false`.
* `:footer_template` (`t:String.t/0`) - HTML template for the print footer. Should use the same format as the `:header_template`.
* `:format` (`t:String.t/0`) - Paper format. If set, takes priority over `:width` or `:height` options. Defaults to 'Letter'.
* `:header_template` (`t:String.t/0`) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values
  into them:

  * `'date'` formatted print date
  * `'title'` document title
  * `'url'` document location
  * `'pageNumber'` current page number
  * `'totalPages'` total pages in the document
* `:height` (`t:String.t/0` | `t:number/0`) - Paper height, accepts values labeled with units.
* `:landscape` (`t:boolean/0`) - Paper orientation. Defaults to `false`.
* `:margin` (`t:map/0`) - Paper margins, defaults to none.
  * `:top` - Top margin, accepts values labeled with units. Defaults to `0`.
  * `:right` - Right margin, accepts values labeled with units. Defaults to `0`.
  * `:bottom` - Bottom margin, accepts values labeled with units. Defaults to `0`.
  * `:left` - Left margin, accepts values labeled with units. Defaults to `0`.
* `:outline` (`t:boolean/0`) - *Since Playwright 1.42.* Whether or not to embed the document outline into the PDF. Defaults to `false`.
* `:page_ranges` (`t:String.t/0`) - Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
* `:path` (`t:String.t/0`) - The file path to save the PDF to. If `:path` is a relative path, then it is resolved relative to the current
  working directory. If no path is provided, the PDF won't be saved to the disk.
* `:prefer_css_page_size` (`t:boolean/0`) - Give any CSS `@page` size declared in the page priority over what is declared in `:width` and
  `:height` or `:format` options. Defaults to `false`, which will scale the content to fit the paper
  size.
* `:print_background` (`t:boolean/0`) - Print background graphics. Defaults to `false`.
* `:scale` (`t:number/0`) - Scale of the webpage rendering. Defaults to `1`. Scale amount must be between 0.1 and 2.
* `:tagged` (`t:boolean/0`) - *Since Playwright 1.42.* Whether or not to generate tagged (accessible) PDF. Defaults to `false`.
* `:width` (`t:String.t/0` | `t:number/0`) - Paper width, accepts values labeled with units.

# `pdf!`

```elixir
@spec pdf!(t(), pdf_options()) :: binary()
```

Like `pdf/2`, but returns the value and raises on error.

# `pick_locator`

```elixir
@spec pick_locator(t()) ::
  {:ok, Playwright.Locator.t()} | {:error, Playwright.error()}
```

Enters pick locator mode where hovering over page elements highlights them and shows the corresponding locator.
Once the user clicks an element, the mode is deactivated and the [`Locator`](`Playwright.Locator`) for the picked element is returned.

**Usage**

```elixir
locator = Page.pick_locator!(page)
IO.puts(Locator.to_string(locator))
```

*Since Playwright 1.59.*

# `pick_locator!`

```elixir
@spec pick_locator!(t()) :: Playwright.Locator.t()
```

Like `pick_locator/1`, but returns the value and raises on error.

# `press`

```elixir
@spec press(t(), String.t(), String.t(), press_options()) ::
  :ok | {:error, Playwright.error()}
```

Focuses the element, and then uses `Playwright.Keyboard.down/2` and `Playwright.Keyboard.up/2`.

`key` can specify the intended
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
generate the text for. A superset of the `key` values can be found
[here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values). Examples of the keys are:

`F1` - `F12`, `Digit0`- `Digit9`, `KeyA`- `KeyZ`, `Backquote`, `Minus`, `Equal`, `Backslash`, `Backspace`, `Tab`,
`Delete`, `Escape`, `ArrowDown`, `End`, `Enter`, `Home`, `Insert`, `PageDown`, `PageUp`, `ArrowRight`, `ArrowUp`, etc.

Following modification shortcuts are also supported: `Shift`, `Control`, `Alt`, `Meta`, `ShiftLeft`, `ControlOrMeta`.
`ControlOrMeta` resolves to `Control` on Windows and Linux and to `Meta` on macOS.

Holding down `Shift` will type the text that corresponds to the `key` in the upper case.

If `key` is a single character, it is case-sensitive, so the values `a` and `A` will generate different
respective texts.

Shortcuts such as `key: "Control+o"`, `key: "Control++` or `key: "Control+Shift+T"` are supported as well. When specified with the
modifier, modifier is pressed and being held while the subsequent key is being pressed.

**Usage**

```elixir
page = Browser.new_page!(browser)
Page.goto!(page, "https://keycode.info")
Page.press!(page, "body", "A")
Page.screenshot!(page, path: "A.png")
Page.press!(page, "body", "ArrowLeft")
Page.screenshot!(page, path: "ArrowLeft.png")
Page.press!(page, "body", "Shift+O")
Page.screenshot!(page, path: "O.png")
Browser.close!(browser)
```

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.press/3` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* `key` - Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.

## Options

* `:delay` (`t:number/0`) - Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
* `:no_wait_after` (`t:boolean/0`) - Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
  opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating
  to inaccessible pages. Defaults to `false`.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `press!`

```elixir
@spec press!(t(), String.t(), String.t(), press_options()) :: :ok
```

Like `press/4`, but returns the value and raises on error.

# `query_selector`

```elixir
@spec query_selector(t(), String.t(), query_selector_options()) ::
  {:ok, nil | Playwright.ElementHandle.t()} | {:error, Playwright.error()}
```

The method finds an element matching the specified selector within the page. If no elements match the selector, the
return value is `nil`. To wait for an element on the page, use `Playwright.Locator.wait_for/2`.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Page.locator/3` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.9.*

## Arguments

* `selector` - A selector to query for.

## Options

* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.

# `query_selector!`

```elixir
@spec query_selector!(t(), String.t(), query_selector_options()) ::
  nil | Playwright.ElementHandle.t()
```

Like `query_selector/3`, but returns the value and raises on error.

# `query_selector_all`

```elixir
@spec query_selector_all(t(), String.t()) ::
  {:ok, [Playwright.ElementHandle.t()]} | {:error, Playwright.error()}
```

The method finds all elements matching the specified selector within the page. If no elements match the selector, the
return value is `[]`.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Page.locator/3` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.9.*

## Arguments

* `selector` - A selector to query for.

# `query_selector_all!`

```elixir
@spec query_selector_all!(t(), String.t()) :: [Playwright.ElementHandle.t()]
```

Like `query_selector_all/2`, but returns the value and raises on error.

# `reload`

```elixir
@spec reload(t(), reload_options()) ::
  {:ok, nil | Playwright.Response.t()} | {:error, Playwright.error()}
```

This method reloads the current page, in the same way as if the user had triggered a browser refresh.
Returns the main resource response. In case of multiple redirects, the navigation returns the response of the
last redirect.

*Since Playwright 1.8.*

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:wait_until` (`:load` | `:domcontentloaded` | `:networkidle` | `:commit`) - When to consider operation succeeded, defaults to `:load`. Events can be either:

  * `:domcontentloaded` - consider operation to be finished when the `DOMContentLoaded` event is fired.
  * `:load` - consider operation to be finished when the `load` event is fired.
  * `:networkidle` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
  * `:commit` - consider operation to be finished when network response is received and the document started loading.

# `reload!`

```elixir
@spec reload!(t(), reload_options()) :: nil | Playwright.Response.t()
```

Like `reload/2`, but returns the value and raises on error.

# `remove_all_listeners`

```elixir
@spec remove_all_listeners(
  t(),
  event() | String.t() | nil,
  remove_all_listeners_options()
) ::
  :ok | {:error, Playwright.error()}
```

Removes all the listeners of the given type (or all registered listeners if no type given).
Allows to wait for running listeners to complete or to ignore subsequent errors from these listeners.

**Usage**

```elixir
Page.on(page, :request, fn request ->
  response = Request.response!(request)
  body = Response.body!(response)
  IO.puts(byte_size(body))
end)

Page.goto!(page, "https://playwright.dev", wait_until: :domcontentloaded)
# Waits for all the reported :request events to resolve.
Page.remove_all_listeners!(page, :request, behavior: :wait)
```

*Since Playwright 1.47.*

## Options

The options may take the place of `event`, which is then `nil`.

* `:behavior` (`:wait` | `:ignore_errors` | `:default`) - Specifies whether to wait for already running listeners and what to do if they raise:

  * `:default` - do not wait for current listener calls (if any) to finish, if the listener raises, it may result in unhandled error
  * `:wait` - wait for current listener calls (if any) to finish
  * `:ignore_errors` - do not wait for current listener calls (if any) to finish, all errors raised by the listeners after removal are silently caught

# `remove_all_listeners!`

```elixir
@spec remove_all_listeners!(
  t(),
  event() | String.t() | nil,
  remove_all_listeners_options()
) :: :ok
```

Like `remove_all_listeners/3`, but returns the value and raises on error.

# `remove_locator_handler`

```elixir
@spec remove_locator_handler(t(), Playwright.Locator.t()) ::
  :ok | {:error, Playwright.error()}
```

Removes all locator handlers added by `Playwright.Page.add_locator_handler/4` for a specific locator.

*Since Playwright 1.44.*

## Arguments

* `locator` - Locator passed to `Playwright.Page.add_locator_handler/4`.

# `remove_locator_handler!`

```elixir
@spec remove_locator_handler!(t(), Playwright.Locator.t()) :: :ok
```

Like `remove_locator_handler/2`, but returns the value and raises on error.

# `request`

```elixir
@spec request(t()) :: Playwright.APIRequestContext.t()
```

API testing helper associated with this page. This method returns the same instance as
`Playwright.BrowserContext.request/1` on the page's context. See `Playwright.BrowserContext.request/1` for more details.

*Since Playwright 1.16.*

# `request_gc`

```elixir
@spec request_gc(t()) :: :ok | {:error, Playwright.error()}
```

Request the page to perform garbage collection. Note that there is no guarantee that all unreachable objects will be collected.

This is useful to help detect memory leaks. For example, if your page has a large object `'suspect'` that might be leaked, you can check that it does not leak by using a [`WeakRef`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef).

```elixir
# 1. In your page, save a WeakRef for the "suspect".
Page.evaluate!(page, "() => globalThis.suspectWeakRef = new WeakRef(suspect)")
# 2. Request garbage collection.
Page.request_gc!(page)
# 3. Check that weak ref does not deref to the original object.
assert Page.evaluate!(page, "() => !globalThis.suspectWeakRef.deref()") == true
```

*Since Playwright 1.48.*

# `request_gc!`

```elixir
@spec request_gc!(t()) :: :ok
```

Like `request_gc/1`, but returns the value and raises on error.

# `requests`

```elixir
@spec requests(t()) :: {:ok, [Playwright.Request.t()]} | {:error, Playwright.error()}
```

Returns up to (currently) 100 last network request from this page. See [`Page.on(:request)`](Playwright.Page.html#module-request) for more details.

Returned requests should be accessed immediately, otherwise they might be collected to prevent unbounded memory growth as new requests come in. Once collected, retrieving most information about the request is impossible.

Note that requests reported through the [`Page.on(:request)`](Playwright.Page.html#module-request) request are not collected, so there is a trade off between efficient memory usage with `Playwright.Page.requests/1` and the amount of available information reported through [`Page.on(:request)`](Playwright.Page.html#module-request).

*Since Playwright 1.56.*

# `requests!`

```elixir
@spec requests!(t()) :: [Playwright.Request.t()]
```

Like `requests/1`, but returns the value and raises on error.

# `route`

```elixir
@spec route(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
  (Playwright.Route.t() -&gt; term())
  | (Playwright.Route.t(), Playwright.Request.t() -&gt; term()),
  route_options()
) :: {:ok, Playwright.Disposable.t()} | {:error, Playwright.error()}
```

Routing provides the capability to modify network requests that are made by a page.

Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.

> #### Note {: .info}
>
> The handler will only be called for the first url if the response is a redirect.

> #### Note {: .info}
>
> `Playwright.Page.route/4` will not intercept requests intercepted by Service Worker. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting `:service_workers` to `:block`.

> #### Note {: .info}
>
> `Playwright.Page.route/4` will not intercept the first request of a popup page. Use `Playwright.BrowserContext.route/4` instead.

**Usage**

An example of a naive handler that aborts all image requests:

```elixir
page = Browser.new_page!(browser)
Page.route!(page, "**/*.{png,jpg,jpeg}", &Route.abort!/1)
Page.goto!(page, "https://example.com")
Browser.close!(browser)
```

or the same snippet using a regex pattern instead:

```elixir
page = Browser.new_page!(browser)
Page.route!(page, ~r/(\.png$)|(\.jpg$)/, &Route.abort!/1)
Page.goto!(page, "https://example.com")
Browser.close!(browser)
```

It is possible to examine the request to decide the route action. For example, mocking all requests that contain some post data, and leaving all other requests as is:

```elixir
Page.route!(page, "/api/**", fn route ->
  if Route.request(route) |> Request.post_data() |> String.contains?("my-string") do
    Route.fulfill!(route, body: "mocked-data")
  else
    Route.continue!(route)
  end
end)
```

If a request matches multiple registered routes, the most recently registered route takes precedence.

Page routes take precedence over browser context routes (set up with `Playwright.BrowserContext.route/4`) when request
matches both handlers.

To remove a route with its handler you can use `Playwright.Page.unroute/3`.

> #### Note {: .info}
>
> Enabling routing disables http cache.

*Since Playwright 1.8.*

## Arguments

* `url` - A glob pattern, regex pattern, URL pattern, or predicate that receives a `URI` to match during routing. If `:base_url` is set in the context options and the provided URL is a string that does not start with `*`, it is resolved using the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
* `handler` - handler function to route the request.

## Options

* `:times` (`t:integer/0`) - *Since Playwright 1.15.* How often a route should be used. By default it will be used every time.

# `route!`

```elixir
@spec route!(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
  (Playwright.Route.t() -&gt; term())
  | (Playwright.Route.t(), Playwright.Request.t() -&gt; term()),
  route_options()
) :: Playwright.Disposable.t()
```

Like `route/4`, but returns the value and raises on error.

# `route_from_har`

```elixir
@spec route_from_har(t(), String.t(), route_from_har_options()) ::
  :ok | {:error, Playwright.error()}
```

If specified the network requests that are made in the page will be served from the HAR file. Read more about [Replaying from HAR](https://playwright.dev/docs/mock#replaying-from-har).

Playwright will not serve requests intercepted by Service Worker from the HAR file. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting `:service_workers` to `:block`.

*Since Playwright 1.23.*

## Arguments

* `har` - Path to a [HAR](http://www.softwareishard.com/blog/har-12-spec) file with prerecorded network data. If `path` is a relative path, then it is resolved relative to the current working directory.

## Options

* `:not_found` (`:abort` | `:fallback`)

  * If set to 'abort' any request not found in the HAR file will be aborted.
  * If set to 'fallback' missing requests will be sent to the network.

  Defaults to abort.
* `:update` (`t:boolean/0`) - If specified, updates the given HAR with the actual network information instead of serving from file. The file is written to disk when `Playwright.BrowserContext.close/2` is called.
* `:update_content` (`:embed` | `:attach`) - *Since Playwright 1.32.* Optional setting to control resource content management. If `attach` is specified, resources are persisted as separate files or entries in the ZIP archive. If `embed` is specified, content is stored inline the HAR file.
* `:update_mode` (`:full` | `:minimal`) - *Since Playwright 1.32.* When set to `minimal`, only record information necessary for routing from HAR. This omits sizes, timing, page, cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to `:minimal`.
* `:url` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0`) - A glob pattern, regular expression or predicate to match the request URL. Only requests with URL matching the pattern will be served from the HAR file. If not specified, all requests are served from the HAR file.

# `route_from_har!`

```elixir
@spec route_from_har!(t(), String.t(), route_from_har_options()) :: :ok
```

Like `route_from_har/3`, but returns the value and raises on error.

# `route_web_socket`

```elixir
@spec route_web_socket(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
  (Playwright.WebSocketRoute.t() -&gt; term())
) :: :ok | {:error, Playwright.error()}
```

This method allows to modify websocket connections that are made by the page.

Note that only [`WebSocket`](`Playwright.WebSocket`)s created after this method was called will be routed. It is recommended to call this method before navigating the page.

**Usage**

Below is an example of a simple mock that responds to a single message. See [`WebSocketRoute`](`Playwright.WebSocketRoute`) for more details and examples.

```elixir
Page.route_web_socket!(page, "/ws", fn ws ->
  WebSocketRoute.on_message(ws, fn message ->
    if message == "request", do: WebSocketRoute.send(ws, "response")
  end)
end)
```

*Since Playwright 1.48.*

## Arguments

* `url` - Only WebSockets with the url matching this pattern will be routed. A string pattern can be relative to the `:base_url` context option.
* `handler` - Handler function to route the WebSocket.

# `route_web_socket!`

```elixir
@spec route_web_socket!(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
  (Playwright.WebSocketRoute.t() -&gt; term())
) :: :ok
```

Like `route_web_socket/3`, but returns the value and raises on error.

# `screencast`

```elixir
@spec screencast(t()) :: Playwright.Screencast.t()
```

[`Screencast`](`Playwright.Screencast`) object associated with this page.

**Usage**

```elixir
# Frames go to the `:on_frame` callback (Screencast has no events).
screencast = Page.screencast(page)

Screencast.start!(screencast,
  on_frame: fn %{data: data} -> IO.puts("received frame, jpeg size: #{byte_size(data)}") end
)

# ... perform actions ...
Screencast.stop!(screencast)
```

*Since Playwright 1.59.*

# `screenshot`

```elixir
@spec screenshot(t(), screenshot_options()) ::
  {:ok, binary()} | {:error, Playwright.error()}
```

Returns the buffer with the captured screenshot.

*Since Playwright 1.8.*

## Options

* `:animations` (`:disabled` | `:allow`) - When set to `:disabled`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:

  * finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
  * infinite animations are canceled to initial state, and then played over after the screenshot.

  Defaults to `:allow` that leaves animations untouched.
* `:caret` (`:hide` | `:initial`) - When set to `:hide`, screenshot will hide text caret. When set to `:initial`, text caret behavior will not be changed.  Defaults to `:hide`.
* `:clip` (`t:map/0`) - An object which specifies clipping of the resulting image.
  * `:x` - x-coordinate of top-left corner of clip area
  * `:y` - y-coordinate of top-left corner of clip area
  * `:width` - width of clipping area
  * `:height` - height of clipping area
* `:full_page` (`t:boolean/0`) - When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to
  `false`.
* `:mask` (list of `t:Playwright.Locator.t/0`) - Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with
  a pink box `#FF00FF` (customized by `:mask_color`) that completely covers its bounding box.
  The mask is also applied to invisible elements, see [Matching only visible elements](https://playwright.dev/docs/locators#matching-only-visible-elements) to disable that.
* `:mask_color` (`t:String.t/0`) - *Since Playwright 1.35.* Specify the color of the overlay box for masked elements, in [CSS color format](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). Default color is pink `#FF00FF`.
* `:omit_background` (`t:boolean/0`) - Hides default white background and allows capturing screenshots with transparency. Not applicable to `jpeg` images.
  Defaults to `false`.
* `:path` (`t:String.t/0`) - The file path to save the image to. The screenshot type will be inferred from file extension. If `:path` is a
  relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be
  saved to the disk.
* `:quality` (`t:integer/0`) - The quality of the image, between 0-100. Not applicable to `png` images. For `jpeg` the default is `80`.
  For `webp`, a quality of `100` (the default) produces a lossless image, while lower values use lossy compression.
* `:scale` (`:css` | `:device`) - When set to `:css`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using `:device` option will produce a single pixel per each device pixel, so screenshots of high-dpi devices will be twice as large or even larger.

  Defaults to `:device`.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:style` (`t:String.t/0`) - *Since Playwright 1.41.* Text of the stylesheet to apply while making the screenshot. This is where you can hide dynamic elements, make elements invisible
  or change their properties to help you creating repeatable screenshots. This stylesheet pierces the Shadow DOM and applies
  to the inner frames.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:type` (`:png` | `:jpeg` | `:webp`) - Specify screenshot type, defaults to `:png`.

# `screenshot!`

```elixir
@spec screenshot!(t(), screenshot_options()) :: binary()
```

Like `screenshot/2`, but returns the value and raises on error.

# `select_option`

```elixir
@spec select_option(
  t(),
  String.t(),
  :null
  | String.t()
  | Playwright.ElementHandle.t()
  | [String.t()]
  | %{
      optional(:value) =&gt; String.t(),
      optional(:label) =&gt; String.t(),
      optional(:index) =&gt; integer(),
      optional(:valueOrLabel) =&gt; String.t()
    }
  | [Playwright.ElementHandle.t()]
  | [
      %{
        optional(:value) =&gt; String.t(),
        optional(:label) =&gt; String.t(),
        optional(:index) =&gt; integer(),
        optional(:valueOrLabel) =&gt; String.t()
      }
    ],
  select_option_options()
) :: {:ok, [String.t()]} | {:error, Playwright.error()}
```

This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, waits until all specified options are present in the `<select>` element and selects these options.

If the target element is not a `<select>` element, this method fails. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.

Returns the array of option values that have been successfully selected.

Triggers a `change` and `input` event once all the provided options have been selected.

**Usage**

```elixir
# Single selection matching the value or label
Page.select_option!(page, "select#colors", "blue")

# single selection matching the label
Page.select_option!(page, "select#colors", %{label: "Blue"})

# multiple selection
Page.select_option!(page, "select#colors", ["red", "green", "blue"])
```

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.select_option/3` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* `values` - Options to select. If the `<select>` has the `multiple` attribute, all matching options are selected, otherwise only the
  first option matching one of the passed options is selected. String values are matching both values and labels. Option
  is considered matching if all specified properties match.
  * `:value` - Matches by `option.value`. Optional.
  * `:label` - Matches by `option.label`. Optional.
  * `:index` - Matches by the index. Optional.
  * `:valueOrLabel` - Matches by value or label, as a string does. Combines such a match with `index` in one list.

## Options

* `:force` (`t:boolean/0`) - *Since Playwright 1.13.* Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `select_option!`

```elixir
@spec select_option!(
  t(),
  String.t(),
  :null
  | String.t()
  | Playwright.ElementHandle.t()
  | [String.t()]
  | %{
      optional(:value) =&gt; String.t(),
      optional(:label) =&gt; String.t(),
      optional(:index) =&gt; integer(),
      optional(:valueOrLabel) =&gt; String.t()
    }
  | [Playwright.ElementHandle.t()]
  | [
      %{
        optional(:value) =&gt; String.t(),
        optional(:label) =&gt; String.t(),
        optional(:index) =&gt; integer(),
        optional(:valueOrLabel) =&gt; String.t()
      }
    ],
  select_option_options()
) :: [String.t()]
```

Like `select_option/4`, but returns the value and raises on error.

# `session_storage`

```elixir
@spec session_storage(t()) :: Playwright.WebStorage.t()
```

Provides access to the page's `sessionStorage` for the current origin. See [`WebStorage`](`Playwright.WebStorage`).

```elixir
Page.session_storage(page) |> WebStorage.set_item!("flag", "1")
flag = Page.session_storage(page) |> WebStorage.get_item!("flag")
```

*Since Playwright 1.61.*

# `set_checked`

```elixir
@spec set_checked(t(), String.t(), boolean(), set_checked_options()) ::
  :ok | {:error, Playwright.error()}
```

This method checks or unchecks an element matching `selector` by performing the following steps:

1. Find an element matching `selector`. If there is none, wait until a matching element is attached to
   the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method fails.
1. If the element already has the right checked state, this method returns immediately.
1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless `:force` option is
   set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `Playwright.Page.mouse/1` to click in the center of the element.
1. Ensure that the element is now checked or unchecked. If not, this method fails.

When all steps combined have not finished during the specified `:timeout`, this method fails with a
[`TimeoutError`](`Playwright.TimeoutError`). Passing zero timeout disables this.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.set_checked/3` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.15.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* `checked` - Whether to check or uncheck the checkbox.

## Options

* `:force` (`t:boolean/0`) - Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:position` (`t:map/0`) - A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
  element.
  * `:x`
  * `:y`
* `:scroll` (`:auto` | `:none`) - *Since Playwright 1.62.* Controls whether Playwright scrolls the element into view before performing the action. Defaults to `:auto`,
  which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to
  `:none`, Playwright does not scroll the element and the action fails if the element is not already in the viewport.
  This is useful to assert that an element is reachable by the user without additional scrolling.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:trial` (`t:boolean/0`) - When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it.

# `set_checked!`

```elixir
@spec set_checked!(t(), String.t(), boolean(), set_checked_options()) :: :ok
```

Like `set_checked/4`, but returns the value and raises on error.

# `set_content`

```elixir
@spec set_content(t(), String.t(), set_content_options()) ::
  :ok | {:error, Playwright.error()}
```

This method internally calls [document.write()](https://developer.mozilla.org/en-US/docs/Web/API/Document/write), inheriting all its specific characteristics and behaviors.

*Since Playwright 1.8.*

## Arguments

* `html` - HTML markup to assign to the page.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:wait_until` (`:load` | `:domcontentloaded` | `:networkidle` | `:commit`) - When to consider operation succeeded, defaults to `:load`. Events can be either:

  * `:domcontentloaded` - consider operation to be finished when the `DOMContentLoaded` event is fired.
  * `:load` - consider operation to be finished when the `load` event is fired.
  * `:networkidle` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
  * `:commit` - consider operation to be finished when network response is received and the document started loading.

# `set_content!`

```elixir
@spec set_content!(t(), String.t(), set_content_options()) :: :ok
```

Like `set_content/3`, but returns the value and raises on error.

# `set_default_navigation_timeout`

```elixir
@spec set_default_navigation_timeout(t(), number() | :infinity) :: :ok
```

This setting will change the default maximum navigation time for the following methods and related shortcuts:

* `Playwright.Page.go_back/2`
* `Playwright.Page.go_forward/2`
* `Playwright.Page.goto/3`
* `Playwright.Page.reload/2`
* `Playwright.Page.set_content/3`
* `Playwright.Page.wait_for_navigation/2`
* `Playwright.Page.wait_for_url/3`

> #### Note {: .info}
>
> `Playwright.Page.set_default_navigation_timeout/2` takes priority over `Playwright.Page.set_default_timeout/2`,
> `Playwright.BrowserContext.set_default_timeout/2` and `Playwright.BrowserContext.set_default_navigation_timeout/2`.

*Since Playwright 1.8.*

## Arguments

* `timeout` - Maximum navigation time in milliseconds

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `set_default_timeout`

```elixir
@spec set_default_timeout(t(), number() | :infinity) :: :ok
```

This setting will change the default maximum time for all the methods accepting `timeout` option.

> #### Note {: .info}
>
> `Playwright.Page.set_default_navigation_timeout/2` takes priority over `Playwright.Page.set_default_timeout/2`.

*Since Playwright 1.8.*

## Arguments

* `timeout` - Maximum time in milliseconds. Pass `0` to disable timeout.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `set_extra_http_headers`

```elixir
@spec set_extra_http_headers(t(), %{optional(String.t()) =&gt; String.t()}) ::
  :ok | {:error, Playwright.error()}
```

The extra HTTP headers will be sent with every request the page initiates.

> #### Note {: .info}
>
> `Playwright.Page.set_extra_http_headers/2` does not guarantee the order of headers in the outgoing requests.

*Since Playwright 1.8.*

## Arguments

* `headers` - An object containing additional HTTP headers to be sent with every request. All header values must be strings.

# `set_extra_http_headers!`

```elixir
@spec set_extra_http_headers!(t(), %{optional(String.t()) =&gt; String.t()}) :: :ok
```

Like `set_extra_http_headers/2`, but returns the value and raises on error.

# `set_input_files`

```elixir
@spec set_input_files(
  t(),
  String.t(),
  String.t()
  | [String.t()]
  | %{name: String.t(), mimeType: String.t(), buffer: binary()}
  | [%{name: String.t(), mimeType: String.t(), buffer: binary()}],
  set_input_files_options()
) :: :ok | {:error, Playwright.error()}
```

Sets the value of the file input to these file paths or files. If some of the `files` are relative paths, then they
are resolved relative to the current working directory. For empty array, clears the selected files.
For inputs with a `[webkitdirectory]` attribute, only a single directory path is supported.

This method expects `selector` to point to an
[input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), targets the control instead.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.set_input_files/3` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* `files`
  * `:name` - File name
  * `:mimeType` - File type
  * `:buffer` - File content

## Options

* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `set_input_files!`

```elixir
@spec set_input_files!(
  t(),
  String.t(),
  String.t()
  | [String.t()]
  | %{name: String.t(), mimeType: String.t(), buffer: binary()}
  | [%{name: String.t(), mimeType: String.t(), buffer: binary()}],
  set_input_files_options()
) :: :ok
```

Like `set_input_files/4`, but returns the value and raises on error.

# `set_viewport_size`

```elixir
@spec set_viewport_size(t(), %{width: integer(), height: integer()}) ::
  :ok | {:error, Playwright.error()}
```

In the case of multiple pages in a single browser, each page can have its own viewport size. However,
`Playwright.Browser.new_context/2` allows to set viewport size (and more) for all pages in the context at once.

`Playwright.Page.set_viewport_size/2` will resize the page. A lot of websites don't expect phones to change size, so you should set the
viewport size before navigating to the page. `Playwright.Page.set_viewport_size/2` will also reset `screen` size, use `Playwright.Browser.new_context/2` with `screen` and `viewport` parameters if you need better control of these properties.

**Usage**

```elixir
page = Browser.new_page!(browser)
Page.set_viewport_size!(page, %{width: 640, height: 480})
Page.goto!(page, "https://example.com")
```

*Since Playwright 1.8.*

## Arguments

* `viewport_size`
  * `:width` - page width in pixels.
  * `:height` - page height in pixels.

# `set_viewport_size!`

```elixir
@spec set_viewport_size!(t(), %{width: integer(), height: integer()}) :: :ok
```

Like `set_viewport_size/2`, but returns the value and raises on error.

# `tap`

```elixir
@spec tap(t(), String.t(), tap_options()) :: :ok | {:error, Playwright.error()}
```

This method taps an element matching `selector` by performing the following steps:

1. Find an element matching `selector`. If there is none, wait until a matching element is attached to
   the DOM.
1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless `:force` option is
   set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `Playwright.Page.touchscreen/1` to tap the center of the element, or the specified `:position`.

When all steps combined have not finished during the specified `:timeout`, this method fails with a
[`TimeoutError`](`Playwright.TimeoutError`). Passing zero timeout disables this.

> #### Note {: .info}
>
> `Playwright.Page.tap/3` will fail if the `:has_touch` option of the browser context is false.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.tap/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:force` (`t:boolean/0`) - Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:modifiers` (list of `:alt` | `:control` | `:control_or_meta` | `:meta` | `:shift`) - Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores current
  modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to "Control" on Windows
  and Linux and to "Meta" on macOS.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:position` (`t:map/0`) - A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
  element.
  * `:x`
  * `:y`
* `:scroll` (`:auto` | `:none`) - *Since Playwright 1.62.* Controls whether Playwright scrolls the element into view before performing the action. Defaults to `:auto`,
  which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to
  `:none`, Playwright does not scroll the element and the action fails if the element is not already in the viewport.
  This is useful to assert that an element is reachable by the user without additional scrolling.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:trial` (`t:boolean/0`) - *Since Playwright 1.11.* When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard `:modifiers` will be pressed regardless of `:trial` to allow testing elements which are only visible when those keys are pressed.

# `tap!`

```elixir
@spec tap!(t(), String.t(), tap_options()) :: :ok
```

Like `tap/3`, but returns the value and raises on error.

# `text_content`

```elixir
@spec text_content(t(), String.t(), text_content_options()) ::
  {:ok, nil | String.t()} | {:error, Playwright.error()}
```

Returns `element.textContent`.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.text_content/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `text_content!`

```elixir
@spec text_content!(t(), String.t(), text_content_options()) :: nil | String.t()
```

Like `text_content/3`, but returns the value and raises on error.

# `title`

```elixir
@spec title(t()) :: {:ok, String.t()} | {:error, Playwright.error()}
```

Returns the page's title.

*Since Playwright 1.8.*

# `title!`

```elixir
@spec title!(t()) :: String.t()
```

Like `title/1`, but returns the value and raises on error.

# `touchscreen`

```elixir
@spec touchscreen(t()) :: Playwright.Touchscreen.t()
```

*Since Playwright 1.8.*

# `type`

> This function is deprecated. In most cases, you should use Playwright.Locator.fill/3 instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use Playwright.Locator.press_sequentially/3.

```elixir
@spec type(t(), String.t(), String.t(), type_options()) ::
  :ok | {:error, Playwright.error()}
```

Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `Playwright.Page.type/4` can be used to send
fine-grained keyboard events. To fill values in form fields, use `Playwright.Page.fill/4`.

To press a special key, like `Control` or `ArrowDown`, use `Playwright.Keyboard.press/3`.

**Usage**

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* `text` - A text to type into a focused element.

## Options

* `:delay` (`t:number/0`) - Time to wait between key presses in milliseconds. Defaults to 0.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `type!`

> This function is deprecated. In most cases, you should use Playwright.Locator.fill/3 instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use Playwright.Locator.press_sequentially/3.

```elixir
@spec type!(t(), String.t(), String.t(), type_options()) :: :ok
```

Like `type/4`, but returns the value and raises on error.

# `uncheck`

```elixir
@spec uncheck(t(), String.t(), uncheck_options()) ::
  :ok | {:error, Playwright.error()}
```

This method unchecks an element matching `selector` by performing the following steps:

1. Find an element matching `selector`. If there is none, wait until a matching element is attached to
   the DOM.
1. Ensure that matched element is a checkbox or a radio input. If not, this method fails. If the element is already
   unchecked, this method returns immediately.
1. Wait for [actionability](https://playwright.dev/docs/actionability) checks on the matched element, unless `:force` option is
   set. If the element is detached during the checks, the whole action is retried.
1. Scroll the element into view if needed.
1. Use `Playwright.Page.mouse/1` to click in the center of the element.
1. Ensure that the element is now unchecked. If not, this method fails.

When all steps combined have not finished during the specified `:timeout`, this method fails with a
[`TimeoutError`](`Playwright.TimeoutError`). Passing zero timeout disables this.

> #### Discouraged {: .warning}
>
> Use locator-based `Playwright.Locator.uncheck/2` instead. Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.

## Options

* `:force` (`t:boolean/0`) - Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
* `:no_wait_after` (`t:boolean/0`) - This option has no effect.
* `:position` (`t:map/0`) - *Since Playwright 1.11.* A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
  element.
  * `:x`
  * `:y`
* `:scroll` (`:auto` | `:none`) - *Since Playwright 1.62.* Controls whether Playwright scrolls the element into view before performing the action. Defaults to `:auto`,
  which scrolls the element into view when necessary, including scrolling nested scrollable containers. When set to
  `:none`, Playwright does not scroll the element and the action fails if the element is not already in the viewport.
  This is useful to assert that an element is reachable by the user without additional scrolling.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:trial` (`t:boolean/0`) - *Since Playwright 1.11.* When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to `false`. Useful to wait until the element is ready for the action without performing it.

# `uncheck!`

```elixir
@spec uncheck!(t(), String.t(), uncheck_options()) :: :ok
```

Like `uncheck/3`, but returns the value and raises on error.

# `unroute`

```elixir
@spec unroute(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
  (Playwright.Route.t() -&gt; term())
  | (Playwright.Route.t(), Playwright.Request.t() -&gt; term())
  | nil
) :: :ok | {:error, Playwright.error()}
```

Removes a route created with `Playwright.Page.route/4`. When `handler` is not specified, removes all routes for
the `url`.

*Since Playwright 1.8.*

## Arguments

* `url` - A glob pattern, regex pattern, URL pattern, or predicate receiving `URI` to match while routing.
* `handler` - Optional handler function to route the request.

# `unroute!`

```elixir
@spec unroute!(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
  (Playwright.Route.t() -&gt; term())
  | (Playwright.Route.t(), Playwright.Request.t() -&gt; term())
  | nil
) :: :ok
```

Like `unroute/3`, but returns the value and raises on error.

# `unroute_all`

```elixir
@spec unroute_all(t(), unroute_all_options()) :: :ok | {:error, Playwright.error()}
```

Removes all routes created with `Playwright.Page.route/4` and `Playwright.Page.route_from_har/3`.

*Since Playwright 1.41.*

## Options

* `:behavior` (`:wait` | `:ignore_errors` | `:default`) - Specifies whether to wait for already running handlers and what to do if they raise:

  * `:default` - do not wait for current handler calls (if any) to finish, if unrouted handler raises, it may result in unhandled error
  * `:wait` - wait for current handler calls (if any) to finish
  * `:ignore_errors` - do not wait for current handler calls (if any) to finish, all errors raised by the handlers after unrouting are silently caught

# `unroute_all!`

```elixir
@spec unroute_all!(t(), unroute_all_options()) :: :ok
```

Like `unroute_all/2`, but returns the value and raises on error.

# `url`

```elixir
@spec url(t()) :: String.t()
```

*Since Playwright 1.8.*

# `video`

```elixir
@spec video(t()) :: nil | Playwright.Video.t()
```

Video object associated with this page. Can be used to access the video file when using the `:record_video` context option.

*Since Playwright 1.8.*

# `viewport_size`

```elixir
@spec viewport_size(t()) :: nil | %{width: integer(), height: integer()}
```

*Since Playwright 1.8.*

# `wait_for_event`

```elixir
@spec wait_for_event(t(), event() | String.t(), wait_for_event_options() | fun()) ::
  Playwright.Promise.t()
```

Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
value. Will fail if the page is closed before the event is fired. Returns the event data value.

**Usage**

```elixir
# Start waiting for download before clicking: a promise, awaited after.
download_promise = Page.wait_for_event(page, :download)
Page.get_by_text(page, "Download file") |> Locator.click!()
download = Promise.await!(download_promise)
```

*Since Playwright 1.8.*

## Arguments

* `event` - Event name, same one typically passed into `Playwright.Page.on/3`.

## Options

A function in place of the options is the `:predicate` option.

* `:predicate` (`t:fun/0`) - Receives the event data and returns a truthy value when the waiting should resolve.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
  The default value can be changed with `Playwright.Page.set_default_timeout/2` or `Playwright.BrowserContext.set_default_timeout/2`.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).

Returns a `Playwright.Promise` at once, with the wait already set up. Start it before the action that triggers it and await it after with `Playwright.Promise.await/1`:

```elixir
promise = Playwright.Page.wait_for_event(page, event)
Playwright.Locator.click!(button)
value = Playwright.Promise.await!(promise)
```

The callback form `expect_event/4` runs the action:

```elixir
value = Playwright.Page.expect_event!(page, event, fn -> Playwright.Locator.click!(button) end)
```

# `wait_for_event!`

```elixir
@spec wait_for_event!(t(), event() | String.t(), wait_for_event_options() | fun()) ::
  term()
```

Like `wait_for_event/3`, but awaits the promise: `Playwright.Promise.await!(wait_for_event(...))`, the value or a raise.

> #### Start waiting before the action {: .warning}
>
> This waits from the time it is called, so it misses what the code before it triggered. Start the wait with `wait_for_event/3` before the action and await it after, or use the callback form `expect_event!/4`:
>
> ```elixir
> promise = Playwright.Page.wait_for_event(page, event)
> Playwright.Locator.click!(button)
> value = Playwright.Promise.await!(promise)
> ```
>
> ```elixir
> value = Playwright.Page.expect_event!(page, event, fn -> Playwright.Locator.click!(button) end)
> ```

# `wait_for_function`

```elixir
@spec wait_for_function(t(), String.t(), term() | nil, wait_for_function_options()) ::
  {:ok, Playwright.JSHandle.t()} | {:error, Playwright.error()}
```

Returns when the `expression` returns a truthy value. It returns a JSHandle of the truthy value.

**Usage**

The `Playwright.Page.wait_for_function/4` can be used to observe viewport size change:

```elixir
# Or Playwright.chromium/1 or Playwright.firefox/1.
browser = Playwright.webkit(playwright) |> BrowserType.launch!()
page = Browser.new_page!(browser)
watch_dog = Task.async(fn -> Page.wait_for_function!(page, "() => window.innerWidth < 100") end)
Page.set_viewport_size!(page, %{width: 50, height: 50})
Task.await(watch_dog)
Browser.close!(browser)
```

To pass an argument to the predicate of `Playwright.Page.wait_for_function/4` function:

```elixir
selector = ".foo"
Page.wait_for_function!(page, "selector => !!document.querySelector(selector)", selector)
```

*Since Playwright 1.8.*

## Arguments

* `expression` - Function to be evaluated in the page context.
* `arg` - Optional argument to pass to `expression`.

## Options

* `:polling` (`t:number/0` | `:raf`) - If `:polling` is `:raf`, then `expression` is constantly executed in `requestAnimationFrame`
  callback. If `:polling` is a number, then it is treated as an interval in milliseconds at which the function
  would be executed. Defaults to `:raf`.
* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time to wait for in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
  value can be changed by using the `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `wait_for_function!`

```elixir
@spec wait_for_function!(t(), String.t(), term() | nil, wait_for_function_options()) ::
  Playwright.JSHandle.t()
```

Like `wait_for_function/4`, but returns the value and raises on error.

# `wait_for_load_state`

```elixir
@spec wait_for_load_state(
  t(),
  :load | :domcontentloaded | :networkidle | nil,
  wait_for_load_state_options()
) :: :ok | {:error, Playwright.error()}
```

Returns when the required load state has been reached.

This resolves when the page reaches a required load state, `load` by default. The navigation must have been committed
when this method is called. If current document has already reached the required state, resolves immediately.

> #### Note {: .info}
>
> Most of the time, this method is not needed because Playwright [auto-waits before every action](https://playwright.dev/docs/actionability).

**Usage**

```elixir
# Click triggers navigation.
Page.get_by_role(page, :button) |> Locator.click!()
# Returns after the "load" event.
Page.wait_for_load_state!(page)
```

```elixir
popup_promise = Page.wait_for_event(page, :popup)
# Click triggers a popup.
Page.get_by_role(page, :button) |> Locator.click!()
popup = Promise.await!(popup_promise)
# Wait for the "DOMContentLoaded" event.
Page.wait_for_load_state!(popup, :domcontentloaded)
# Popup is ready to use.
IO.puts(Page.title!(popup))
```

*Since Playwright 1.8.*

## Arguments

* `state` - Optional load state to wait for, defaults to `:load`. If the state has been already reached while loading current document, the
  method resolves immediately. Can be one of:

  * `:load` - wait for the `load` event to be fired.
  * `:domcontentloaded` - wait for the `DOMContentLoaded` event to be fired.
  * `:networkidle` - **DISCOURAGED** wait until there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.

## Options

The options may take the place of `state`, which is then `nil`.

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `wait_for_load_state!`

```elixir
@spec wait_for_load_state!(
  t(),
  :load | :domcontentloaded | :networkidle | nil,
  wait_for_load_state_options()
) :: :ok
```

Like `wait_for_load_state/3`, but returns the value and raises on error.

# `wait_for_navigation`

> This function is deprecated. This method is inherently racy, please use Playwright.Page.wait_for_url/3 instead.

```elixir
@spec wait_for_navigation(t(), wait_for_navigation_options()) ::
  Playwright.Promise.t()
```

Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the navigation
returns the response of the last redirect. In case of navigation to a different anchor or navigation due to
History API usage, the navigation returns `nil`.

**Usage**

This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly
cause the page to navigate. e.g. The click target has an `onclick` handler that triggers navigation from a `setTimeout`.
Consider this example:

```elixir
# Start waiting for navigation before clicking: a promise, awaited after.
navigation_promise = Page.wait_for_navigation(page)
Page.get_by_text(page, "Navigate after timeout") |> Locator.click!()
Promise.await!(navigation_promise)
```

> #### Note {: .info}
>
> Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered
> a navigation.

*Since Playwright 1.8.*

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:url` (`t:String.t/0` | `t:Regex.t/0` | `t:Playwright.RegExp.t/0` | `(URI.t() -> boolean())`) - A glob pattern, regex pattern, URL pattern, or predicate receiving `URI` to match while waiting for the navigation. Note that if
  the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
  equal to the string.
* `:wait_until` (`:load` | `:domcontentloaded` | `:networkidle` | `:commit`) - When to consider operation succeeded, defaults to `:load`. Events can be either:

  * `:domcontentloaded` - consider operation to be finished when the `DOMContentLoaded` event is fired.
  * `:load` - consider operation to be finished when the `load` event is fired.
  * `:networkidle` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
  * `:commit` - consider operation to be finished when network response is received and the document started loading.

Returns a `Playwright.Promise` at once, with the wait already set up. Start it before the action that triggers it and await it after with `Playwright.Promise.await/1`:

```elixir
promise = Playwright.Page.wait_for_navigation(page)
Playwright.Locator.click!(button)
response = Playwright.Promise.await!(promise)
```

The callback form `expect_navigation/3` runs the action:

```elixir
response = Playwright.Page.expect_navigation!(page, fn -> Playwright.Locator.click!(button) end)
```

# `wait_for_navigation!`

> This function is deprecated. This method is inherently racy, please use Playwright.Page.wait_for_url/3 instead.

```elixir
@spec wait_for_navigation!(t(), wait_for_navigation_options()) ::
  nil | Playwright.Response.t()
```

Like `wait_for_navigation/2`, but awaits the promise: `Playwright.Promise.await!(wait_for_navigation(...))`, the value or a raise.

> #### Start waiting before the action {: .warning}
>
> This waits from the time it is called, so it misses what the code before it triggered. Start the wait with `wait_for_navigation/2` before the action and await it after, or use the callback form `expect_navigation!/3`:
>
> ```elixir
> promise = Playwright.Page.wait_for_navigation(page)
> Playwright.Locator.click!(button)
> response = Playwright.Promise.await!(promise)
> ```
>
> ```elixir
> response = Playwright.Page.expect_navigation!(page, fn -> Playwright.Locator.click!(button) end)
> ```

# `wait_for_request`

```elixir
@spec wait_for_request(
  t(),
  String.t()
  | Regex.t()
  | Playwright.RegExp.t()
  | (Playwright.Request.t() -&gt; boolean()),
  wait_for_request_options()
) :: Playwright.Promise.t()
```

Waits for the matching request and returns it. See [waiting for event](https://playwright.dev/docs/events#waiting-for-event) for more details about events.

**Usage**

```elixir
# Start waiting for request before clicking: a promise, awaited after.
request_promise = Page.wait_for_request(page, "https://example.com/resource")
Page.get_by_text(page, "trigger request") |> Locator.click!()
first_request = Promise.await!(request_promise)

# Alternative way with a predicate.
request_promise =
  Page.wait_for_request(page, fn request ->
    Request.url(request) == "https://example.com/" and Request.method(request) == "GET"
  end)

Page.get_by_text(page, "trigger request") |> Locator.click!()
second_request = Promise.await!(request_promise)
```

*Since Playwright 1.8.*

## Arguments

* `url_or_predicate` - Request URL string, regex or predicate receiving [`Request`](`Playwright.Request`) object.
  When a `:base_url` via the context options was provided and the passed URL is a path,
  it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be
  changed by using the `Playwright.Page.set_default_timeout/2` method.

  In Elixir, `:infinity` is the same as `0`: no timeout.

Returns a `Playwright.Promise` at once, with the wait already set up. Start it before the action that triggers it and await it after with `Playwright.Promise.await/1`:

```elixir
promise = Playwright.Page.wait_for_request(page, url_or_predicate)
Playwright.Locator.click!(button)
request = Playwright.Promise.await!(promise)
```

The callback form `expect_request/4` runs the action:

```elixir
request = Playwright.Page.expect_request!(page, url_or_predicate, fn -> Playwright.Locator.click!(button) end)
```

# `wait_for_request!`

```elixir
@spec wait_for_request!(
  t(),
  String.t()
  | Regex.t()
  | Playwright.RegExp.t()
  | (Playwright.Request.t() -&gt; boolean()),
  wait_for_request_options()
) :: Playwright.Request.t()
```

Like `wait_for_request/3`, but awaits the promise: `Playwright.Promise.await!(wait_for_request(...))`, the value or a raise.

> #### Start waiting before the action {: .warning}
>
> This waits from the time it is called, so it misses what the code before it triggered. Start the wait with `wait_for_request/3` before the action and await it after, or use the callback form `expect_request!/4`:
>
> ```elixir
> promise = Playwright.Page.wait_for_request(page, url_or_predicate)
> Playwright.Locator.click!(button)
> request = Playwright.Promise.await!(promise)
> ```
>
> ```elixir
> request = Playwright.Page.expect_request!(page, url_or_predicate, fn -> Playwright.Locator.click!(button) end)
> ```

# `wait_for_response`

```elixir
@spec wait_for_response(
  t(),
  String.t()
  | Regex.t()
  | Playwright.RegExp.t()
  | (Playwright.Response.t() -&gt; boolean()),
  wait_for_response_options()
) :: Playwright.Promise.t()
```

Returns the matched response. See [waiting for event](https://playwright.dev/docs/events#waiting-for-event) for more details about events.

**Usage**

```elixir
# Start waiting for response before clicking: a promise, awaited after.
response_promise = Page.wait_for_response(page, "https://example.com/resource")
Page.get_by_text(page, "trigger response") |> Locator.click!()
first_response = Promise.await!(response_promise)

# Alternative way with a predicate.
response_promise =
  Page.wait_for_response(page, fn response ->
    Response.url(response) == "https://example.com/" and Response.status(response) == 200 and
      Request.method(Response.request(response)) == "GET"
  end)

Page.get_by_text(page, "trigger response") |> Locator.click!()
second_response = Promise.await!(response_promise)
```

*Since Playwright 1.8.*

## Arguments

* `url_or_predicate` - Request URL string, regex or predicate receiving [`Response`](`Playwright.Response`) object.
  When a `:base_url` via the context options was provided and the passed URL is a path,
  it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be
  changed by using the `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

Returns a `Playwright.Promise` at once, with the wait already set up. Start it before the action that triggers it and await it after with `Playwright.Promise.await/1`:

```elixir
promise = Playwright.Page.wait_for_response(page, url_or_predicate)
Playwright.Locator.click!(button)
response = Playwright.Promise.await!(promise)
```

The callback form `expect_response/4` runs the action:

```elixir
response = Playwright.Page.expect_response!(page, url_or_predicate, fn -> Playwright.Locator.click!(button) end)
```

# `wait_for_response!`

```elixir
@spec wait_for_response!(
  t(),
  String.t()
  | Regex.t()
  | Playwright.RegExp.t()
  | (Playwright.Response.t() -&gt; boolean()),
  wait_for_response_options()
) :: Playwright.Response.t()
```

Like `wait_for_response/3`, but awaits the promise: `Playwright.Promise.await!(wait_for_response(...))`, the value or a raise.

> #### Start waiting before the action {: .warning}
>
> This waits from the time it is called, so it misses what the code before it triggered. Start the wait with `wait_for_response/3` before the action and await it after, or use the callback form `expect_response!/4`:
>
> ```elixir
> promise = Playwright.Page.wait_for_response(page, url_or_predicate)
> Playwright.Locator.click!(button)
> response = Playwright.Promise.await!(promise)
> ```
>
> ```elixir
> response = Playwright.Page.expect_response!(page, url_or_predicate, fn -> Playwright.Locator.click!(button) end)
> ```

# `wait_for_selector`

```elixir
@spec wait_for_selector(t(), String.t(), wait_for_selector_options()) ::
  {:ok, nil | Playwright.ElementHandle.t()} | {:error, Playwright.error()}
```

Returns when element specified by selector satisfies `:state` option. Returns `nil` if waiting for `hidden` or
`detached`.

> #### Note {: .info}
>
> Playwright automatically waits for element to be ready before performing an action. Using
> [`Locator`](`Playwright.Locator`) objects and web-first assertions makes the code wait-for-selector-free.

Wait for the `selector` to satisfy `:state` option (either appear/disappear from dom, or become
visible/hidden). If at the moment of calling the method `selector` already satisfies the condition, the method
will return immediately. If the selector doesn't satisfy the condition for the `:timeout` milliseconds, the
function will fail.

**Usage**

This method works across navigations:

```elixir
# Or Playwright.firefox/1 or Playwright.webkit/1.
browser = Playwright.chromium(playwright) |> BrowserType.launch!()
page = Browser.new_page!(browser)

for current_url <- ["https://google.com", "https://bbc.com"] do
  Page.goto!(page, current_url)
  element = Page.wait_for_selector!(page, "img")
  IO.puts("Loaded image: " <> ElementHandle.get_attribute!(element, "src"))
end

Browser.close!(browser)
```

> #### Discouraged {: .warning}
>
> Use web assertions that assert visibility or a locator-based `Playwright.Locator.wait_for/2` instead.
> Read more about [locators](https://playwright.dev/docs/locators).

*Since Playwright 1.8.*

## Arguments

* `selector` - A selector to query for.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the operation using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the operation will be aborted and fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2` or `Playwright.Page.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:state` (`:attached` | `:detached` | `:visible` | `:hidden`) - Defaults to `:visible`. Can be either:

  * `:attached` - wait for element to be present in DOM.
  * `:detached` - wait for element to not be present in DOM.
  * `:visible` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without
    any content or with `display:none` has an empty bounding box and is not considered visible.
  * `:hidden` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`.
    This is opposite to the `:visible` option.
* `:strict` (`t:boolean/0`) - *Since Playwright 1.14.* When true, the call requires selector to resolve to a single element. If given selector resolves to more
  than one element, the call fails.
* `:timeout` (`t:number/0` | `:infinity`) - Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by
  using the `Playwright.BrowserContext.set_default_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.

# `wait_for_selector!`

```elixir
@spec wait_for_selector!(t(), String.t(), wait_for_selector_options()) ::
  nil | Playwright.ElementHandle.t()
```

Like `wait_for_selector/3`, but returns the value and raises on error.

# `wait_for_timeout`

```elixir
@spec wait_for_timeout(t(), number()) :: :ok | {:error, Playwright.error()}
```

Waits for the given `timeout` in milliseconds. It rejects `:infinity`.

Note that `Playwright.Page.wait_for_timeout/2` should only be used for debugging. Tests using the timer in production are going to be
flaky. Use signals such as network events, selectors becoming visible and others instead.

**Usage**

```elixir
# wait for 1 second
Page.wait_for_timeout!(page, 1000)
```

> #### Discouraged {: .warning}
>
> Never wait for timeout in production. Tests that wait for time are
> inherently flaky. Use [`Locator`](`Playwright.Locator`) actions and web assertions that wait automatically.

*Since Playwright 1.8.*

## Arguments

* `timeout` - A timeout to wait for

# `wait_for_timeout!`

```elixir
@spec wait_for_timeout!(t(), number()) :: :ok
```

Like `wait_for_timeout/2`, but returns the value and raises on error.

# `wait_for_url`

```elixir
@spec wait_for_url(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
  wait_for_url_options()
) :: :ok | {:error, Playwright.error()}
```

Waits for the main frame to navigate to the given URL.

**Usage**

```elixir
# Clicking the link will indirectly cause a navigation
Page.click!(page, "a.delayed-navigation")
Page.wait_for_url!(page, "**/target.html")
```

*Since Playwright 1.11.*

## Arguments

* `url` - A glob pattern, regex pattern, URL pattern, or predicate receiving `URI` to match while waiting for the navigation. Note that if
  the parameter is a string without wildcard characters, the method will wait for navigation to URL that is exactly
  equal to the string.

## Options

* `:signal` (`t:Playwright.AbortSignal.t/0`) - *Since Playwright 1.62.* Allows to cancel the waiting using an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the waiting will be aborted and the operation will fail.
  Note that providing a signal does not disable the default timeout, which can be changed using `Playwright.BrowserContext.set_default_timeout/2`; pass `timeout: 0` to disable the timeout entirely.

  In Elixir, a `Playwright.AbortSignal` (`Playwright.AbortController.signal/1`).
* `:timeout` (`t:number/0` | `:infinity`) - Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
  The default value can be changed by using the
  `Playwright.BrowserContext.set_default_navigation_timeout/2`,
  `Playwright.BrowserContext.set_default_timeout/2`,
  `Playwright.Page.set_default_navigation_timeout/2` or
  `Playwright.Page.set_default_timeout/2` methods.

  In Elixir, `:infinity` is the same as `0`: no timeout.
* `:wait_until` (`:load` | `:domcontentloaded` | `:networkidle` | `:commit`) - When to consider operation succeeded, defaults to `:load`. Events can be either:

  * `:domcontentloaded` - consider operation to be finished when the `DOMContentLoaded` event is fired.
  * `:load` - consider operation to be finished when the `load` event is fired.
  * `:networkidle` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead.
  * `:commit` - consider operation to be finished when network response is received and the document started loading.

# `wait_for_url!`

```elixir
@spec wait_for_url!(
  t(),
  String.t() | Regex.t() | Playwright.RegExp.t() | (URI.t() -&gt; boolean()),
  wait_for_url_options()
) :: :ok
```

Like `wait_for_url/3`, but returns the value and raises on error.

# `webmcp`

```elixir
@spec webmcp(t()) :: Playwright.WebMCP.t()
```

Tools that the main frame registers through the experimental [`WebMCP`](`Playwright.WebMCP`) browser API. Shortcut for `Playwright.Frame.webmcp/1` of `Playwright.Page.main_frame/1`, see [`WebMCP`](`Playwright.WebMCP`) for details.

**Usage**

```elixir
tools = Page.webmcp(page) |> WebMCP.tools!()
result = Page.webmcp(page) |> WebMCP.call_tool!("add", %{a: 2, b: 40})
```

*Since Playwright 1.64.*

# `workers`

```elixir
@spec workers(t()) :: [Playwright.Worker.t()]
```

This method returns all of the dedicated [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)
associated with the page.

> #### Note {: .info}
>
> This does not contain ServiceWorkers

*Since Playwright 1.8.*

# `add_listener`

```elixir
@spec add_listener(t(), :close, (t() -&gt; term())) :: t()
@spec add_listener(t(), :console, (Playwright.ConsoleMessage.t() -&gt; term())) :: t()
@spec add_listener(t(), :crash, (t() -&gt; term())) :: t()
@spec add_listener(t(), :dialog, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec add_listener(t(), :dialog_closed, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec add_listener(t(), :dom_content_loaded, (t() -&gt; term())) :: t()
@spec add_listener(t(), :download, (Playwright.Download.t() -&gt; term())) :: t()
@spec add_listener(t(), :file_chooser, (Playwright.FileChooser.t() -&gt; term())) :: t()
@spec add_listener(t(), :frame_attached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec add_listener(t(), :frame_detached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec add_listener(t(), :frame_navigated, (Playwright.Frame.t() -&gt; term())) :: t()
@spec add_listener(t(), :load, (t() -&gt; term())) :: t()
@spec add_listener(t(), :page_error, (Exception.t() -&gt; term())) :: t()
@spec add_listener(t(), :popup, (t() -&gt; term())) :: t()
@spec add_listener(t(), :request, (Playwright.Request.t() -&gt; term())) :: t()
@spec add_listener(t(), :request_failed, (Playwright.Request.t() -&gt; term())) :: t()
@spec add_listener(t(), :request_finished, (Playwright.Request.t() -&gt; term())) :: t()
@spec add_listener(t(), :response, (Playwright.Response.t() -&gt; term())) :: t()
@spec add_listener(t(), :web_socket, (Playwright.WebSocket.t() -&gt; term())) :: t()
@spec add_listener(t(), :worker, (Playwright.Worker.t() -&gt; term())) :: t()
@spec add_listener(t(), String.t(), (term() -&gt; term())) :: t()
```

Adds an event listener for `event`, see the module docs for the events.

# `off`

```elixir
@spec off(t(), :close, (t() -&gt; term())) :: t()
@spec off(t(), :console, (Playwright.ConsoleMessage.t() -&gt; term())) :: t()
@spec off(t(), :crash, (t() -&gt; term())) :: t()
@spec off(t(), :dialog, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec off(t(), :dialog_closed, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec off(t(), :dom_content_loaded, (t() -&gt; term())) :: t()
@spec off(t(), :download, (Playwright.Download.t() -&gt; term())) :: t()
@spec off(t(), :file_chooser, (Playwright.FileChooser.t() -&gt; term())) :: t()
@spec off(t(), :frame_attached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec off(t(), :frame_detached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec off(t(), :frame_navigated, (Playwright.Frame.t() -&gt; term())) :: t()
@spec off(t(), :load, (t() -&gt; term())) :: t()
@spec off(t(), :page_error, (Exception.t() -&gt; term())) :: t()
@spec off(t(), :popup, (t() -&gt; term())) :: t()
@spec off(t(), :request, (Playwright.Request.t() -&gt; term())) :: t()
@spec off(t(), :request_failed, (Playwright.Request.t() -&gt; term())) :: t()
@spec off(t(), :request_finished, (Playwright.Request.t() -&gt; term())) :: t()
@spec off(t(), :response, (Playwright.Response.t() -&gt; term())) :: t()
@spec off(t(), :web_socket, (Playwright.WebSocket.t() -&gt; term())) :: t()
@spec off(t(), :worker, (Playwright.Worker.t() -&gt; term())) :: t()
@spec off(t(), String.t(), (term() -&gt; term())) :: t()
```

Removes an event listener added by `on/3` or `add_listener/3`.

# `on`

```elixir
@spec on(t(), :close, (t() -&gt; term())) :: t()
@spec on(t(), :console, (Playwright.ConsoleMessage.t() -&gt; term())) :: t()
@spec on(t(), :crash, (t() -&gt; term())) :: t()
@spec on(t(), :dialog, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec on(t(), :dialog_closed, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec on(t(), :dom_content_loaded, (t() -&gt; term())) :: t()
@spec on(t(), :download, (Playwright.Download.t() -&gt; term())) :: t()
@spec on(t(), :file_chooser, (Playwright.FileChooser.t() -&gt; term())) :: t()
@spec on(t(), :frame_attached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec on(t(), :frame_detached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec on(t(), :frame_navigated, (Playwright.Frame.t() -&gt; term())) :: t()
@spec on(t(), :load, (t() -&gt; term())) :: t()
@spec on(t(), :page_error, (Exception.t() -&gt; term())) :: t()
@spec on(t(), :popup, (t() -&gt; term())) :: t()
@spec on(t(), :request, (Playwright.Request.t() -&gt; term())) :: t()
@spec on(t(), :request_failed, (Playwright.Request.t() -&gt; term())) :: t()
@spec on(t(), :request_finished, (Playwright.Request.t() -&gt; term())) :: t()
@spec on(t(), :response, (Playwright.Response.t() -&gt; term())) :: t()
@spec on(t(), :web_socket, (Playwright.WebSocket.t() -&gt; term())) :: t()
@spec on(t(), :worker, (Playwright.Worker.t() -&gt; term())) :: t()
@spec on(t(), String.t(), (term() -&gt; term())) :: t()
```

Adds an event listener for `event`, see the module docs for the events.

# `once`

```elixir
@spec once(t(), :close, (t() -&gt; term())) :: t()
@spec once(t(), :console, (Playwright.ConsoleMessage.t() -&gt; term())) :: t()
@spec once(t(), :crash, (t() -&gt; term())) :: t()
@spec once(t(), :dialog, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec once(t(), :dialog_closed, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec once(t(), :dom_content_loaded, (t() -&gt; term())) :: t()
@spec once(t(), :download, (Playwright.Download.t() -&gt; term())) :: t()
@spec once(t(), :file_chooser, (Playwright.FileChooser.t() -&gt; term())) :: t()
@spec once(t(), :frame_attached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec once(t(), :frame_detached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec once(t(), :frame_navigated, (Playwright.Frame.t() -&gt; term())) :: t()
@spec once(t(), :load, (t() -&gt; term())) :: t()
@spec once(t(), :page_error, (Exception.t() -&gt; term())) :: t()
@spec once(t(), :popup, (t() -&gt; term())) :: t()
@spec once(t(), :request, (Playwright.Request.t() -&gt; term())) :: t()
@spec once(t(), :request_failed, (Playwright.Request.t() -&gt; term())) :: t()
@spec once(t(), :request_finished, (Playwright.Request.t() -&gt; term())) :: t()
@spec once(t(), :response, (Playwright.Response.t() -&gt; term())) :: t()
@spec once(t(), :web_socket, (Playwright.WebSocket.t() -&gt; term())) :: t()
@spec once(t(), :worker, (Playwright.Worker.t() -&gt; term())) :: t()
@spec once(t(), String.t(), (term() -&gt; term())) :: t()
```

Adds an event listener that is removed after it is triggered once. See `on/3`.

# `prepend_listener`

```elixir
@spec prepend_listener(t(), :close, (t() -&gt; term())) :: t()
@spec prepend_listener(t(), :console, (Playwright.ConsoleMessage.t() -&gt; term())) ::
  t()
@spec prepend_listener(t(), :crash, (t() -&gt; term())) :: t()
@spec prepend_listener(t(), :dialog, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :dialog_closed, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :dom_content_loaded, (t() -&gt; term())) :: t()
@spec prepend_listener(t(), :download, (Playwright.Download.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :file_chooser, (Playwright.FileChooser.t() -&gt; term())) ::
  t()
@spec prepend_listener(t(), :frame_attached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :frame_detached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :frame_navigated, (Playwright.Frame.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :load, (t() -&gt; term())) :: t()
@spec prepend_listener(t(), :page_error, (Exception.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :popup, (t() -&gt; term())) :: t()
@spec prepend_listener(t(), :request, (Playwright.Request.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :request_failed, (Playwright.Request.t() -&gt; term())) ::
  t()
@spec prepend_listener(t(), :request_finished, (Playwright.Request.t() -&gt; term())) ::
  t()
@spec prepend_listener(t(), :response, (Playwright.Response.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :web_socket, (Playwright.WebSocket.t() -&gt; term())) :: t()
@spec prepend_listener(t(), :worker, (Playwright.Worker.t() -&gt; term())) :: t()
@spec prepend_listener(t(), String.t(), (term() -&gt; term())) :: t()
```

Adds an event listener for `event`, see the module docs for the events.

# `remove_listener`

```elixir
@spec remove_listener(t(), :close, (t() -&gt; term())) :: t()
@spec remove_listener(t(), :console, (Playwright.ConsoleMessage.t() -&gt; term())) :: t()
@spec remove_listener(t(), :crash, (t() -&gt; term())) :: t()
@spec remove_listener(t(), :dialog, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec remove_listener(t(), :dialog_closed, (Playwright.Dialog.t() -&gt; term())) :: t()
@spec remove_listener(t(), :dom_content_loaded, (t() -&gt; term())) :: t()
@spec remove_listener(t(), :download, (Playwright.Download.t() -&gt; term())) :: t()
@spec remove_listener(t(), :file_chooser, (Playwright.FileChooser.t() -&gt; term())) ::
  t()
@spec remove_listener(t(), :frame_attached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec remove_listener(t(), :frame_detached, (Playwright.Frame.t() -&gt; term())) :: t()
@spec remove_listener(t(), :frame_navigated, (Playwright.Frame.t() -&gt; term())) :: t()
@spec remove_listener(t(), :load, (t() -&gt; term())) :: t()
@spec remove_listener(t(), :page_error, (Exception.t() -&gt; term())) :: t()
@spec remove_listener(t(), :popup, (t() -&gt; term())) :: t()
@spec remove_listener(t(), :request, (Playwright.Request.t() -&gt; term())) :: t()
@spec remove_listener(t(), :request_failed, (Playwright.Request.t() -&gt; term())) :: t()
@spec remove_listener(t(), :request_finished, (Playwright.Request.t() -&gt; term())) ::
  t()
@spec remove_listener(t(), :response, (Playwright.Response.t() -&gt; term())) :: t()
@spec remove_listener(t(), :web_socket, (Playwright.WebSocket.t() -&gt; term())) :: t()
@spec remove_listener(t(), :worker, (Playwright.Worker.t() -&gt; term())) :: t()
@spec remove_listener(t(), String.t(), (term() -&gt; term())) :: t()
```

Removes an event listener added by `on/3` or `add_listener/3`.

---

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