0

I have a winforms application. I installed the latest stable Appium version through NuGet.

I simply want to enter an emoji into a text field

using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Appium;
using System.Windows.Forms;
using System;

var appiumOptions = new AppiumOptions();
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "1234");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.AutomationName, "UiAutomator2");
         

var driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);

AndroidElement messageBox = driver.FindElementById("com.app:id/simple_text");                
messageBox.SendKeys("");

But the output is always "��" instead.

If I use the Appium Session Manager to set the field, it works flawlessly.

I strangely noticed in the Appium Window that for my C# program, this appears:

[HTTP] {"text":"","value":["�","�"]}

But for the Appium Session Manager, it looks like this

[HTTP] {"value":[""],"text":""}

It works correctly when using Selenium WebDriver instead of Appium but this is not an optimal solution.

Are there any ways to fix this?

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
maddo7
  • 4,503
  • 6
  • 31
  • 51
  • The method is called `SendKeys` not `Type` or `SendString`. `"".Length` returns 2. . Emojis may be composed by one or more Unicode characters that are invalid as individual characters. – Panagiotis Kanavos Apr 11 '23 at 08:57
  • 1
    Does this answer your question? [Sending emojis with selenium's send\_keys()](https://stackoverflow.com/questions/51706256/sending-emojis-with-seleniums-send-keys) – Panagiotis Kanavos Apr 11 '23 at 08:59
  • An alternative to using Javascript to send the text is to send the actual keystrokes you'd use to enter the emoji. That's rather fragile though, as it depends on the virtual keyboard used by the target machine – Panagiotis Kanavos Apr 11 '23 at 09:02
  • The application receiving the keys should also support Unicode characters, too. Silly question, but when you use the app on your phone, can you insert Unicode emoji's from the native keyboard app? – Greg Burghardt Apr 11 '23 at 12:21

0 Answers0