Skip to content

Commit d0c3cff

Browse files
authored
chore: use _snapshotForAI in page snapshot (microsoft#36745)
1 parent fd01e7e commit d0c3cff

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/playwright/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import type { ClientInstrumentationListener } from '../../playwright-core/src/cl
3131
import type { Playwright as PlaywrightImpl } from '../../playwright-core/src/client/playwright';
3232
import type { Browser as BrowserImpl } from '../../playwright-core/src/client/browser';
3333
import type { BrowserContext as BrowserContextImpl } from '../../playwright-core/src/client/browserContext';
34+
import type { Page as PageImpl } from '../../playwright-core/src/client/page';
3435
import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core';
3536

3637
export { expect } from './matchers/expect';
@@ -664,10 +665,12 @@ class ArtifactsRecorder {
664665
if (this._pageSnapshot)
665666
return;
666667
const page = context.pages()[0];
668+
if (!page)
669+
return;
667670

668671
try {
669672
// TODO: maybe capture snapshot when the error is created, so it's from the right page and right time
670-
this._pageSnapshot = await page?.locator('body').ariaSnapshot({ timeout: 5000 });
673+
this._pageSnapshot = await (page as PageImpl)._snapshotForAI({ timeout: 5000 });
671674
} catch {}
672675
}
673676

0 commit comments

Comments
 (0)