I am trying to sendkeys a emoji.I have tried to send it by coping the signal
This error message...
OpenQA.Selenium.WebDriverException: 'unknown error: ChromeDriver only supports characters in the BMP
...implies that the ChromeDriver was unable to send the emoji i.e. ?? signal through SendKeys()
method.
Taking out a leaf from @JimEvans answer, currently ChromeDriver only supports code points in the Plane 0 i.e. the Basic Multilingual Plane (BMP) at present.
Using GeckoDriver/Firefox or IEDriverServer/IE combo would have fetched you better results.
You can find the current status of the specific tests in the Web Platform Test Suite that specifically send emojis and these work for other browsers too.
However, to send a emoji through C# you can use the following syntax:
input.SendKeys("\u1F44D");
Solution
async sendKeysWithEmojis(element, text) {
const script = `var elm = arguments[0],
txt = arguments[1];elm.value += txt;
elm.dispatchEvent(new Event('keydown', {bubbles: true}));
elm.dispatchEvent(new Event('keypress', {bubbles: true}));
elm.dispatchEvent(new Event('input', {bubbles: true}));
elm.dispatchEvent(new Event('keyup', {bubbles: true}));`;
await this.driver.executeScript(script, element, text);
}
Call it like so
const element = await this.driver.findElement(selector);
await sendKeysWithEmojis(element, '