Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add setInputFiles input event test (#944)

Pavel Feldmanc8c4356d7cd0
diff --git a/test/input.spec.js b/test/input.spec.js
index ea796842bd..4a78afa06a 100644
--- a/test/input.spec.js
+++ b/test/input.spec.js
@@ -193,6 +193,18 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
path.relative(process.cwd(), __dirname + '/assets/pptr.png')).catch(e => error = e);
expect(error).not.toBe(null);
});
+ it('should emit input change event', async({page, server}) => {
+ const events = [];
+ await page.exposeFunction('eventHandled', e => events.push(e));
+ await page.setContent(`
+ <input id=input type=file></input>
+ <script>
+ input.addEventListener('input', e => eventHandled({ type: e.type }));
+ </script>`);
+ await (await page.$('input')).setInputFiles(FILE_TO_UPLOAD);
+ expect(events.length).toBe(1);
+ expect(events[0].type).toBe('input');
+ });
});
describe('Page.waitForFileChooser isMultiple', () => {