Skip to content

Commit 67e8def

Browse files
authored
docs: update tracing.group docs (#33487)
1 parent 43e4ba9 commit 67e8def

File tree

2 files changed

+30
-50
lines changed

2 files changed

+30
-50
lines changed

docs/src/api/class-tracing.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -284,54 +284,51 @@ To specify the final trace zip file name, you need to pass `path` option to
284284
## async method: Tracing.group
285285
* since: v1.49
286286

287-
Creates a new group within the trace, assigning any subsequent API calls to this group, until [`method: Tracing.groupEnd`] is called. Groups can be nested and will be visible in the trace viewer and test reports.
288-
289287
:::caution
290-
When using Playwright test runner, we strongly recommend `test.step` instead.
288+
Use `test.step` instead when available.
291289
:::
292290

291+
Creates a new group within the trace, assigning any subsequent API calls to this group, until [`method: Tracing.groupEnd`] is called. Groups can be nested and will be visible in the trace viewer.
292+
293293
**Usage**
294294

295295
```js
296-
await context.tracing.start({ screenshots: true, snapshots: true });
297-
await context.tracing.group('Open Playwright.dev');
298-
// All actions between group and groupEnd will be shown in the trace viewer as a group.
299-
const page = await context.newPage();
300-
await page.goto('https://playwright.dev/');
301-
await context.tracing.groupEnd();
302-
await context.tracing.group('Open API Docs of Tracing');
303-
await page.getByRole('link', { name: 'API' }).click();
304-
await page.getByRole('link', { name: 'Tracing' }).click();
305-
await context.tracing.groupEnd();
306-
// This Trace will have two groups: 'Open Playwright.dev' and 'Open API Docs of Tracing'.
296+
// use test.step instead
297+
await test.step('Log in', async () => {
298+
// ...
299+
});
307300
```
308301

309302
```java
310-
// All actions between group and groupEnd will be shown in the trace viewer as a group.
303+
// All actions between group and groupEnd
304+
// will be shown in the trace viewer as a group.
311305
page.context().tracing.group("Open Playwright.dev > API");
312306
page.navigate("https://playwright.dev/");
313307
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("API")).click();
314308
page.context().tracing.groupEnd();
315309
```
316310

317311
```python sync
318-
# All actions between group and groupEnd will be shown in the trace viewer as a group.
312+
# All actions between group and group_end
313+
# will be shown in the trace viewer as a group.
319314
page.context.tracing.group("Open Playwright.dev > API")
320315
page.goto("https://playwright.dev/")
321316
page.get_by_role("link", name="API").click()
322317
page.context.tracing.group_end()
323318
```
324319

325320
```python async
326-
# All actions between group and groupEnd will be shown in the trace viewer as a group.
321+
# All actions between group and group_end
322+
# will be shown in the trace viewer as a group.
327323
await page.context.tracing.group("Open Playwright.dev > API")
328324
await page.goto("https://playwright.dev/")
329325
await page.get_by_role("link", name="API").click()
330326
await page.context.tracing.group_end()
331327
```
332328

333329
```csharp
334-
// All actions between group and groupEnd will be shown in the trace viewer as a group.
330+
// All actions between GroupAsync and GroupEndAsync
331+
// will be shown in the trace viewer as a group.
335332
await Page.Context().Tracing.GroupAsync("Open Playwright.dev > API");
336333
await Page.GotoAsync("https://playwright.dev/");
337334
await Page.GetByRole(AriaRole.Link, new() { Name = "API" }).ClickAsync();
@@ -342,17 +339,16 @@ await Page.Context().Tracing.GroupEndAsync();
342339
* since: v1.49
343340
- `name` <[string]>
344341

345-
Group name shown in the actions tree in trace viewer.
342+
Group name shown in the trace viewer.
346343

347344
### option: Tracing.group.location
348345
* since: v1.49
349346
- `location` ?<[Object]>
350-
- `file` <[string]> Source file path to be shown in the trace viewer source tab.
351-
- `line` ?<[int]> Line number in the source file.
352-
- `column` ?<[int]> Column number in the source file.
347+
- `file` <[string]>
348+
- `line` ?<[int]>
349+
- `column` ?<[int]>
353350

354-
Specifies a custom location for the group start to be shown in source tab in trace viewer.
355-
By default, location of the [`method: Tracing.group`] call is shown.
351+
Specifies a custom location for the group to be shown in the trace viewer. Defaults to the location of the [`method: Tracing.group`] call.
356352

357353
## async method: Tracing.groupEnd
358354
* since: v1.49

packages/playwright-core/types/types.d.ts

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21056,50 +21056,34 @@ export interface Touchscreen {
2105621056
*/
2105721057
export interface Tracing {
2105821058
/**
21059+
* **NOTE** Use `test.step` instead when available.
21060+
*
2105921061
* Creates a new group within the trace, assigning any subsequent API calls to this group, until
2106021062
* [tracing.groupEnd()](https://playwright.dev/docs/api/class-tracing#tracing-group-end) is called. Groups can be
21061-
* nested and will be visible in the trace viewer and test reports.
21062-
*
21063-
* **NOTE** When using Playwright test runner, we strongly recommend `test.step` instead.
21063+
* nested and will be visible in the trace viewer.
2106421064
*
2106521065
* **Usage**
2106621066
*
2106721067
* ```js
21068-
* await context.tracing.start({ screenshots: true, snapshots: true });
21069-
* await context.tracing.group('Open Playwright.dev');
21070-
* // All actions between group and groupEnd will be shown in the trace viewer as a group.
21071-
* const page = await context.newPage();
21072-
* await page.goto('https://playwright.dev/');
21073-
* await context.tracing.groupEnd();
21074-
* await context.tracing.group('Open API Docs of Tracing');
21075-
* await page.getByRole('link', { name: 'API' }).click();
21076-
* await page.getByRole('link', { name: 'Tracing' }).click();
21077-
* await context.tracing.groupEnd();
21078-
* // This Trace will have two groups: 'Open Playwright.dev' and 'Open API Docs of Tracing'.
21068+
* // use test.step instead
21069+
* await test.step('Log in', async () => {
21070+
* // ...
21071+
* });
2107921072
* ```
2108021073
*
21081-
* @param name Group name shown in the actions tree in trace viewer.
21074+
* @param name Group name shown in the trace viewer.
2108221075
* @param options
2108321076
*/
2108421077
group(name: string, options?: {
2108521078
/**
21086-
* Specifies a custom location for the group start to be shown in source tab in trace viewer. By default, location of
21087-
* the [tracing.group(name[, options])](https://playwright.dev/docs/api/class-tracing#tracing-group) call is shown.
21079+
* Specifies a custom location for the group to be shown in the trace viewer. Defaults to the location of the
21080+
* [tracing.group(name[, options])](https://playwright.dev/docs/api/class-tracing#tracing-group) call.
2108821081
*/
2108921082
location?: {
21090-
/**
21091-
* Source file path to be shown in the trace viewer source tab.
21092-
*/
2109321083
file: string;
2109421084

21095-
/**
21096-
* Line number in the source file.
21097-
*/
2109821085
line?: number;
2109921086

21100-
/**
21101-
* Column number in the source file.
21102-
*/
2110321087
column?: number;
2110421088
};
2110521089
}): Promise<void>;

0 commit comments

Comments
 (0)