Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: only render top-level cursor=pointer (#37196)
Pavel Feldmana114f92a3c18
diff --git a/packages/injected/src/ariaSnapshot.ts b/packages/injected/src/ariaSnapshot.tsindex 1fcde61224..ad4ccbd233 100644--- a/packages/injected/src/ariaSnapshot.ts+++ b/packages/injected/src/ariaSnapshot.ts@@ -469,7 +469,7 @@ export function renderAriaTree(ariaSnapshot: AriaSnapshot, publicOptions: AriaTrconst lines: string[] = [];const includeText = options.renderStringsAsRegex ? textContributesInfo : () => true;const renderString = options.renderStringsAsRegex ? convertToBestGuessRegex : (str: string) => str;- const visit = (ariaNode: AriaNode | string, parentAriaNode: AriaNode | null, indent: string) => {+ const visit = (ariaNode: AriaNode | string, parentAriaNode: AriaNode | null, indent: string, renderCursorPointer: boolean) => {if (typeof ariaNode === 'string') {if (parentAriaNode && !includeText(parentAriaNode, ariaNode))return;@@ -507,10 +507,13 @@ export function renderAriaTree(ariaSnapshot: AriaSnapshot, publicOptions: AriaTrif (ariaNode.selected === true)key += ` [selected]`;+ let inCursorPointer = false;if (ariaNode.ref) {key += ` [ref=${ariaNode.ref}]`;- if (options.renderCursorPointer && hasPointerCursor(ariaNode))+ if (renderCursorPointer && hasPointerCursor(ariaNode)) {+ inCursorPointer = true;key += ' [cursor=pointer]';+ }}const escapedKey = indent + '- ' + yamlEscapeKeyIfNeeded(key);@@ -528,7 +531,7 @@ export function renderAriaTree(ariaSnapshot: AriaSnapshot, publicOptions: AriaTrfor (const [name, value] of Object.entries(ariaNode.props))lines.push(indent + ' - /' + name + ': ' + yamlEscapeValueIfNeeded(value));for (const child of ariaNode.children || [])- visit(child, ariaNode, indent + ' ');+ visit(child, ariaNode, indent + ' ', renderCursorPointer && !inCursorPointer);}};@@ -536,9 +539,9 @@ export function renderAriaTree(ariaSnapshot: AriaSnapshot, publicOptions: AriaTrif (ariaNode.role === 'fragment') {// Render fragment.for (const child of ariaNode.children || [])- visit(child, ariaNode, '');+ visit(child, ariaNode, '', !!options.renderCursorPointer);} else {- visit(ariaNode, null, '');+ visit(ariaNode, null, '', !!options.renderCursorPointer);}return lines.join('\n');}diff --git a/tests/page/page-aria-snapshot-ai.spec.ts b/tests/page/page-aria-snapshot-ai.spec.tsindex 86b6f344ad..1493f65291 100644--- a/tests/page/page-aria-snapshot-ai.spec.ts+++ b/tests/page/page-aria-snapshot-ai.spec.ts@@ -218,6 +218,23 @@ it('should include cursor pointer hint', async ({ page }) => {`);});+it('should not nest cursor pointer hints', async ({ page }) => {+ await page.setContent(`+ <a style="cursor: pointer" href="about:blank">+ Link with a button+ <button style="cursor: pointer">Button</button>+ </a>+ `);++ const snapshot = await snapshotForAI(page);+ expect(snapshot).toContainYaml(`+ - link \"Link with a button Button\" [ref=e2] [cursor=pointer]:+ - /url: about:blank+ - text: Link with a button+ - button "Button" [ref=e3]+ `);+});+it('should gracefully fallback when child frame cant be captured', async ({ page, server }) => {await page.setContent(`<p>Test</p>