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

API for controlling the Playwright debugger. The debugger allows pausing script execution and inspecting the page.
Obtain the debugger instance via `Playwright.BrowserContext.debugger/1`.

*Since Playwright 1.59.*

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

## Events

### `:paused_state_changed`

Emitted when the debugger pauses or resumes.

# `event`

```elixir
@type event() :: :paused_state_changed
```

An event name, see the module docs.

# `t`

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

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

# `next`

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

Resumes script execution and pauses again before the next action. Fails if the debugger is not paused.

*Since Playwright 1.59.*

# `next!`

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

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

# `paused_details`

```elixir
@spec paused_details(t()) ::
  nil
  | %{
      location: %{
        :file =&gt; String.t(),
        optional(:line) =&gt; integer(),
        optional(:column) =&gt; integer()
      },
      title: String.t()
    }
```

Returns details about the currently paused call. Returns `nil` if the debugger is not paused.

*Since Playwright 1.59.*

# `request_pause`

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

Configures the debugger to pause before the next action is executed.

Fails if the debugger is already paused. Use `Playwright.Debugger.next/1` or `Playwright.Debugger.run_to/2` to step while paused.

Note that `Playwright.Page.pause/1` is equivalent to a "debugger" statement — it pauses execution at the call site immediately. On the contrary, `Playwright.Debugger.request_pause/1` is equivalent to "pause on next statement" — it configures the debugger to pause before the next action is executed.

*Since Playwright 1.59.*

# `request_pause!`

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

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

# `resume`

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

Resumes script execution. Fails if the debugger is not paused.

*Since Playwright 1.59.*

# `resume!`

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

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

# `run_to`

```elixir
@spec run_to(t(), %{
  :file =&gt; String.t(),
  optional(:line) =&gt; integer(),
  optional(:column) =&gt; integer()
}) ::
  :ok | {:error, Playwright.error()}
```

Resumes script execution and pauses when an action originates from the given source location. Fails if the debugger is not paused.

*Since Playwright 1.59.*

## Arguments

* `location` - The source location to pause at.
  * `:file`
  * `:line`
  * `:column`

# `run_to!`

```elixir
@spec run_to!(t(), %{
  :file =&gt; String.t(),
  optional(:line) =&gt; integer(),
  optional(:column) =&gt; integer()
}) ::
  :ok
```

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

# `add_listener`

```elixir
@spec add_listener(t(), :paused_state_changed, (nil -&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(), :paused_state_changed, (nil -&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(), :paused_state_changed, (nil -&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(), :paused_state_changed, (nil -&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(), :paused_state_changed, (nil -&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(), :paused_state_changed, (nil -&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*
