Playwright.Debugger (Playwright v1.65.0-rc.3)

Copy Markdown View Source

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.

Summary

Types

An event name, see the module docs.

t()

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

Functions

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

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

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

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

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

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

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

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

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

Events

Adds an event listener for event, see the module docs for the events.

Removes an event listener added by on/3 or add_listener/3.

Adds an event listener for event, see the module docs for the events.

Adds an event listener that is removed after it is triggered once. See on/3.

Adds an event listener for event, see the module docs for the events.

Removes an event listener added by on/3 or add_listener/3.

Types

event()

@type event() :: :paused_state_changed

An event name, see the module docs.

t()

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

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

Functions

next(debugger)

@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!(debugger)

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

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

paused_details(debugger)

@spec paused_details(t()) ::
  nil
  | %{
      location: %{
        :file => String.t(),
        optional(:line) => integer(),
        optional(:column) => 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(debugger)

@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!(debugger)

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

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

resume(debugger)

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

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

Since Playwright 1.59.

resume!(debugger)

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

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

run_to(debugger, location)

@spec run_to(t(), %{
  :file => String.t(),
  optional(:line) => integer(),
  optional(:column) => 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!(debugger, location)

@spec run_to!(t(), %{
  :file => String.t(),
  optional(:line) => integer(),
  optional(:column) => integer()
}) ::
  :ok

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

Events

add_listener(debugger, event, listener)

@spec add_listener(t(), :paused_state_changed, (nil -> term())) :: t()
@spec add_listener(t(), String.t(), (term() -> term())) :: t()

Adds an event listener for event, see the module docs for the events.

off(debugger, event, listener)

@spec off(t(), :paused_state_changed, (nil -> term())) :: t()
@spec off(t(), String.t(), (term() -> term())) :: t()

Removes an event listener added by on/3 or add_listener/3.

on(debugger, event, listener)

@spec on(t(), :paused_state_changed, (nil -> term())) :: t()
@spec on(t(), String.t(), (term() -> term())) :: t()

Adds an event listener for event, see the module docs for the events.

once(debugger, event, listener)

@spec once(t(), :paused_state_changed, (nil -> term())) :: t()
@spec once(t(), String.t(), (term() -> term())) :: t()

Adds an event listener that is removed after it is triggered once. See on/3.

prepend_listener(debugger, event, listener)

@spec prepend_listener(t(), :paused_state_changed, (nil -> term())) :: t()
@spec prepend_listener(t(), String.t(), (term() -> term())) :: t()

Adds an event listener for event, see the module docs for the events.

remove_listener(debugger, event, listener)

@spec remove_listener(t(), :paused_state_changed, (nil -> term())) :: t()
@spec remove_listener(t(), String.t(), (term() -> term())) :: t()

Removes an event listener added by on/3 or add_listener/3.