Skip to content

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

fix(input): send keypress event for enter key in chromium (#3796)

Joel Einbinder1791be6d1652
diff --git a/src/server/chromium/crInput.ts b/src/server/chromium/crInput.ts
index 63faf1eb93..e7e4d24b8f 100644
--- a/src/server/chromium/crInput.ts
+++ b/src/server/chromium/crInput.ts
@@ -53,6 +53,8 @@ export class RawKeyboardImpl implements input.RawKeyboard {
let commands = macEditingCommands[shortcut] || [];
if (isString(commands))
commands = [commands];
+ // Commands that insert text are not supported
+ commands = commands.filter(x => !x.startsWith('insert'));
// remove the trailing : to match the Chromium command names.
return commands.map(c => c.substring(0, c.length - 1));
}
diff --git a/test/page-basic.spec.ts b/test/page-basic.spec.ts
index 48482b533b..6a767dac53 100644
--- a/test/page-basic.spec.ts
+++ b/test/page-basic.spec.ts
@@ -237,9 +237,7 @@ it('page.press should work', async ({page, server}) => {
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('a');
});
-it('page.press should work for Enter', test => {
- test.fail(options.CHROMIUM && MAC, 'page.press() does not emit keypress event on Enter');
-}, async ({page, server}) => {
+it('page.press should work for Enter', async ({page, server}) => {
await page.setContent(`<input onkeypress="console.log('press')"></input>`);
const messages = [];
page.on('console', message => messages.push(message));