diff --git a/lib/Input.js b/lib/Input.js index 6f2ce2e3..72a05d98 100644 --- a/lib/Input.js +++ b/lib/Input.js @@ -148,13 +148,7 @@ class Keyboard { * @param {string} char */ async sendCharacter(char) { - await this._client.send('Input.dispatchKeyEvent', { - type: 'char', - modifiers: this._modifiers, - text: char, - key: char, - unmodifiedText: char - }); + await this._client.send('Input.insertText', {text: char}); } /** diff --git a/test/input.spec.js b/test/input.spec.js index a50c6b76..9505b06c 100644 --- a/test/input.spec.js +++ b/test/input.spec.js @@ -472,6 +472,19 @@ module.exports.addTests = function({testRunner, expect, DeviceDescriptors}) { error = await page.keyboard.press('😊').catch(e => e); expect(error && error.message).toBe('Unknown key: "😊"'); }); + it('should type emoji', async({page, server}) => { + await page.goto(server.PREFIX + '/input/textarea.html'); + await page.type('textarea', '👹 Tokyo street Japan 🇯🇵'); + expect(await page.$eval('textarea', textarea => textarea.value)).toBe('👹 Tokyo street Japan 🇯🇵'); + }); + it('should type emoji into an iframe', async({page, server}) => { + await page.goto(server.EMPTY_PAGE); + await utils.attachFrame(page, 'emoji-test', server.PREFIX + '/input/textarea.html'); + const frame = page.frames()[1]; + const textarea = await frame.$('textarea'); + await textarea.type('👹 Tokyo street Japan 🇯🇵'); + expect(await frame.$eval('textarea', textarea => textarea.value)).toBe('👹 Tokyo street Japan 🇯🇵'); + }); function dimensions() { const rect = document.querySelector('textarea').getBoundingClientRect(); return {