diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.ts
index 9f06e8f3b4..045ad6d419 100644
--- a/tests/playwright-test/playwright.trace.spec.ts
+++ b/tests/playwright-test/playwright.trace.spec.ts
@@ -1271,3 +1271,49 @@ test('should record trace after fixture teardown timeout', {
// Check console events to make sure that library trace is recorded.
expect(trace.events).toContainEqual(expect.objectContaining({ type: 'console', text: 'from the page' }));
});
+
+test('should record trace snapshot for more obscure commands', async ({ runInlineTest }) => {
+ const result = await runInlineTest({
+ 'a.spec.ts': `
+ import { test, expect } from '@playwright/test';
+ test('test 1', async ({ browser }) => {
+ const page = await browser.newPage();
+ await page.setContent('
Content
');
+ expect(await page.locator('div').count()).toBe(1);
+ await page.locator('div').boundingBox();
+ });
+ `,
+ }, { trace: 'on' });
+
+ expect(result.exitCode).toBe(0);
+ expect(result.passed).toBe(1);
+
+ const tracePath = test.info().outputPath('test-results', 'a-test-1', 'trace.zip');
+ const trace = await parseTrace(tracePath);
+ expect(trace.actionTree).toEqual([
+ 'Before Hooks',
+ ' fixture: browser',
+ ' browserType.launch',
+ 'browser.newPage',
+ 'page.setContent',
+ 'locator.count',
+ 'expect.toBe',
+ 'locator.boundingBox',
+ 'After Hooks',
+ ]);
+
+ const snapshots = trace.traceModel.storage();
+ const snapshotFrameOrPageId = snapshots.snapshotsForTest()[0];
+
+ const countAction = trace.actions.find(a => a.apiName === 'locator.count');
+ expect(countAction.beforeSnapshot).toBeTruthy();
+ expect(countAction.afterSnapshot).toBeTruthy();
+ expect(snapshots.snapshotByName(snapshotFrameOrPageId, countAction.beforeSnapshot)).toBeTruthy();
+ expect(snapshots.snapshotByName(snapshotFrameOrPageId, countAction.afterSnapshot)).toBeTruthy();
+
+ const boundingBoxAction = trace.actions.find(a => a.apiName === 'locator.boundingBox');
+ expect(boundingBoxAction.beforeSnapshot).toBeTruthy();
+ expect(boundingBoxAction.afterSnapshot).toBeTruthy();
+ expect(snapshots.snapshotByName(snapshotFrameOrPageId, boundingBoxAction.beforeSnapshot)).toBeTruthy();
+ expect(snapshots.snapshotByName(snapshotFrameOrPageId, boundingBoxAction.afterSnapshot)).toBeTruthy();
+});