Cannot send emoji to input field with unicode keyboard

Automating tests for native android app. Trying to make Appium send emojis with sendKeys() method, but it doesn’t seem to work. I have added “unicodeKeyboard” and “resetKeyboard” to the capabilities, and logs say that keys were send, but input field stays empty.

Appium version is 1.6.5. Testing on a real device.

String I’m sending looks something like this:

private static final String GRINNING_FACE = new String(Character.toChars(0x1F601));

Hi,

can’t you use the java code directly instead of HEX code?

.sendKeys("\uD83D\uDE01");

Thank you for the answer. I tried to use the java code directly, but result is the same. Input field stays empty.

It works for me… Can you share the appium logs?

Appium logs look like this:

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in: 23
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
[HTTP] --> GET /wd/hub/status {}
[debug] [MJSONWP] Calling AppiumDriver.getStatus() with args: []
[debug] [MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.6.5”,“revision”:null}}
[HTTP] <-- GET /wd/hub/status 200 1056 ms - 83
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text remains after clearing, but it appears to be hint text.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text not cleared. Assuming remainder is hint text.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Sending plain text to element: :grin:
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:0,“value”:true}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.setValue() result: true

Maybe you using old uiautomator… can you switch to uiautomator2?

capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");

Yes, It may be that I’m using deprecated uiautomator.
Anyway, just tried it with uiautomator2 and got some inexplicable StaleObjectException at starting page.

Thats another issue :slight_smile: Look around in the forum, there are some explanations about what it is and how to try to avoid it

Hi ,

I am facing issue in sending emojis to ios simulator . When I send the below commands I see “?”"?" ion device .Can you please let me know how did you achieve.

I am sending “driver.findElementByXPath(”//XCUIElementTypeTextField[@name=‘registerUserNameField’]").sendKeys(“:credit_card:”);"

and also tried unicode “\uD83D\uDCB3”


[HTTP] --> POST /wd/hub/session/b6c082f0-f156-4255-8ced-25e133050564/element/1D000000-0000-0000-871A-000000000000/value

[HTTP] {"id":"1D000000-0000-0000-871A-000000000000","text":":credit_card:","value":[":credit_card:"]}

[debug] [W3C (b6c082f0)] Calling AppiumDriver.setValue() with args: [[":credit_card:"],"1D000000-0000-0000-871A-000000000000","b6c082f0-f156-4255-8ced-25e133050564"]

[debug] [XCUITest] Executing command ‘setValue’

[debug] [WD Proxy] Matched ‘/element/1D000000-0000-0000-871A-000000000000/value’ to command name ‘setValue’

[debug] [Protocol Converter] Added ‘text’ property “:credit_card:” to ‘setValue’ request body

[debug] [WD Proxy] Proxying [POST /element/1D000000-0000-0000-871A-000000000000/value] to [POST http://localhost:8100/session/3ABEBC18-8255-4D61-B820-F89693D7E006/element/1D000000-0000-0000-871A-000000000000/value] with body: {"value":[" "," "],"text":":credit_card:"}

[debug] [WD Proxy] Got response with status 200: {"status":0,"id":"1D000000-0000-0000-871A-000000000000","value":"","sessionId":"3ABEBC18-8255-4D61-B820-F89693D7E006"}

[debug] [W3C (b6c082f0)] Responding to client with driver.setValue() result: null

[HTTP] <-- POST /wd/hub/session/b6c082f0-f156-4255-8ced-25e133050564/element/1D000000-0000-0000-871A-000000000000/value 200 2388 ms - 14

[HTTP]

can you help how you did I am facing same issue

I was not able to solve it. Assumed as project limitation, cannot send emojis that are represented with 2 unicode codes in iOS