fix: locator.fill should work for textareas (#10737)

Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
This commit is contained in:
Alex Rudenko 2023-08-17 08:05:58 +02:00 committed by GitHub
parent 0a686fbf24
commit fc08a7dd54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -476,6 +476,9 @@ export abstract class Locator<T> extends EventEmitter {
if (el instanceof HTMLSelectElement) {
return 'select';
}
if (el instanceof HTMLTextAreaElement) {
return 'typeable-input';
}
if (el instanceof HTMLInputElement) {
if (
new Set([

View File

@ -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(`
<textarea></textarea>
`);
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();