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
fix(aria): disregard text area textContent (#34544)
Pavel Feldmaneff5cd6dbbc4
diff --git a/packages/playwright-core/src/server/injected/ariaSnapshot.ts b/packages/playwright-core/src/server/injected/ariaSnapshot.tsindex 5f6782fe7f..4318b9aea9 100644--- a/packages/playwright-core/src/server/injected/ariaSnapshot.ts+++ b/packages/playwright-core/src/server/injected/ariaSnapshot.ts@@ -57,7 +57,8 @@ export function generateAriaTree(rootElement: Element): AriaSnapshot {if (node.nodeType === Node.TEXT_NODE && node.nodeValue) {const text = node.nodeValue;- if (text)+ // <textarea>AAA</textarea> should not report AAA as a child of the textarea.+ if (ariaNode.role !== 'textbox' && text)ariaNode.children.push(node.nodeValue || '');return;}diff --git a/tests/page/page-aria-snapshot.spec.ts b/tests/page/page-aria-snapshot.spec.tsindex 878262400d..78bfb667d8 100644--- a/tests/page/page-aria-snapshot.spec.ts+++ b/tests/page/page-aria-snapshot.spec.ts@@ -605,3 +605,16 @@ it('should escape special yaml values', async ({ page }) => {- textbox: "555"`);});++it('should not report textarea textContent', async ({ page }) => {+ await page.setContent(`<textarea>Before</textarea>`);+ await checkAndMatchSnapshot(page.locator('body'), `+ - textbox: Before+ `);+ await page.evaluate(() => {+ document.querySelector('textarea').value = 'After';+ });+ await checkAndMatchSnapshot(page.locator('body'), `+ - textbox: After+ `);+});