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(selectors): match `input[type="reset"]` button label as text (#41473)
Devin Roussoaeee3a395dff
diff --git a/packages/injected/src/selectorUtils.ts b/packages/injected/src/selectorUtils.tsindex 6466e1b7b0..2a02df62ff 100644--- a/packages/injected/src/selectorUtils.ts+++ b/packages/injected/src/selectorUtils.ts@@ -68,7 +68,7 @@ export function elementText(cache: Map<Element | ShadowRoot, ElementText>, root:value = { full: '', normalized: '', immediate: [] };if (!shouldSkipForTextMatching(root)) {let currentImmediate = '';- if ((root instanceof HTMLInputElement) && (root.type === 'submit' || root.type === 'button')) {+ if ((root instanceof HTMLInputElement) && (root.type === 'submit' || root.type === 'button' || root.type === 'reset')) {value = { full: root.value, normalized: normalizeWhiteSpace(root.value), immediate: [root.value] };} else {for (let child = root.firstChild; child; child = child.nextSibling) {diff --git a/tests/page/selectors-text.spec.ts b/tests/page/selectors-text.spec.tsindex 3793cdac5c..0c0afa7b5a 100644--- a/tests/page/selectors-text.spec.ts+++ b/tests/page/selectors-text.spec.ts@@ -362,10 +362,11 @@ it('should skip head, script and style', async ({ page }) => {}});-it('should match input[type=button|submit]', async ({ page }) => {- await page.setContent(`<input type="submit" value="hello"><input type="button" value="world">`);+it('should match input[type=button|submit|reset]', async ({ page }) => {+ await page.setContent(`<input type="submit" value="hello"><input type="button" value="world"><input type="reset" value="clear">`);expect(await page.$eval(`text=hello`, e => e.outerHTML)).toBe('<input type="submit" value="hello">');expect(await page.$eval(`text=world`, e => e.outerHTML)).toBe('<input type="button" value="world">');+ expect(await page.$eval(`text=clear`, e => e.outerHTML)).toBe('<input type="reset" value="clear">');});it('should work for open shadow roots', async ({ page, server }) => {