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): use placeholder for the accessible name of `<input type="number">` (#41485)
Devin Roussoda747ec24da6
diff --git a/packages/injected/src/roleUtils.ts b/packages/injected/src/roleUtils.tsindex 1c1bfb8635..f18665902a 100644--- a/packages/injected/src/roleUtils.ts+++ b/packages/injected/src/roleUtils.ts@@ -827,7 +827,7 @@ function getTextAlternativeInternal(element: Element, options: AccessibleNameOptif (labels.length)return getAccessibleNameFromAssociatedLabels(labels, options);- const usePlaceholder = (tagName === 'INPUT' && ['text', 'password', 'search', 'tel', 'email', 'url'].includes((element as HTMLInputElement).type)) || tagName === 'TEXTAREA';+ const usePlaceholder = (tagName === 'INPUT' && ['text', 'password', 'number', 'search', 'tel', 'email', 'url'].includes((element as HTMLInputElement).type)) || tagName === 'TEXTAREA';const placeholder = element.getAttribute('placeholder') || '';const title = element.getAttribute('title') || '';if (!usePlaceholder || title)diff --git a/tests/library/role-utils.spec.ts b/tests/library/role-utils.spec.tsindex d894edbb29..7006f4d372 100644--- a/tests/library/role-utils.spec.ts+++ b/tests/library/role-utils.spec.ts@@ -299,6 +299,7 @@ test('native controls', async ({ page }) => {<label for="text1">TEXT1</label><input id="text1" type=text><input id="text2" type=text title="TEXT2"><input id="text3" type=text placeholder="TEXT3">+ <input id="number1" type=number placeholder="NUMBER1"><label for="image1">IMAGE1</label><input id="image1" type=image><input id="image2" type=image alt="IMAGE2">@@ -316,6 +317,7 @@ test('native controls', async ({ page }) => {expect.soft(await getNameAndRole(page, '#text1')).toEqual({ role: 'textbox', name: 'TEXT1' });expect.soft(await getNameAndRole(page, '#text2')).toEqual({ role: 'textbox', name: 'TEXT2' });expect.soft(await getNameAndRole(page, '#text3')).toEqual({ role: 'textbox', name: 'TEXT3' });+ expect.soft(await getNameAndRole(page, '#number1')).toEqual({ role: 'spinbutton', name: 'NUMBER1' });expect.soft(await getNameAndRole(page, '#image1')).toEqual({ role: 'button', name: 'IMAGE1' });expect.soft(await getNameAndRole(page, '#image2')).toEqual({ role: 'button', name: 'IMAGE2' });expect.soft(await getNameAndRole(page, '#image3')).toEqual({ role: 'button', name: 'IMAGE3' });