Falko Falko - 5 months ago 36
Android Question

Xamarin.UITest on Android: Dismiss keyboard with Entry.Completed

I'm testing a Xamarin.Forms app with an

element. I'd like to enter some text and dismiss the keyboard raising the
event. On iOS this is working nicely with
. On Android, however, this only inserts another whitespace.

How can I dismiss the keyboard such that
is raised?

I could imagine invoking a backdoor method or executing methods on the native views, but I couldn't get it to work, yet. Do you know how to raise
programatically from within Xamarin.Forms or Xamarin.Android?


Oh, I found a solution and it's rather trivial.

While the IApp interface has no method that is dismissing the keyboard and raising Entry.Completed on Android, there is AndroidApp.PressUserAction() for the desired purpose. So we can write:

(app as iOSApp)?.PressEnter();
(app as AndroidApp)?.PressUserAction();