Tracing.start Start tracing. **NOTE** You probably want to [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead of using `Tracing.start`. The `context.tracing` API captures browser operations and
(
self,
*,
name: typing.Optional[str] = None,
title: typing.Optional[str] = None,
snapshots: typing.Optional[bool] = None,
screenshots: typing.Optional[bool] = None,
sources: typing.Optional[bool] = None,
live: typing.Optional[bool] = None,
)
| 17160 | class Tracing(AsyncBase): |
| 17161 | |
| 17162 | async def start( |
| 17163 | self, |
| 17164 | *, |
| 17165 | name: typing.Optional[str] = None, |
| 17166 | title: typing.Optional[str] = None, |
| 17167 | snapshots: typing.Optional[bool] = None, |
| 17168 | screenshots: typing.Optional[bool] = None, |
| 17169 | sources: typing.Optional[bool] = None, |
| 17170 | live: typing.Optional[bool] = None, |
| 17171 | ) -> None: |
| 17172 | """Tracing.start |
| 17173 | |
| 17174 | Start tracing. |
| 17175 | |
| 17176 | **NOTE** You probably want to |
| 17177 | [enable tracing in your config file](https://playwright.dev/docs/api/class-testoptions#test-options-trace) instead |
| 17178 | of using `Tracing.start`. |
| 17179 | |
| 17180 | The `context.tracing` API captures browser operations and network activity, but it doesn't record test assertions |
| 17181 | (like `expect` calls). We recommend |
| 17182 | [enabling tracing through Playwright Test configuration](https://playwright.dev/docs/api/class-testoptions#test-options-trace), |
| 17183 | which includes those assertions and provides a more complete trace for debugging test failures. |
| 17184 | |
| 17185 | **Usage** |
| 17186 | |
| 17187 | ```py |
| 17188 | await context.tracing.start(screenshots=True, snapshots=True) |
| 17189 | page = await context.new_page() |
| 17190 | await page.goto(\"https://playwright.dev\") |
| 17191 | await context.tracing.stop(path = \"trace.zip\") |
| 17192 | ``` |
| 17193 | |
| 17194 | Parameters |
| 17195 | ---------- |
| 17196 | name : Union[str, None] |
| 17197 | If specified, intermediate trace files are going to be saved into the files with the given name prefix inside the |
| 17198 | `tracesDir` directory specified in `browser_type.launch()`. To specify the final trace zip file name, you |
| 17199 | need to pass `path` option to `tracing.stop()` instead. |
| 17200 | title : Union[str, None] |
| 17201 | Trace name to be shown in the Trace Viewer. |
| 17202 | snapshots : Union[bool, None] |
| 17203 | If this option is true tracing will |
| 17204 | - capture DOM snapshot on every action |
| 17205 | - record network activity |
| 17206 | screenshots : Union[bool, None] |
| 17207 | Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview. |
| 17208 | sources : Union[bool, None] |
| 17209 | Whether to include source files for trace actions. |
| 17210 | live : Union[bool, None] |
| 17211 | When enabled, the trace is written to an unarchived file that is updated in real time as actions occur, instead of |
| 17212 | caching changes and archiving them into a zip file at the end. This is useful for live trace viewing during test |
| 17213 | execution. |
| 17214 | """ |
| 17215 | |
| 17216 | return mapping.from_maybe_impl( |
| 17217 | await self._impl_obj.start( |
| 17218 | name=name, |
| 17219 | title=title, |