Interact with a Playwright Tracing.
There is no official documentation, since this is considered Playwright internal.
References:
Summary
Functions
Wraps a function call in a named trace group.
Starts tracing.
Starts a new chunk in the tracing.
Stops tracing.
Stops a chunk of tracing.
Types
@type group_opt() :: {:connection, GenServer.name()} | {:timeout, timeout()} | {:name, binary()} | {:location, keyword()}
@type start_chunk_opt() :: {:connection, GenServer.name()} | {:timeout, timeout()} | {:title, binary()}
@type stop_chunk_opt() :: {:connection, GenServer.name()} | {:timeout, timeout()} | {:mode, atom()}
@type stop_opt() :: {:connection, GenServer.name()} | {:timeout, timeout()}
Functions
@spec group( PlaywrightEx.guid(), [group_opt() | PlaywrightEx.unknown_opt()], (-> result) ) :: result when result: any()
Wraps a function call in a named trace group.
Reference: https://playwright.dev/docs/api/class-tracing#tracing-group
Automatically starts a trace group before executing the function and ends it after, ensuring proper cleanup even if the function raises an exception.
Options
:connection(term/0) - The Connection process name. Defaults toPlaywrightEx.Supervisor.Connection. The default value isPlaywrightEx.Supervisor.Connection.:timeout(timeout/0) - Required. Maximum time for the operation (milliseconds).:name(String.t/0) - Required. Name of the group to appear in trace viewer:location(non-emptykeyword/0) - Source location metadata for the trace group:file(String.t/0) - Required. File path for the source location:line(integer/0) - Required. Line number in the source file:column(integer/0) - Column number in the source file
Examples
Tracing.group(browser_context.tracing.guid, [name: "Login Flow"], fn ->
Page.fill(page_id, "#email", "user@example.com")
Page.fill(page_id, "#password", "secret")
Page.click(page_id, "button[type=submit]")
end)
# Custom location for trace viewer navigation
Tracing.group(browser_context.tracing.guid,
[name: "Login Flow", location: [file: "/absolute/path/to/test.exs", line: 42]],
fn ->
# assertion logic
end)
# Groups can be nested
Tracing.group(browser_context.tracing.guid, [name: "User Workflow"], fn ->
Tracing.group(browser_context.tracing.guid, [name: "Login"], fn ->
# login actions
end)
Tracing.group(browser_context.tracing.guid, [name: "Dashboard"], fn ->
# dashboard actions
end)
end)
@spec tracing_start(PlaywrightEx.guid(), [start_opt() | PlaywrightEx.unknown_opt()]) :: {:ok, any()} | {:error, any()}
Starts tracing.
Reference: https://playwright.dev/docs/api/class-tracing#tracing-start
Options
:connection(term/0) - The Connection process name. Defaults toPlaywrightEx.Supervisor.Connection. The default value isPlaywrightEx.Supervisor.Connection.:timeout(timeout/0) - Required. Maximum time for the operation (milliseconds).:title(String.t/0) - Trace name to be shown in the Trace Viewer.:screenshots(boolean/0) - Whether to capture screenshots during tracing:snapshots(boolean/0) - Captures DOM snapshots and records network activity:sources(boolean/0) - Whether to include source files for trace actions
@spec tracing_start_chunk(PlaywrightEx.guid(), [ start_chunk_opt() | PlaywrightEx.unknown_opt() ]) :: {:ok, any()} | {:error, any()}
Starts a new chunk in the tracing.
Reference: https://playwright.dev/docs/api/class-tracing#tracing-start-chunk
Options
:connection(term/0) - The Connection process name. Defaults toPlaywrightEx.Supervisor.Connection. The default value isPlaywrightEx.Supervisor.Connection.:timeout(timeout/0) - Required. Maximum time for the operation (milliseconds).:title(String.t/0) - Trace name to be shown in the Trace Viewer.
@spec tracing_stop(PlaywrightEx.guid(), [stop_opt() | PlaywrightEx.unknown_opt()]) :: {:ok, any()} | {:error, any()}
Stops tracing.
Reference: https://playwright.dev/docs/api/class-tracing#tracing-stop
Options
@spec tracing_stop_chunk(PlaywrightEx.guid(), [ stop_chunk_opt() | PlaywrightEx.unknown_opt() ]) :: {:ok, %{guid: PlaywrightEx.guid(), absolute_path: Path.t()}} | {:error, any()}
Stops a chunk of tracing.
Reference: https://playwright.dev/docs/api/class-tracing#tracing-stop-chunk
Options
:connection(term/0) - The Connection process name. Defaults toPlaywrightEx.Supervisor.Connection. The default value isPlaywrightEx.Supervisor.Connection.:timeout(timeout/0) - Required. Maximum time for the operation (milliseconds).:mode(atom/0) - Mode for stopping the chunk The default value is:archive.