From fc08a7dd54226878300f3a4b52fb16aeb5cc93e8 Mon Sep 17 00:00:00 2001 From: Alex Rudenko Date: Thu, 17 Aug 2023 08:05:58 +0200 Subject: [PATCH] fix: locator.fill should work for textareas (#10737) Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> --- .../src/api/locators/Locator.ts | 3 +++ test/src/locator.spec.ts | 23 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/puppeteer-core/src/api/locators/Locator.ts b/packages/puppeteer-core/src/api/locators/Locator.ts index ede94498..32d3f4e2 100644 --- a/packages/puppeteer-core/src/api/locators/Locator.ts +++ b/packages/puppeteer-core/src/api/locators/Locator.ts @@ -476,6 +476,9 @@ export abstract class Locator extends EventEmitter { if (el instanceof HTMLSelectElement) { return 'select'; } + if (el instanceof HTMLTextAreaElement) { + return 'typeable-input'; + } if (el instanceof HTMLInputElement) { if ( new Set([ diff --git a/test/src/locator.spec.ts b/test/src/locator.spec.ts index 30c11308..abab4aeb 100644 --- a/test/src/locator.spec.ts +++ b/test/src/locator.spec.ts @@ -370,7 +370,28 @@ describe('Locator', function () { }); }); - describe('Locator.change', function () { + describe('Locator.fill', function () { + it('should work for textarea', async () => { + const {page} = await getTestState(); + + await page.setContent(` + + `); + let filled = false; + await page + .locator('textarea') + .on(LocatorEmittedEvents.Action, () => { + filled = true; + }) + .fill('test'); + expect( + await page.evaluate(() => { + return document.querySelector('textarea')?.value === 'test'; + }) + ).toBe(true); + expect(filled).toBe(true); + }); + it('should work for selects', async () => { const {page} = await getTestState();