How to send emoticons to text field

Hi,

I’m currently trying to send a string to an android device with appium/java.
When using two different strings like

string1 = “Wow! That is great!” and
string2=“Wow! That is great! :roll_eyes::open_mouth::turkey::robot::princess::tada::monkey::panda_face::relieved::grimacing:!”

with findElement(By.id(editTextID)).sendKeys(stringX).

The first string1 is send without problems. But the second one does not even appear on the screen of the mobile device.

info: --> POST […]/value {“id”:“54”,“value”:[“Wow! That is great! :roll_eyes::open_mouth::turkey::robot::princess::tada::monkey::panda_face::relieved::grimacing:!”]}
info: [debug] Pushing command to appium work queue: [“element:setText”,{“elementId”:“54”,“text”:“Wow! That is great! :roll_eyes::open_mouth::turkey::robot::princess::tada::monkey::panda_face::relieved::grimacing:!”,“replace”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“element:setText”,“params”:{“elementId”:“54”,“text”:“Wow! That is great! :roll_eyes::open_mouth::turkey::robot::princess::tada::monkey::panda_face::relieved::grimacing:!”,“replace”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: setText
info: [debug] [BOOTSTRAP] [debug] Using element passed in.
info: [debug] [BOOTSTRAP] [debug] Attempting to clear using UiObject.clearText().

info: [debug] [BOOTSTRAP] [debug] Text remains after clearing, but it appears to be hint text.

info: [debug] [BOOTSTRAP] [debug] Text not cleared. Assuming remainder is hint text.

info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: Wow! That is great! :roll_eyes::open_mouth::turkey::robot::princess::tada::monkey::panda_face::relieved::grimacing: !

info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}

info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:"[…]"}
info: <-- POST […]/54/value 200 5368.662 ms - 76 {“status”:0,“value”:true,“sessionId”:"[…]"}

What Encoding are you using? You may want to try Unicode.

Hi @wreed, thanks for your answer,

I am using UTF-8.
Or do you mean i should just encode the emoticons in unicode?

I was trying to do this like:

char c1 = “\u1F621”.toCharArray()[0];
char c2 = “\u1F637”.toCharArray()[0];
char c3 = “\u1F63B”.toCharArray()[0];
char c4 = “\u1F646”.toCharArray()[0];
String messageWithEmoticon = "Wow! That is great! " + c1 + c2 + c3 + c4 + “!”;

But that does not change the result. Now the debug information is just not that colorful anymore:

info: [debug] [BOOTSTRAP] [debug] Sending plain text to element: Wow! That is great! ὢὣὣὤ!

Or should I encode them in a different way?

try also set capability with android drive ‘unicodeKeyboard’ to ‘true’

Hi @Aleksei,

I tried around with combinations of
caps.setCapability(“unicodeKeyboard”, true);
caps.setCapability(“resetKeyboard”, true);
but that also did not change a think.

Different devices and simulators are also not the reason.

Is there anyone here, who has ever tried this out and made it work? Am I the only person with this problem or am I only the only one who tries to sends emoticons to text fields?

Just idea emotion itself is e.g. “:smile:” try so send one by one “that is great! :smi” send another part “le::mon” and so on. Idea is divide smile into several part.

Full disclosure: I don’t need to write emoticons to the screen. However, I do have a joker of a developer who put emoticons in all of our Debug mode screens. So I have to read them from the screen.

We had to monkey patch WebDriver (I’m using Ruby) so that the ‘text’ property would be properly read. Here is the code:

require 'unicode_utils'
module Selenium
  module WebDriver
    class Element
      def text
        UnicodeUtils.nfc bridge.getElementText @id
      end
    end

    class Alert

      def text
        UnicodeUtils.nfc @bridge.getAlertText
      end
    end
  end
end

Yay! Now we can read ‘:zap:SuperDebugMenu​:zap:’

I hope this helps.