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(role): support `<search>` element (#36512)
Dmitry Gozmaneacc204c5fed
diff --git a/packages/injected/src/roleUtils.ts b/packages/injected/src/roleUtils.tsindex 75bb580dad..e652ee8c15 100644--- a/packages/injected/src/roleUtils.ts+++ b/packages/injected/src/roleUtils.ts@@ -153,6 +153,7 @@ const kImplicitRoleByTagName: { [tagName: string]: (e: Element) => AriaRole | nu'OUTPUT': () => 'status','P': () => 'paragraph','PROGRESS': () => 'progressbar',+ 'SEARCH': () => 'search','SECTION': (e: Element) => hasExplicitAccessibleName(e) ? 'region' : null,'SELECT': (e: Element) => e.hasAttribute('multiple') || (e as HTMLSelectElement).size > 1 ? 'listbox' : 'combobox','STRONG': () => 'strong',diff --git a/tests/library/role-utils.spec.ts b/tests/library/role-utils.spec.tsindex bdfb9c78c7..4bde350c2d 100644--- a/tests/library/role-utils.spec.ts+++ b/tests/library/role-utils.spec.ts@@ -549,6 +549,20 @@ test('should ignore invalid aria-labelledby', async ({ page }) => {expect.soft(await getNameAndRole(page, 'input')).toEqual({ role: 'textbox', name: 'Text here' });});+test('should support search element', async ({ page }) => {+ await page.setContent(`+ <search id=search1 aria-label="example">+ Hello+ </search>+ <search id=search2>+ World+ </search>+ `);+ expect.soft(await getNameAndRole(page, '#search1')).toEqual({ role: 'search', name: 'example' });+ expect.soft(await getNameAndRole(page, '#search2')).toEqual({ role: 'search', name: '' });+ await expect.soft(page.getByRole('search', { name: 'example' })).toBeVisible();+});+function toArray(x: any): any[] {return Array.isArray(x) ? x : [x];}