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
test: file input triggers input event only once (#20306)
Yury Semikhatsky7fcec1a06b01
diff --git a/tests/page/page-set-input-files.spec.ts b/tests/page/page-set-input-files.spec.tsindex 14ea76fff4..01f28c748a 100644--- a/tests/page/page-set-input-files.spec.ts+++ b/tests/page/page-set-input-files.spec.ts@@ -548,3 +548,26 @@ it('should trigger listener added before navigation', async ({ page, server, broexpect(chooser).toBeTruthy();});+it('input should trigger events when files changed second time', async ({ page, asset, browserName }) => {+ it.fixme(browserName === 'webkit');+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/20079' });+ await page.setContent(`<input type=file multiple=true/>`);++ const input = page.locator('input');+ const events = await input.evaluateHandle(e => {+ const events = [];+ e.addEventListener('input', () => events.push('input'));+ e.addEventListener('change', () => events.push('change'));+ return events;+ });++ await input.setInputFiles(asset('file-to-upload.txt'));+ expect(await input.evaluate(e => (e as HTMLInputElement).files[0].name)).toBe('file-to-upload.txt');+ expect(await events.evaluate(e => e)).toEqual(['input', 'change']);++ await events.evaluate(e => e.length = 0);++ await input.setInputFiles(asset('pptr.png'));+ expect(await input.evaluate(e => (e as HTMLInputElement).files[0].name)).toBe('pptr.png');+ expect(await events.evaluate(e => e)).toEqual(['input', 'change']);+});\ No newline at end of file