Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: remove incremental aria snapshots from the api (#39777)

Dmitry Gozman613acd49e7bb
diff --git a/docs/src/api/class-locator.md b/docs/src/api/class-locator.md
index da7139618d..f9f5d82521 100644
--- a/docs/src/api/class-locator.md
+++ b/docs/src/api/class-locator.md
@@ -206,9 +206,9 @@ Below is the HTML markup and the respective ARIA snapshot:
- link "About"
```
-### option: Locator.ariaSnapshot.format
+### option: Locator.ariaSnapshot.mode
* since: v1.59
-- `format` <[AriaSnapshotFormat]<"ai"|"default">>
+- `mode` <[AriaSnapshotMode]<"ai"|"default">>
When set to `"ai"`, returns a snapshot optimized for AI consumption with element references.
Defaults to `"default"`.
diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md
index d5194a48f9..82eded0f08 100644
--- a/docs/src/api/class-page.md
+++ b/docs/src/api/class-page.md
@@ -4217,9 +4217,9 @@ Page height in pixels.
Captures the aria snapshot of the page. Read more about [aria snapshots](../aria-snapshots.md).
-### option: Page.ariaSnapshot.format
+### option: Page.ariaSnapshot.mode
* since: v1.59
-- `format` <[AriaSnapshotFormat]<"ai"|"default">>
+- `mode` <[AriaSnapshotMode]<"ai"|"default">>
When set to `"ai"`, returns a snapshot optimized for AI consumption with element references. Defaults to `"default"`.
@@ -4229,21 +4229,6 @@ When set to `"ai"`, returns a snapshot optimized for AI consumption with element
### option: Page.ariaSnapshot.timeout = %%-input-timeout-js-%%
* since: v1.59
-### option: Page.ariaSnapshot.track
-* since: v1.59
-- `track` <[string]>
-
-When specified, enables incremental snapshots. Subsequent calls with the same track name will
-track changes between calls.
-
-### option: Page.ariaSnapshot.mode
-* since: v1.59
-- `mode` <[AriaSnapshotContent]<"incremental"|"full">>
-
-When set to `"incremental"` and [`option: Page.ariaSnapshot.track`] is specified, returns an
-incremental snapshot containing only changes since the last call with the same track name.
-Defaults to `"full"`.
-
### option: Page.ariaSnapshot.depth
* since: v1.59
- `depth` <[int]>
diff --git a/packages/injected/src/ariaSnapshot.ts b/packages/injected/src/ariaSnapshot.ts
index 4bb00a1705..142fd7517e 100644
--- a/packages/injected/src/ariaSnapshot.ts
+++ b/packages/injected/src/ariaSnapshot.ts
@@ -37,7 +37,7 @@ type AriaRef = {
let lastRef = 0;
export type AriaTreeOptions = {
- format: 'ai' | 'default' | 'codegen' | 'autoexpect';
+ mode: 'ai' | 'default' | 'codegen' | 'autoexpect';
refPrefix?: string;
doNotRenderActive?: boolean;
depth?: number;
@@ -54,7 +54,7 @@ type InternalOptions = {
};
function toInternalOptions(options: AriaTreeOptions): InternalOptions {
- if (options.format === 'ai') {
+ if (options.mode === 'ai') {
// For AI consumption.
return {
visibility: 'ariaOrVisible',
@@ -65,11 +65,11 @@ function toInternalOptions(options: AriaTreeOptions): InternalOptions {
renderCursorPointer: true,
};
}
- if (options.format === 'autoexpect') {
+ if (options.mode === 'autoexpect') {
// To auto-generate assertions on visible elements.
return { visibility: 'ariaAndVisible', refs: 'none' };
}
- if (options.format === 'codegen') {
+ if (options.mode === 'codegen') {
// To generate aria assertion with regex heurisitcs.
return { visibility: 'aria', refs: 'none', renderStringsAsRegex: true };
}
@@ -387,19 +387,19 @@ export type MatcherReceived = {
};
export function matchesExpectAriaTemplate(rootElement: Element, template: aria.AriaTemplateNode): { matches: aria.AriaNode[], received: MatcherReceived } {
- const snapshot = generateAriaTree(rootElement, { format: 'default' });
+ const snapshot = generateAriaTree(rootElement, { mode: 'default' });
const matches = matchesNodeDeep(snapshot.root, template, false, false);
return {
matches,
received: {
- raw: renderAriaTree(snapshot, { format: 'default' }),
- regex: renderAriaTree(snapshot, { format: 'codegen' }),
+ raw: renderAriaTree(snapshot, { mode: 'default' }),
+ regex: renderAriaTree(snapshot, { mode: 'codegen' }),
}
};
}
export function getAllElementsMatchingExpectAriaTemplate(rootElement: Element, template: aria.AriaTemplateNode): Element[] {
- const root = generateAriaTree(rootElement, { format: 'default' }).root;
+ const root = generateAriaTree(rootElement, { mode: 'default' }).root;
const matches = matchesNodeDeep(root, template, true, false);
return matches.map(n => ariaNodeElement(n));
}
diff --git a/packages/injected/src/consoleApi.ts b/packages/injected/src/consoleApi.ts
index 38967e3bda..8cd9b5beaa 100644
--- a/packages/injected/src/consoleApi.ts
+++ b/packages/injected/src/consoleApi.ts
@@ -93,7 +93,7 @@ export class ConsoleAPI {
selector: (element: Element) => this._selector(element),
generateLocator: (element: Element, language?: Language) => this._generateLocator(element, language),
ariaSnapshot: (element?: Element, options?: AriaTreeOptions) => {
- return this._injectedScript.ariaSnapshot(element || this._injectedScript.document.body, options || { format: 'default' });
+ return this._injectedScript.ariaSnapshot(element || this._injectedScript.document.body, options || { mode: 'default' });
},
resume: () => this._resume(),
...new Locator(this._injectedScript, ''),
diff --git a/packages/injected/src/injectedScript.ts b/packages/injected/src/injectedScript.ts
index 89dbad7bdc..416ef12ea6 100644
--- a/packages/injected/src/injectedScript.ts
+++ b/packages/injected/src/injectedScript.ts
@@ -323,8 +323,8 @@ export class InjectedScript {
}
ariaSnapshotForRecorder(): { ariaSnapshot: string, refs: Map<Element, string> } {
- const tree = generateAriaTree(this.document.body, { format: 'ai' });
- const ariaSnapshot = renderAriaTree(tree, { format: 'ai' });
+ const tree = generateAriaTree(this.document.body, { mode: 'ai' });
+ const ariaSnapshot = renderAriaTree(tree, { mode: 'ai' });
return { ariaSnapshot, refs: tree.refs };
}
diff --git a/packages/injected/src/recorder/recorder.ts b/packages/injected/src/recorder/recorder.ts
index 724cb2511e..7b4c98f59b 100644
--- a/packages/injected/src/recorder/recorder.ts
+++ b/packages/injected/src/recorder/recorder.ts
@@ -1064,7 +1064,7 @@ class TextAssertionTool implements RecorderTool {
name: 'assertSnapshot',
selector: this._hoverHighlight.selector,
signals: [],
- ariaSnapshot: this._recorder.injectedScript.ariaSnapshot(target, { format: 'codegen' }),
+ ariaSnapshot: this._recorder.injectedScript.ariaSnapshot(target, { mode: 'codegen' }),
};
} else {
const generated = this._recorder.injectedScript.generateSelector(target, { testIdAttributeName: this._recorder.state.testIdAttributeName, forTextExpect: true });
@@ -1698,7 +1698,7 @@ export class Recorder {
private _captureAutoExpectSnapshot() {
const documentElement = this.injectedScript.document.documentElement;
- return documentElement ? this.injectedScript.utils.generateAriaTree(documentElement, { format: 'autoexpect' }) : undefined;
+ return documentElement ? this.injectedScript.utils.generateAriaTree(documentElement, { mode: 'autoexpect' }) : undefined;
}
async performAction(action: actions.PerformOnRecordAction) {
@@ -1723,7 +1723,7 @@ export class Recorder {
}
elementPicked(selector: string, model: HighlightModel) {
- const ariaSnapshot = this.injectedScript.ariaSnapshot(model.elements[0], { format: 'default' });
+ const ariaSnapshot = this.injectedScript.ariaSnapshot(model.elements[0], { mode: 'default' });
void this._delegate.elementPicked?.({ selector, ariaSnapshot });
}
}
diff --git a/packages/playwright-client/types/types.d.ts b/packages/playwright-client/types/types.d.ts
index f9cc94cca2..887bcdb70e 100644
--- a/packages/playwright-client/types/types.d.ts
+++ b/packages/playwright-client/types/types.d.ts
@@ -2113,14 +2113,7 @@ export interface Page {
* When set to `"ai"`, returns a snapshot optimized for AI consumption with element references. Defaults to
* `"default"`.
*/
- format?: "ai"|"default";
-
- /**
- * When set to `"incremental"` and
- * [`track`](https://playwright.dev/docs/api/class-page#page-aria-snapshot-option-track) is specified, returns an
- * incremental snapshot containing only changes since the last call with the same track name. Defaults to `"full"`.
- */
- mode?: "incremental"|"full";
+ mode?: "ai"|"default";
/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
@@ -2129,12 +2122,6 @@ export interface Page {
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods.
*/
timeout?: number;
-
- /**
- * When specified, enables incremental snapshots. Subsequent calls with the same track name will track changes between
- * calls.
- */
- track?: string;
}): Promise<string>;
/**
@@ -12787,7 +12774,7 @@ export interface Locator {
* When set to `"ai"`, returns a snapshot optimized for AI consumption with element references. Defaults to
* `"default"`.
*/
- format?: "ai"|"default";
+ mode?: "ai"|"default";
/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
diff --git a/packages/playwright-core/src/client/locator.ts b/packages/playwright-core/src/client/locator.ts
index 29f2f66e09..83d2ec449c 100644
--- a/packages/playwright-core/src/client/locator.ts
+++ b/packages/playwright-core/src/client/locator.ts
@@ -312,8 +312,8 @@ export class Locator implements api.Locator {
return await this._withElement((h, timeout) => h.screenshot({ ...options, mask, timeout }), { title: 'Screenshot', timeout: options.timeout });
}
- async ariaSnapshot(options: TimeoutOptions & { format?: 'ai' | 'default', depth?: number } = {}): Promise<string> {
- const result = await this._frame._page!._channel.ariaSnapshot({ timeout: this._frame._timeout(options), format: options.format, selector: this._selector, depth: options.depth });
+ async ariaSnapshot(options: TimeoutOptions & { mode?: 'ai' | 'default', depth?: number } = {}): Promise<string> {
+ const result = await this._frame._page!._channel.ariaSnapshot({ timeout: this._frame._timeout(options), mode: options.mode, selector: this._selector, depth: options.depth });
return result.snapshot;
}
diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.ts
index ca36eb25ec..7c56fd27b6 100644
--- a/packages/playwright-core/src/client/page.ts
+++ b/packages/playwright-core/src/client/page.ts
@@ -851,8 +851,8 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
return result.pdf;
}
- async ariaSnapshot(options: TimeoutOptions & { format?: 'ai' | 'default', track?: string, mode?: 'full' | 'incremental', depth?: number } = {}): Promise<string> {
- const result = await this._channel.ariaSnapshot({ timeout: this._timeoutSettings.timeout(options), format: options.format, track: options.track, mode: options.mode, depth: options.depth });
+ async ariaSnapshot(options: TimeoutOptions & { mode?: 'ai' | 'default', depth?: number, _track?: string } = {}): Promise<string> {
+ const result = await this._channel.ariaSnapshot({ timeout: this._timeoutSettings.timeout(options), track: options._track, mode: options.mode, depth: options.depth });
return result.snapshot;
}
diff --git a/packages/playwright-core/src/protocol/validator.ts b/packages/playwright-core/src/protocol/validator.ts
index 479b1b2fd4..0303364ac2 100644
--- a/packages/playwright-core/src/protocol/validator.ts
+++ b/packages/playwright-core/src/protocol/validator.ts
@@ -1495,9 +1495,8 @@ scheme.PageRequestsResult = tObject({
requests: tArray(tChannel(['Request'])),
});
scheme.PageAriaSnapshotParams = tObject({
- format: tOptional(tEnum(['ai', 'default'])),
+ mode: tOptional(tEnum(['ai', 'default'])),
track: tOptional(tString),
- mode: tOptional(tEnum(['full', 'incremental'])),
selector: tOptional(tString),
depth: tOptional(tInt),
timeout: tFloat,
diff --git a/packages/playwright-core/src/server/page.ts b/packages/playwright-core/src/server/page.ts
index 0bcbb3e9b8..8e07c11104 100644
--- a/packages/playwright-core/src/server/page.ts
+++ b/packages/playwright-core/src/server/page.ts
@@ -886,7 +886,7 @@ export class Page extends SdkObject<PageEventMap> {
await Promise.all(this.frames().map(frame => frame.hideHighlight().catch(() => {})));
}
- async ariaSnapshot(progress: Progress, options: { format?: 'ai' | 'default', track?: string, mode?: 'full' | 'incremental', doNotRenderActive?: boolean, selector?: string, depth?: number } = {}): Promise<{ snapshot: string }> {
+ async ariaSnapshot(progress: Progress, options: { mode?: 'ai' | 'default', track?: string, doNotRenderActive?: boolean, selector?: string, depth?: number } = {}): Promise<{ snapshot: string }> {
if (options.selector && options.track)
throw new Error('Cannot specify both selector and track options');
@@ -903,7 +903,7 @@ export class Page extends SdkObject<PageEventMap> {
}
const result = await ariaSnapshotForFrame(progress, frame, { ...options, info });
- const snapshot = options.mode === 'incremental' && result.incremental !== undefined ? result.incremental.join('\n') : result.full.join('\n');
+ const snapshot = options.track && result.incremental ? result.incremental.join('\n') : result.full.join('\n');
return { snapshot };
}
@@ -1048,7 +1048,7 @@ export class InitScript extends DisposableObject {
}
}
-async function ariaSnapshotForFrame(progress: Progress, frame: frames.Frame, options: { format?: 'ai' | 'default', track?: string, doNotRenderActive?: boolean, info?: SelectorInfo, depth?: number } = {}): Promise<{ full: string[], incremental?: string[] }> {
+async function ariaSnapshotForFrame(progress: Progress, frame: frames.Frame, options: { mode?: 'ai' | 'default', track?: string, doNotRenderActive?: boolean, info?: SelectorInfo, depth?: number } = {}): Promise<{ full: string[], incremental?: string[] }> {
// Only await the topmost navigations, inner frames will be empty when racing.
const snapshot = await frame.retryWithProgressAndTimeouts(progress, [1000, 2000, 4000, 8000], async continuePolling => {
try {
@@ -1066,7 +1066,7 @@ async function ariaSnapshotForFrame(progress: Progress, frame: frames.Frame, opt
return true;
return injected.incrementalAriaSnapshot(node, options);
}, {
- format: options.format ?? 'default',
+ mode: options.mode ?? 'default',
refPrefix: frame.seq ? 'f' + frame.seq : '',
track: options.track,
doNotRenderActive: options.doNotRenderActive,
@@ -1119,7 +1119,7 @@ async function ariaSnapshotForFrame(progress: Progress, frame: frames.Frame, opt
return { full, incremental };
}
-async function ariaSnapshotFrameRef(progress: Progress, parentFrame: frames.Frame, frameRef: string, options: { format?: 'ai' | 'default', track?: string, doNotRenderActive?: boolean, mode?: 'full' | 'incremental' }): Promise<{ full: string[], incremental?: string[] }> {
+async function ariaSnapshotFrameRef(progress: Progress, parentFrame: frames.Frame, frameRef: string, options: { mode?: 'ai' | 'default', track?: string, doNotRenderActive?: boolean }): Promise<{ full: string[], incremental?: string[] }> {
const frameSelector = `aria-ref=${frameRef} >> internal:control=enter-frame`;
const frameBodySelector = `${frameSelector} >> body`;
const child = await progress.race(parentFrame.selectors.resolveFrameForSelector(frameBodySelector, { strict: true }));
diff --git a/packages/playwright-core/src/tools/backend/context.ts b/packages/playwright-core/src/tools/backend/context.ts
index e2bf838c0e..d86a74bbc0 100644
--- a/packages/playwright-core/src/tools/backend/context.ts
+++ b/packages/playwright-core/src/tools/backend/context.ts
@@ -48,7 +48,7 @@ export type ContextConfig = {
saveTrace?: boolean;
secrets?: Record<string, string>;
snapshot?: {
- mode?: 'incremental' | 'full' | 'none';
+ mode?: 'full' | 'none';
};
testIdAttribute?: string;
timeouts?: {
diff --git a/packages/playwright-core/src/tools/backend/response.ts b/packages/playwright-core/src/tools/backend/response.ts
index 27cd4a02be..8b681daeb5 100644
--- a/packages/playwright-core/src/tools/backend/response.ts
+++ b/packages/playwright-core/src/tools/backend/response.ts
@@ -45,7 +45,7 @@ export class Response {
private _errors: string[] = [];
private _code: string[] = [];
private _context: Context;
- private _includeSnapshot: 'none' | 'full' | 'incremental' | 'explicit' = 'none';
+ private _includeSnapshot: 'none' | 'full' | 'explicit' = 'none';
private _includeSnapshotFileName: string | undefined;
private _includeSnapshotSelector: string | undefined;
private _includeSnapshotDepth: number | undefined;
@@ -129,7 +129,7 @@ export class Response {
}
setIncludeSnapshot() {
- this._includeSnapshot = this._context.config.snapshot?.mode || 'incremental';
+ this._includeSnapshot = this._context.config.snapshot?.mode ?? 'full';
}
setIncludeFullSnapshot(includeSnapshotFileName?: string, selector?: string, depth?: number) {
@@ -202,7 +202,7 @@ export class Response {
addSection('Ran Playwright code', this._code, 'js');
// Render tab titles upon changes or when more than one tab.
- const tabSnapshot = this._context.currentTab() ? await this._context.currentTabOrDie().captureSnapshot(this._includeSnapshotSelector, this._includeSnapshotDepth, this._clientWorkspace, this._includeSnapshot === 'incremental' ? 'incremental' : 'full') : undefined;
+ const tabSnapshot = this._context.currentTab() ? await this._context.currentTabOrDie().captureSnapshot(this._includeSnapshotSelector, this._includeSnapshotDepth, this._clientWorkspace) : undefined;
const tabHeaders = await Promise.all(this._context.tabs().map(tab => tab.headerSnapshot()));
if (this._includeSnapshot !== 'none' || tabHeaders.some(header => header.changed)) {
if (tabHeaders.length !== 1)
diff --git a/packages/playwright-core/src/tools/backend/tab.ts b/packages/playwright-core/src/tools/backend/tab.ts
index 6ee668cc39..2d4966e1cd 100644
--- a/packages/playwright-core/src/tools/backend/tab.ts
+++ b/packages/playwright-core/src/tools/backend/tab.ts
@@ -98,7 +98,6 @@ export class Tab extends EventEmitter<TabEventsInterface> {
private _onPageClose: (tab: Tab) => void;
private _modalStates: ModalState[] = [];
private _initializedPromise: Promise<void>;
- private _needsFullSnapshot = false;
private _recentEventEntries: EventEntry[] = [];
private _consoleLog: LogFile;
private _disposables: Disposable[];
@@ -373,13 +372,13 @@ export class Tab extends EventEmitter<TabEventsInterface> {
this._requests.length = 0;
}
- async captureSnapshot(selector: string | undefined, depth: number | undefined, relativeTo: string | undefined, mode: 'full' | 'incremental'): Promise<TabSnapshot> {
+ async captureSnapshot(selector: string | undefined, depth: number | undefined, relativeTo: string | undefined): Promise<TabSnapshot> {
await this._initializedPromise;
let tabSnapshot: TabSnapshot | undefined;
const modalStates = await this._raceAgainstModalStates(async () => {
const ariaSnapshot = selector
- ? await this.page.locator(selector).ariaSnapshot({ format: 'ai', depth })
- : await this.page.ariaSnapshot({ format: 'ai', track: 'response', mode: this._needsFullSnapshot ? 'full' : mode, depth });
+ ? await this.page.locator(selector).ariaSnapshot({ mode: 'ai', depth })
+ : await this.page.ariaSnapshot({ mode: 'ai', depth });
tabSnapshot = {
ariaSnapshot,
modalStates: [],
@@ -392,9 +391,6 @@ export class Tab extends EventEmitter<TabEventsInterface> {
this._recentEventEntries = [];
}
- // If we failed to capture a snapshot this time, make sure we do a full one next time,
- // to avoid reporting deltas against un-reported snapshot.
- this._needsFullSnapshot = !tabSnapshot;
return tabSnapshot ?? {
ariaSnapshot: '',
modalStates,
diff --git a/packages/playwright-core/src/tools/cli-client/skill/SKILL.md b/packages/playwright-core/src/tools/cli-client/skill/SKILL.md
index 77a0c0eae0..121aa9a74e 100644
--- a/packages/playwright-core/src/tools/cli-client/skill/SKILL.md
+++ b/packages/playwright-core/src/tools/cli-client/skill/SKILL.md
@@ -207,8 +207,9 @@ playwright-cli snapshot --filename=after-click.yaml
# snapshot an element instead of the whole page
playwright-cli snapshot "#main"
-# limit snapshot depth for efficiency
+# limit snapshot depth for efficiency, take a partial snapshot afterwards
playwright-cli snapshot --depth=4
+playwright-cli snapshot e34
```
## Targeting elements
diff --git a/packages/playwright-core/src/tools/mcp/config.d.ts b/packages/playwright-core/src/tools/mcp/config.d.ts
index 4bc76ea30c..26cc07518d 100644
--- a/packages/playwright-core/src/tools/mcp/config.d.ts
+++ b/packages/playwright-core/src/tools/mcp/config.d.ts
@@ -212,7 +212,7 @@ export type Config = {
/**
* When taking snapshots for responses, specifies the mode to use.
*/
- mode?: 'incremental' | 'full' | 'none';
+ mode?: 'full' | 'none';
};
/**
diff --git a/packages/playwright-core/src/tools/mcp/config.ts b/packages/playwright-core/src/tools/mcp/config.ts
index 340c6a59da..0b60178b24 100644
--- a/packages/playwright-core/src/tools/mcp/config.ts
+++ b/packages/playwright-core/src/tools/mcp/config.ts
@@ -64,7 +64,7 @@ export type CLIOptions = {
saveSession?: boolean;
secrets?: Record<string, string>;
sharedBrowserContext?: boolean;
- snapshotMode?: 'incremental' | 'full' | 'none';
+ snapshotMode?: 'full' | 'none';
storageState?: string;
testIdAttribute?: string;
timeoutAction?: number;
diff --git a/packages/playwright-core/src/tools/mcp/program.ts b/packages/playwright-core/src/tools/mcp/program.ts
index 794bb8f2cc..e31e41cdfd 100644
--- a/packages/playwright-core/src/tools/mcp/program.ts
+++ b/packages/playwright-core/src/tools/mcp/program.ts
@@ -66,7 +66,7 @@ export function decorateMCPCommand(command: Command) {
.option('--save-session', 'Whether to save the Playwright MCP session into the output directory.')
.option('--secrets <path>', 'path to a file containing secrets in the dotenv format', dotenvFileLoader)
.option('--shared-browser-context', 'reuse the same browser context between all connected HTTP clients.')
- .option('--snapshot-mode <mode>', 'when taking snapshots for responses, specifies the mode to use. Can be "incremental", "full", or "none". Default is incremental.')
+ .option('--snapshot-mode <mode>', 'when taking snapshots for responses, specifies the mode to use. Can be "full" or "none". Default is "full".')
.option('--storage-state <path>', 'path to the storage state file for isolated sessions.')
.option('--test-id-attribute <attribute>', 'specify the attribute to use for test ids, defaults to "data-testid"')
.option('--timeout-action <timeout>', 'specify action timeout in milliseconds, defaults to 5000ms', numberParser)
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index f9cc94cca2..887bcdb70e 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -2113,14 +2113,7 @@ export interface Page {
* When set to `"ai"`, returns a snapshot optimized for AI consumption with element references. Defaults to
* `"default"`.
*/
- format?: "ai"|"default";
-
- /**
- * When set to `"incremental"` and
- * [`track`](https://playwright.dev/docs/api/class-page#page-aria-snapshot-option-track) is specified, returns an
- * incremental snapshot containing only changes since the last call with the same track name. Defaults to `"full"`.
- */
- mode?: "incremental"|"full";
+ mode?: "ai"|"default";
/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
@@ -2129,12 +2122,6 @@ export interface Page {
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods.
*/
timeout?: number;
-
- /**
- * When specified, enables incremental snapshots. Subsequent calls with the same track name will track changes between
- * calls.
- */
- track?: string;
}): Promise<string>;
/**
@@ -12787,7 +12774,7 @@ export interface Locator {
* When set to `"ai"`, returns a snapshot optimized for AI consumption with element references. Defaults to
* `"default"`.
*/
- format?: "ai"|"default";
+ mode?: "ai"|"default";
/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts
index 62b815dce7..2b627388bb 100644
--- a/packages/playwright/src/index.ts
+++ b/packages/playwright/src/index.ts
@@ -709,7 +709,7 @@ class ArtifactsRecorder {
try {
// TODO: maybe capture snapshot when the error is created, so it's from the right page and right time
await page._wrapApiCall(async () => {
- this._pageSnapshot = await page.ariaSnapshot({ format: 'ai', timeout: 5000 });
+ this._pageSnapshot = await page.ariaSnapshot({ mode: 'ai', timeout: 5000 });
}, { internal: true });
} catch {}
}
diff --git a/packages/playwright/src/mcp/test/browserBackend.ts b/packages/playwright/src/mcp/test/browserBackend.ts
index 3c30678dcb..86104ccba4 100644
--- a/packages/playwright/src/mcp/test/browserBackend.ts
+++ b/packages/playwright/src/mcp/test/browserBackend.ts
@@ -98,7 +98,7 @@ async function generatePausedMessage(testInfo: TestInfoImpl, context: playwright
lines.push(
`- Page Snapshot:`,
'```yaml',
- await page.ariaSnapshot({ format: 'ai' }),
+ await page.ariaSnapshot({ mode: 'ai' }),
'```',
);
}
diff --git a/packages/protocol/src/channels.d.ts b/packages/protocol/src/channels.d.ts
index 0dc226d605..6ca538f07f 100644
--- a/packages/protocol/src/channels.d.ts
+++ b/packages/protocol/src/channels.d.ts
@@ -2611,17 +2611,15 @@ export type PageRequestsResult = {
requests: RequestChannel[],
};
export type PageAriaSnapshotParams = {
- format?: 'ai' | 'default',
+ mode?: 'ai' | 'default',
track?: string,
- mode?: 'full' | 'incremental',
selector?: string,
depth?: number,
timeout: number,
};
export type PageAriaSnapshotOptions = {
- format?: 'ai' | 'default',
+ mode?: 'ai' | 'default',
track?: string,
- mode?: 'full' | 'incremental',
selector?: string,
depth?: number,
};
diff --git a/packages/protocol/src/protocol.yml b/packages/protocol/src/protocol.yml
index 90ca47e39e..063ab3e0d9 100644
--- a/packages/protocol/src/protocol.yml
+++ b/packages/protocol/src/protocol.yml
@@ -2012,18 +2012,13 @@ Page:
title: Aria snapshot
group: getter
parameters:
- format:
+ mode:
type: enum?
literals:
- ai
- default
# When track is present, an incremental snapshot is returned when possible.
track: string?
- mode:
- type: enum?
- literals:
- - full
- - incremental
selector: string?
depth: int?
timeout: float
diff --git a/tests/mcp/core.spec.ts b/tests/mcp/core.spec.ts
index 5256111ca5..a0936e80ac 100644
--- a/tests/mcp/core.spec.ts
+++ b/tests/mcp/core.spec.ts
@@ -108,7 +108,7 @@ test('browser_select_option', async ({ client, server }) => {
values: ['bar'],
},
})).toHaveResponse({
- snapshot: `- <changed> combobox [ref=e2]:
+ snapshot: `- combobox [ref=e2]:
- option "Foo"
- option "Bar" [selected]`,
});
@@ -138,8 +138,10 @@ test('browser_select_option (multiple)', async ({ client, server }) => {
},
})).toHaveResponse({
code: `await page.getByRole('listbox').selectOption(['bar', 'baz']);`,
- snapshot: `- <changed> option "Bar" [selected] [ref=e4]
-- <changed> option "Baz" [selected] [ref=e5]`,
+ snapshot: `- listbox [ref=e2]:
+ - option "Foo" [ref=e3]
+ - option "Bar" [selected] [ref=e4]
+ - option "Baz" [selected] [ref=e5]`,
});
});
diff --git a/tests/mcp/session-log.spec.ts b/tests/mcp/session-log.spec.ts
index 74b9a7da63..78c9b4a60b 100644
--- a/tests/mcp/session-log.spec.ts
+++ b/tests/mcp/session-log.spec.ts
@@ -78,7 +78,7 @@ test('session log should record tool calls', async ({ startClient, server, mcpBr
\\{
"code": "await page.getByRole\\('button', \\{ name: 'Submit' \\}\\).click\\(\\);",
"page": "- Page URL: http://localhost:${server.PORT}/\\\\n- Page Title: Title",
- "snapshot": "- <changed> button \\\\"Submit\\\\" \\[active\\] \\[ref=e2\\]"
+ "snapshot": "- button \\\\"Submit\\\\" \\[active\\] \\[ref=e2\\]"
\\}
\\\`\\\`\\\`
`.trim()));
diff --git a/tests/mcp/snapshot-diff.spec.ts b/tests/mcp/snapshot-diff.spec.ts
deleted file mode 100644
index 05c05a1fb0..0000000000
--- a/tests/mcp/snapshot-diff.spec.ts
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { test, expect } from './fixtures';
-
-test('should return aria snapshot diff', async ({ client, server }) => {
- server.setContent('/', `
- <button>Button 1</button>
- <button>Button 2</button>
- <ul id=filler></ul>
- <script>
- const filler = document.getElementById('filler');
- for (let i = 0; i < 100; i++) {
- const li = document.createElement('li');
- li.textContent = 'Filler ' + i;
- filler.appendChild(li);
- }
- const [button1, button2] = document.querySelectorAll('button');
- button1.addEventListener('click', () => {
- const span = document.createElement('span');
- span.textContent = 'new text';
- button2.appendChild(span);
- button1.focus(); // without manual focus, webkit focuses body
- });
- button2.focus();
- button2.addEventListener('click', () => {
- button2.focus(); // without manual focus, webkit focuses body
- });
- </script>
- `, 'text/html');
-
- const listitems = new Array(100).fill(0).map((_, i) => `\n - listitem [ref=e${5 + i}]: Filler ${i}`).join('');
-
- expect(await client.callTool({
- name: 'browser_navigate',
- arguments: {
- url: server.PREFIX,
- },
- })).toHaveResponse({
- snapshot: expect.stringContaining(`- button "Button 1" [ref=e2]
- - button "Button 2" [active] [ref=e3]
- - list [ref=e4]:${listitems}`),
- });
-
- expect(await client.callTool({
- name: 'browser_click',
- arguments: {
- element: 'Button 2',
- ref: 'e3',
- },
- })).toHaveResponse({
- snapshot: ``,
- });
-
- expect(await client.callTool({
- name: 'browser_click',
- arguments: {
- element: 'Button 1',
- ref: 'e2',
- },
- })).toHaveResponse({
- snapshot: `- <changed> generic [ref=e1]:
- - button "Button 1" [active] [ref=e2]
- - button "Button 2new text" [ref=e105]
- - ref=e4 [unchanged]`,
- });
-
- // browser_snapshot forces a full snapshot.
- expect(await client.callTool({
- name: 'browser_snapshot',
- })).toHaveResponse({
- inlineSnapshot: `- generic [ref=e1]:
- - button "Button 1" [active] [ref=e2]
- - button "Button 2new text" [ref=e105]
- - list [ref=e4]:${listitems}`,
- });
-});
-
-test('should reset aria snapshot diff upon navigation', async ({ client, server }) => {
- server.setContent('/before', `
- <button>Button 1</button>
- <button>Button 2</button>
- <ul id=filler></ul>
- <script>
- const filler = document.getElementById('filler');
- for (let i = 0; i < 100; i++) {
- const li = document.createElement('li');
- li.textContent = 'Filler ' + i;
- filler.appendChild(li);
- }
- document.querySelector('button').addEventListener('click', () => {
- window.location.href = '/after';
- });
- document.querySelectorAll('button')[1].focus();
- </script>
- `, 'text/html');
-
- server.setContent('/after', `
- <button>Button 1</button>
- <button>Button 2</button>
- <ul id=filler></ul>
- <script>
- const filler = document.getElementById('filler');
- for (let i = 0; i < 100; i++) {
- const li = document.createElement('li');
- li.textContent = 'Filler ' + i;
- filler.appendChild(li);
- }
- document.querySelectorAll('button')[1].focus();
- </script>
- `, 'text/html');
-
- expect(await client.callTool({
- name: 'browser_navigate',
- arguments: {
- url: server.PREFIX + '/before',
- },
- })).toHaveResponse({
- snapshot: expect.stringContaining(`- button "Button 1" [ref=e2]
- - button "Button 2" [active] [ref=e3]`),
- });
-
- expect(await client.callTool({
- name: 'browser_click',
- arguments: {
- element: 'Button 1',
- ref: 'e2',
- },
- })).toHaveResponse({
- snapshot: expect.stringContaining(`- button "Button 1" [ref=e2]
- - button "Button 2" [active] [ref=e3]`),
- });
-});
diff --git a/tests/mcp/snapshot-mode.spec.ts b/tests/mcp/snapshot-mode.spec.ts
index 0b4066b6ea..e96689ddc5 100644
--- a/tests/mcp/snapshot-mode.spec.ts
+++ b/tests/mcp/snapshot-mode.spec.ts
@@ -53,47 +53,6 @@ test('should respect --snapshot-mode=full', async ({ startClient, server }) => {
});
});
-test('should respect --snapshot-mode=incremental', async ({ startClient, server, mcpBrowser }) => {
- test.fixme(mcpBrowser === 'webkit', 'Active handling?');
- server.setContent('/', `<button>Button 1</button>`, 'text/html');
-
- const { client } = await startClient({
- args: ['--snapshot-mode=incremental'],
- });
-
- expect(await client.callTool({
- name: 'browser_navigate',
- arguments: {
- url: server.PREFIX,
- },
- })).toHaveResponse({
- snapshot: expect.stringContaining(`- button "Button 1" [ref=e2]`),
- });
-
- await client.callTool({
- name: 'browser_evaluate',
- arguments: {
- function: `async () => {
- const button2 = document.createElement('button');
- button2.textContent = 'Button 2';
- document.body.appendChild(button2);
- }`,
- },
- });
-
- expect(await client.callTool({
- name: 'browser_click',
- arguments: {
- element: 'Button 2',
- ref: 'e3',
- },
- })).toHaveResponse({
- snapshot: expect.stringContaining(`- <changed> generic [ref=e1]:
- - ref=e2 [unchanged]
- - button \"Button 2\" [active] [ref=e3]`),
- });
-});
-
test('should respect --snapshot-mode=none', async ({ startClient, server }) => {
server.setContent('/', `<button>Button 1</button>`, 'text/html');
diff --git a/tests/page/page-aria-snapshot-ai.spec.ts b/tests/page/page-aria-snapshot-ai.spec.ts
index 093b32e675..49d094ec8e 100644
--- a/tests/page/page-aria-snapshot-ai.spec.ts
+++ b/tests/page/page-aria-snapshot-ai.spec.ts
@@ -19,8 +19,8 @@ import { test as it, expect } from './pageTest';
import { unshift } from '../config/utils';
import type { Page } from 'playwright-core';
-async function snapshotForAI(page: Page, options?: Omit<Parameters<Page['ariaSnapshot']>[0], 'format'>): Promise<string> {
- return await page.ariaSnapshot({ ...options, format: 'ai' });
+async function snapshotForAI(page: Page, options?: Omit<Parameters<Page['ariaSnapshot']>[0], 'mode'> & { _track?: string }): Promise<string> {
+ return await page.ariaSnapshot({ ...options, mode: 'ai' });
}
it('should generate refs', async ({ page }) => {
@@ -494,26 +494,26 @@ it('should not remove generic nodes with title', async ({ page }) => {
it('should create incremental snapshots on multiple tracks', async ({ page }) => {
await page.setContent(`<ul><li><button>a button</button></li><li><span>a span</span></li><li id=hidden-li style="display:none">some text</li></ul>`);
- expect(await snapshotForAI(page, { track: 'first', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'first' })).toContainYaml(`
- list [ref=e2]:
- listitem [ref=e3]:
- button "a button" [ref=e4]
- listitem [ref=e5]: a span
`);
- expect(await snapshotForAI(page, { track: 'second', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'second' })).toContainYaml(`
- list [ref=e2]:
- listitem [ref=e3]:
- button "a button" [ref=e4]
- listitem [ref=e5]: a span
`);
- expect(await snapshotForAI(page, { track: 'first', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'first' })).toContainYaml(`
`);
await page.evaluate(() => {
document.querySelector('span').textContent = 'changed span';
document.getElementById('hidden-li').style.display = 'inline';
});
- expect(await snapshotForAI(page, { track: 'first', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'first' })).toContainYaml(`
- <changed> list [ref=e2]:
- ref=e3 [unchanged]
- listitem [ref=e5]: changed span
@@ -524,45 +524,38 @@ it('should create incremental snapshots on multiple tracks', async ({ page }) =>
document.querySelector('span').textContent = 'a span';
document.getElementById('hidden-li').style.display = 'none';
});
- expect(await snapshotForAI(page, { track: 'first', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'first' })).toContainYaml(`
- <changed> list [ref=e2]:
- ref=e3 [unchanged]
- listitem [ref=e5]: a span
`);
- expect(await snapshotForAI(page, { track: 'second', mode: 'incremental' })).toContainYaml(`
- `);
-
- expect(await snapshotForAI(page, { track: 'second', mode: 'full' })).toContainYaml(`
- - list [ref=e2]:
- - listitem [ref=e3]:
- - button "a button" [ref=e4]
- - listitem [ref=e5]: a span
+ expect(await snapshotForAI(page, { _track: 'second' })).toContainYaml(`
`);
});
it('should create incremental snapshot for attribute change', async ({ page }) => {
await page.setContent(`<button>a button</button>`);
await page.evaluate(() => document.querySelector('button').focus());
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- button "a button" [active] [ref=e2]
`);
await page.evaluate(() => document.querySelector('button').blur());
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> button "a button" [ref=e2]
`);
});
it('should create incremental snapshot for child removal', async ({ page }) => {
await page.setContent(`<li><button>a button</button><span>some text</span></li>`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- listitem [ref=e2]:
- button "a button" [ref=e3]
- text: some text
`);
await page.evaluate(() => document.querySelector('span').remove());
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> listitem [ref=e2]:
- ref=e3 [unchanged]
`);
@@ -570,13 +563,13 @@ it('should create incremental snapshot for child removal', async ({ page }) => {
it('should create incremental snapshot for child addition', async ({ page }) => {
await page.setContent(`<li><button>a button</button><span style="display:none">some text</span></li>`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- listitem [ref=e2]:
- button "a button" [ref=e3]
`);
await page.evaluate(() => document.querySelector('span').style.display = 'inline');
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> listitem [ref=e2]:
- ref=e3 [unchanged]
- text: some text
@@ -585,13 +578,13 @@ it('should create incremental snapshot for child addition', async ({ page }) =>
it('should create incremental snapshot for prop change', async ({ page }) => {
await page.setContent(`<a href="about:blank" style="cursor:pointer">a link</a>`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- link "a link" [ref=e2] [cursor=pointer]:
- /url: about:blank
`);
await page.evaluate(() => document.querySelector('a').setAttribute('href', 'https://playwright.dev'));
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> link "a link" [ref=e2] [cursor=pointer]:
- /url: https://playwright.dev
`);
@@ -599,13 +592,13 @@ it('should create incremental snapshot for prop change', async ({ page }) => {
it('should create incremental snapshot for cursor change', async ({ page }) => {
await page.setContent(`<a href="about:blank" style="cursor:pointer">a link</a>`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- link "a link" [ref=e2] [cursor=pointer]:
- /url: about:blank
`);
await page.evaluate(() => document.querySelector('a').style.cursor = 'default');
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> link "a link" [ref=e2]:
- /url: about:blank
`);
@@ -613,24 +606,24 @@ it('should create incremental snapshot for cursor change', async ({ page }) => {
it('should create incremental snapshot for name change', async ({ page }) => {
await page.setContent(`<button><span>a button</span></button>`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- button "a button" [ref=e2]
`);
await page.evaluate(() => document.querySelector('span').textContent = 'new button');
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> button "new button" [ref=e3]
`);
});
it('should create incremental snapshot for text change', async ({ page }) => {
await page.setContent(`<li><span>an item</span></li>`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- listitem [ref=e2]: an item
`);
await page.evaluate(() => document.querySelector('span').textContent = 'new text');
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> listitem [ref=e2]: new text
`);
});
@@ -645,7 +638,7 @@ it('should produce incremental snapshot for iframes', async ({ page }) => {
</li>
"></iframe>
`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- iframe [ref=e2]:
- listitem [ref=f1e2]:
- button "a button" [ref=f1e3]
@@ -655,7 +648,7 @@ it('should produce incremental snapshot for iframes', async ({ page }) => {
document.querySelector('span').style.display = 'block';
document.querySelector('iframe').style.display = 'block';
});
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> listitem [ref=f1e2]:
- generic [ref=f1e4]: outer text
- ref=f1e3 [unchanged]
@@ -677,7 +670,7 @@ it('should create multiple chunks in incremental snapshot', async ({ page }) =>
</ul>
</ul>
`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- list [ref=e2]:
- listitem [ref=e3]: item1
- listitem [ref=e4]: item2
@@ -697,7 +690,7 @@ it('should create multiple chunks in incremental snapshot', async ({ page }) =>
spans[2].parentElement.appendChild(button);
document.querySelector('#to-remove').remove();
});
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> listitem [ref=e3]: new item1
- <changed> group [ref=e6]:
- text: new item3
@@ -707,24 +700,6 @@ it('should create multiple chunks in incremental snapshot', async ({ page }) =>
`);
});
-it('should not create incremental snapshots without tracks', async ({ page }) => {
- await page.setContent(`<ul><li><button>a button</button></li><li><span>a span</span></li><li id=hidden-li style="display:none">some text</li></ul>`);
-
- expect(await snapshotForAI(page, { mode: 'full' })).toContainYaml(`
- - list [ref=e2]:
- - listitem [ref=e3]:
- - button "a button" [ref=e4]
- - listitem [ref=e5]: a span
- `);
- // Without a track, mode: 'incremental' falls back to full snapshot.
- expect(await snapshotForAI(page, { mode: 'incremental' })).toContainYaml(`
- - list [ref=e2]:
- - listitem [ref=e3]:
- - button "a button" [ref=e4]
- - listitem [ref=e5]: a span
- `);
-});
-
it('should create incremental snapshot for children swap', async ({ page }) => {
await page.setContent(`
<ul>
@@ -732,14 +707,14 @@ it('should create incremental snapshot for children swap', async ({ page }) => {
<li>item 2</li>
</ul>
`);
- expect(await snapshotForAI(page, { track: 'track', mode: 'full' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- list [ref=e2]:
- listitem [ref=e3]: item 1
- listitem [ref=e4]: item 2
`);
await page.evaluate(() => document.querySelector('ul').appendChild(document.querySelector('li')));
- expect(await snapshotForAI(page, { track: 'track', mode: 'incremental' })).toContainYaml(`
+ expect(await snapshotForAI(page, { _track: 'track' })).toContainYaml(`
- <changed> list [ref=e2]:
- ref=e4 [unchanged]
- ref=e3 [unchanged]
@@ -799,7 +774,7 @@ it('should limit depth', async ({ page }) => {
- listitem [ref=e10]: item3
`);
- const snapshot4 = await page.locator('#target').ariaSnapshot({ format: 'ai', depth: 1 });
+ const snapshot4 = await page.locator('#target').ariaSnapshot({ mode: 'ai', depth: 1 });
expect(snapshot4).toContainYaml(`
- list [ref=e6]:
- listitem [ref=e7]: item2