Appcenter: Issue with app.EnterText for Android API 29 ONLY Xamarin.UITest

Created on 3 Dec 2019  Â·  87Comments  Â·  Source: microsoft/appcenter

I have been having an issue with Xamarin.UITest after the application that I am working on was updated to the latest android version (API 29). This issue did not happen before the application updates and automation worked as intended on API 29. Before the application was updated and you did a fresh install the application would have an "OS" prompt stating that the "Application was out of Date" once the application was updated that prompt no longer displayed however the Xamarin.UITest issues appeared.

The issue is that when automation runs on a device with API 29 ONLY and when the code app.EnterText runs the text that was requested via code to be inputted does not get input. The same applies to app.ClearText, once the command is done the text in the field does not get cleared. its as if there is a permission issue with the automation interacting with the application text fields only. Note, the test does not fail with an error and the test keeps running like it did the commend, which makes it header to know why it's doing this.

I did work with my DEV's to see if this is an application issue and his theory is that it's a permission issue but we are both not sure where the issue is of what permission is being blocked any help of shedding light would be very helpful.

Environment replication that I am seeing the issues on:
Device/OS: Pixel 3 XL (real device)/ Android version 10(API 29)
Xamarin.UITest version: 3.0.4

Application:
Rinning the latest updates for packages including Xamrin.Forms and the application is configured for API(29)
Note: the text fields work just fine outside of automation and if a user inputs the text it works as intended, just an Automation issue

VS/Xcode version:
Visual Studio Enterprise 2019 for Mac
Version 8.3.10 (build 2)
Installation UUID: 87bfc8d6-bb7e-4416-8725-c451ad424835
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)

Package version: 604000208
Mono Framework MDK
Runtime:
Mono 6.4.0.208 (2019-06/07c23f2ca43) (64-bit)
Package version: 604000208

NuGet
Version: 5.3.0.6192

.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.0.100/Sdks
SDK Versions:
3.0.100
2.1.700
2.1.505
2.1.504
2.1.503
2.1.302
2.1.301
2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.0.0
2.1.13
2.1.11
2.1.9
2.1.8
2.1.7
2.1.2
2.1.1
2.0.5

Xamarin.Profiler
Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 11.2.1 (15526.1)
Build 11B500

Xamarin Designer
Version: 16.3.0.256
Hash: 8a223bfd7
Branch: remotes/origin/d16-3
Build date: 2019-11-01 21:02:02 UTC

Xamarin.Mac
Version: 6.6.0.12 (Visual Studio Enterprise)
Hash: e3c2b406d
Branch: xcode11.2
Build date: 2019-11-01 00:12:07-0400

Xamarin.iOS
Version: 13.6.0.12 (Visual Studio Enterprise)
Hash: e3c2b406d
Branch: xcode11.2
Build date: 2019-11-01 00:12:08-0400

Xamarin.Android
Version: 10.0.6.2 (Visual Studio Enterprise)
Commit: xamarin-android/d16-3/c407838
Android SDK: /Users/{*}/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.5
SDK Build Tools Version: 28.0.3

Build Information:
Mono: mono/mono/2019-06@476d72b9e32
Java.Interop: xamarin/java.interop/d16-3@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip/rel-1-5-1@b95cf3fd
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333

Microsoft Mobile OpenJDK
Java SDK: /Users/mmoadeb/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 1.4.0.65
Hash: c33b107
Branch: remotes/origin/d16-3
Build date: 2019-11-19 20:33:22 UTC

Android Device Manager
Version: 1.2.0.116
Hash: d2b2af0
Branch: remotes/origin/d16-3
Build date: 2019-11-19 20:33:42 UTC

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 803100002
Git revision: add3a4998a5cb5b081e0404e1fe13acfecb7801d
Build date: 2019-11-20 13:35:15+00
Build branch: release-8.3
Xamarin extensions: 79c69708816813b498283eeda7bcb4d464433a04

Operating System
Mac OS X 10.15.1
Darwin 19.0.0 Darwin Kernel Version 19.0.0
Thu Oct 17 16:17:15 PDT 2019
root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64

Enabled user installed extensions
Straight8's SpecFlow Integration 1.11.3.0
XAML Styler 1.1.5

The only error that I see when debugging the test is below, I am not sure if this has any relevance:

[0x7000100bc000] The instruction pointer of the currently executing method(Xamarin.UITest.Queries.AppQuery:tokensFromObjectArray (object[])) is not on the recorded stack. This is likely due to a runtime bug. The 15 frames are as follow:
[0x7000100bc000] Frame (0 / 15): (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo:InternalInvoke (System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
[0x7000100bc000] Frame (1 / 15): System.Reflection.RuntimeMethodInfo:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
[0x7000100bc000] Frame (2 / 15): System.Reflection.MethodBase:Invoke (object,object[])
[0x7000100bc000] Frame (3 / 15): System.Delegate:DynamicInvokeImpl (object[])
[0x7000100bc000] Frame (4 / 15): System.MulticastDelegate:DynamicInvokeImpl (object[])
[0x7000100bc000] Frame (5 / 15): System.Delegate:DynamicInvoke (object[])
[0x7000100bc000] Frame (6 / 15): TechTalk.SpecFlow.Bindings.BindingInvoker:InvokeBinding (TechTalk.SpecFlow.Bindings.IBinding,TechTalk.SpecFlow.Infrastructure.IContextManager,object[],TechTalk.SpecFlow.Tracing.ITestTracer,System.TimeSpan&)
[0x7000100bc000] Frame (7 / 15): TechTalk.SpecFlow.Infrastructure.TestExecutionEngine:ExecuteStepMatch (TechTalk.SpecFlow.Bindings.BindingMatch,object[])
[0x7000100bc000] Frame (8 / 15): TechTalk.SpecFlow.Infrastructure.TestExecutionEngine:ExecuteStep (TechTalk.SpecFlow.Infrastructure.IContextManager,TechTalk.SpecFlow.Bindings.StepInstance)
[0x7000100bc000] Frame (9 / 15): TechTalk.SpecFlow.Infrastructure.TestExecutionEngine:Step (TechTalk.SpecFlow.Bindings.StepDefinitionKeyword,string,string,string,TechTalk.SpecFlow.Table)
[0x7000100bc000] Frame (10 / 15): TechTalk.SpecFlow.TestRunner:When (string,string,TechTalk.SpecFlow.Table,string)
[0x7000100bc000] Frame (11 / 15): TechTalk.SpecFlow.Steps:When (string,string,TechTalk.SpecFlow.Table)
[0x7000100bc000] Frame (12 / 15): TechTalk.SpecFlow.Steps:When (string)
[0x7000100bc000] Frame (13 / 15): WellRx.UITests.Steps.DashboardSteps:GivenIAmOnTheHomePage ()
[0x7000100bc000] Frame (14 / 15): (wrapper dynamic-method) object:lambda_method (System.Runtime.CompilerServices.Closure,TechTalk.SpecFlow.Infrastructure.IContextManager)

bug test

Most helpful comment

I couldn’t find a Xamarin.UITest repository. I also raised a support ticket with App Center, and was told to just “thumbs up” 👍 this issue, so that it gets higher prioritised by the team.

All 87 comments

Thank you for reporting the bug with so much detail. I've created a bug for it.

Hi @Moshex
I have a same issue , so if you have any solution,please share me
Thanks you

Hi @Moshex
I have a same issue , so if you have any solution, please share me
Thanks you

I do not have a solution yet but based on what it stated it sounds like it is a bug with Xamrain uiTest and they need to fix it in a future release.

Hi @Moshex
so when you have solutions, can you post them to here? thanks you

Hi @Moshex
so when you have solutions, can you post them to here? thank you

@quangthaiaht
I will if I do, but as I stated this does not appear to be something that can not be fixed in code since it's an issue in the framework itself

@Moshex
i tried with a other app on android 10 devices then app.EnterText is still works. what do you think this issus.I thinks team dev customized object edittext, and it suits earlier android versions but it not suites with android 10

I'm the developer working with @Moshex - We did have a few minor customizations (for UI) with our Entry controls, so I removed all of them in a test branch - I stripped the entire page down to just a scrollview wrapping a stacklayout with 2 Entries and a few buttons on it - completely unstyled, unaltered.

@Moshex ran his automation tests again and had the exact same result. It will definitely take me some time, since I'm in the middle of a release, but I will do my best to make a reproduction solution. If someone has a sample app that is working, please provide that too, so we can analyze that.

i have a app, which is prove app.Entertext work on android 10 devices
You can see it at the link
https://github.com/quangthaiaht/test
If you encounter any difficulties, please add skype +841679099444 which is my phone number used to create skype nick
Thanks you

@quangthaiaht The app you linked us is just an APK, we need the application's full source code in order to know that the application has the same updates and packages that the application I am working on. As stated in the bug even my app used to work on API 29 but it stopped working after updating the application to be configured for the newest Android update, AKA API 29. Do you have a true sample application that is updated with the latest updates and the source code, not just an APK? This is so if it does work we are able to see the differences and fix our application accordingly.

I can not public source code the project but i realy with the file apk then app.Entertext work on android 10 devices

@quangthaiaht But the question of whether or not the APK that you have provided matches the preconditions for the bug that we are dealing with. This makes it not useful into tracking down what the issue is stemming from. Thank you for trying and track this down.

I have a repro here: https://github.com/getsentry/symbol-collector/pull/63

Basically ClearText focuses on the element but doesn't clear the text box. EnterText doesn't write the text but focuses too.

I've tested on a Samsung S10+ device.

Hi,
I have faced the exact same problem: updated an existing app to API 29, and both ClearText and EnterText fail both on local connected physical device, and emulators in App Center.
Waiting for a fix, I can provide a repro project and related UI tests if needed.

@Oddj0b

Thank you for reporting the bug with so much detail. I've created a bug for it.

Is this bug filed on GitHub? Is there a way for us to follow the progress?

I have the same issue on my Pixel (3a xl - Android 10).

Target Android Version: Android 10.0 (API Level 29 - Q).

All of my tests were able to run successfully with an earlier version.

On my Samsung S9 (Android 9) the isssue is not there.

After I set the Target Android Version to 9 EnterText works fine on both devices.

@bruno-garcia It's tracked internally.

@Oddj0b is there any news about this bug? Is ETA for it?

Any updates on this? I have the same problem enter en clear text not working on a samsung with android version 10. On my huawei with android version 9 I have no problems. However when I enter text with the adb command it works without any problem.

Any updates on this? I have the same problem enter en clear text not working on a samsung with android version 10. On my huawei with android version 9 I have no problems. However when I enter text with the adb command it works without any problem.

I have the same issue with Samsung Galaxy S9 (Android 10).

I am also having this issue with UITests in App Center. This basically renders UI testing of Android apps that have text fields (such as login) useless.
Is there any work around?

You could introduce backdoors to replace your login process, see here: https://docs.microsoft.com/en-us/appcenter/test-cloud/uitest/working-with-backdoors

The point is that if after the login there is another text-box, you'll face again the problem.

The only other solution is that this bug gets fixed.

@curia-damiano Thanks, yes I am currently using backdoors at the moment to simulate picking images, however if I have to use backdoors for every text box, the gets a bit cumbersome, as well as remove part of the reason UI tests exists, to test UI elements, such as text boxes.
Thanks for your suggestion :)

Does anyone know who the Microsoft representative is on this ticket, if there is one?

I have the same problem. Even with the repl I can not enterText in Entry.

Do you notify Xamarin.UITest repository ?

I couldn’t find a Xamarin.UITest repository. I also raised a support ticket with App Center, and was told to just “thumbs up” 👍 this issue, so that it gets higher prioritised by the team.

Internal Tracking ID - AZD 72482

The latest release 3.0.8-dev1 does not fix the issue. Are there any kind of clues on why this does not work ? I can provide another type of repro using Uno Platform, if that helps.

@jeromelaban Sadly even with many repros, this issue has been ignored by appcenter folks for months. I've also brought this up on the Xamarin slack server, appcenter channel without reply. I'll reach out through zendesk.

I have received updated info that it is at the top of the ready to work list..

Our engineers are working on it but but we don't have an estimate on a fix right now. We will let you know once the fix is in place. We are sorry for the inconvenience.

Just discovered this issue today: I have been using an Android Pixel 3a running api 29 for UI tests in App Center, but locally I run UI tests on a physical LG V20 running api 26. I added a test today that needs to enter text in an entry and an editor field, and sure enough, no text gets entered if the Android device is running api 29.

I've confirmed that the issue happens on a local emulator as well, and I have also confirmed that the issue is not there if you use an emulator running api 28.

As a work-around until this issue is resolved, I will be creating a new device-set in App Center with an Android device running api 28 rather than 29. Hopefully something like this will get most people by until the real issue is resolved.

Same problem here. I recognized a java.lang.NoSuchFieldException in the logcat during my UITest where entering text failed. Maybe this is a hint for the guys who are about to fix that issue:

 I System.out: URI: /
 I System.out: params: {json={"command":"keyboard_enter_text","arguments":["Hallo"]}
 I System.out: }
 I System.out: header: {content-type=application/json; charset=utf-8, connection=Keep-Alive, expect=100-continue, host=127.0.0.1:53445, content-length=55}
 I System.out: params: {json={"command":"keyboard_enter_text","arguments":["Hallo"]}
 I System.out: }
 I System.out: ProP json = {"command":"keyboard_enter_text","arguments":["Hallo"]}
 I System.out: files: {}
 I System.out: command: {"command":"keyboard_enter_text","arguments":["Hallo"]}
 I InstrumentationBackend: Got command:'Command:'Line:null,keyboard_enter_text', arguments:'[Hallo]'
 W f.tgm.ticketap: Accessing hidden field Landroid/view/inputmethod/InputMethodManager;->mServedView:Landroid/view/View; (greylist-max-p, reflection, denied)
 W System.err: java.lang.RuntimeException: sh.calaba.instrumentationbackend.actions.text.InfoMethodUtil$UnexpectedInputMethodManagerStructureException: java.lang.NoSuchFieldException: No field mServedView in class Landroid/view/inputmethod/InputMethodManager; (declaration of 'android.view.inputmethod.InputMethodManager' appears in /system/framework/framework.jar!classes3.dex)
 W System.err: <09>at sh.calaba.instrumentationbackend.actions.text.TextAction.execute(TextAction.java:44)
 W System.err: <09>at sh.calaba.instrumentationbackend.Command.execute(Command.java:47)
 W System.err: <09>at sh.calaba.instrumentationbackend.actions.HttpServer.runCommand(HttpServer.java:787)
 W System.err: <09>at sh.calaba.instrumentationbackend.actions.HttpServer.serve(HttpServer.java:767)
 W System.err: <09>at sh.calaba.instrumentationbackend.actions.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:487)
 W System.err: <09>at java.lang.Thread.run(Thread.java:919)
 W System.err: Caused by: sh.calaba.instrumentationbackend.actions.text.InfoMethodUtil$UnexpectedInputMethodManagerStructureException: java.lang.NoSuchFieldException: No field mServedView in class Landroid/view/inputmethod/InputMethodManager; (declaration of 'android.view.inputmethod.InputMethodManager' appears in /system/framework/framework.jar!classes3.dex)
 W System.err: <09>at sh.calaba.instrumentationbackend.actions.text.InfoMethodUtil.getServedView(InfoMethodUtil.java:29)
 W System.err: <09>at sh.calaba.instrumentationbackend.actions.text.TextAction.execute(TextAction.java:28)
 W System.err: <09>... 5 more
 W System.err: Caused by: java.lang.NoSuchFieldException: No field mServedView in class Landroid/view/inputmethod/InputMethodManager; (declaration of 'android.view.inputmethod.InputMethodManager' appears in /system/framework/framework.jar!classes3.dex)
 W System.err: <09>at java.lang.Class.getDeclaredField(Native Method)
 W System.err: <09>at sh.calaba.instrumentationbackend.actions.text.InfoMethodUtil.getServedView(InfoMethodUtil.java:22)
 W System.err: <09>... 6 more
 I System.out: result:{ "bonusInformation":[ "Exception stack trace:\n java.lang.RuntimeException: sh.calaba.instrumentationbackend.actions.text.InfoMethodUtil$UnexpectedInputMethodManagerStructureException: java.lang.NoSuchFieldException: No field mServedView in class Lan
droid/view/inputmethod/InputMethodManager; (declaration of 'android.view.inputmethod.InputMethodManager' appears in /system/framework/framework.jar!classes3.dex)\n
\tat sh.calaba.instrumentationbackend.actions.text.TextAction.execute(TextAction.java:44)\n\tat sh.calaba.instrumentationbackend.Command.
execute(Command.java:47)\n\tat sh.calaba.instrumentationbackend.actions.HttpServer.runCommand(HttpServer.java:787)\n\tat sh.calaba.instrumentationbackend.actions.HttpServer.serve(HttpServer.java:767)\n\tat sh.calaba.instrumentationbackend.actions.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:487)\n\tat j
ava.lang.Thread.run(Thread.java:919)\nCaused by: sh.calaba.instrumentationbackend.actions.text.InfoMethodUtil$UnexpectedInputMethodManagerStructureException: java.lang.NoSuchFieldException: No field mServedView in class Landroid/view/inputmethod/InputMethodManager; (declaration of 'android.view.inpu
tmethod.InputMethodManager' appears in /system/framework/framework.jar!classes3.dex)\n\tat sh.calaba.instrumentationbackend.actions.text.InfoMethodUtil.getServedView(InfoMethodUtil.java:29)\n\tat sh.calaba.instrumentationbackend.actions.text.TextAction.execute(TextAction.java:28)\n\t... 5 more\nCaus
ed by: java.lang.NoSuchFieldException: No field mServedView in class Landroid/view/inputmethod/InputMethodManager; (declaration of 'android.view.inputmethod.InputMethodManager' appears in /system/framework/framework.jar!classes3.dex)\n\tat java.lang.Class.getDeclaredField(Native Method)\n\tat sh.cal
aba.instrumentationbackend.actions.text.InfoMethodUtil.getServedView(InfoMethodUtil.java:22)\n\t... 6 more\n"
],
"message":"sh.calaba.instrumentationbackend.actions.text.InfoMethodUtil$UnexpectedInputMethodManagerStructureException: java.lang.NoSuchFieldException: No field mServedView in class Landroi
d/view/inputmethod/InputMethodManager; (declaration of 'android.view.inputmethod.InputMethodManager' appears in /system/framework/framework.jar!classes3.dex)",
"success":false
}

EnterText works on API28
EnterText doesn't work on API29
Downgrade to API28 is my workaround.

When you are testing locally with a emulator you should have no issues downgrading.
When you use a physical device that is upgraded to API29 you have a problem.
I'm not sure about Cloud-Test, can you choose the API level of the devices there?

Yes, @michaelulmer - You can create basically any kind of device you want. Here's a screenshot of my "device sets" in app center. You can see my two sets (each 'set' includes just one device in this case) here... An Pixel 3a running Android 10 was my initial device, which shows the problem. The second device you see is my newer device set, with a Pixel 3a running Android 9, which does not have the enter-text problem:

image

Hello, I search any solutions about this issue, have you receive an update about this ?

Hi Guys,
I applied in app.Query(e => e.Marked("lblUsername").Invoke("setText", "username")); way for andriod API 29. It's work for me.

Ok it's work but it's not good way to do.
So I think we must use the method clearText and enterText.
Thanks you

[Update] in search Bar with app.Query(e => e.Marked("lblUsername").Invoke("setText", "username")); the event on text changed is not working.
[UPDATE] I Found solution with app.PressedEnter().

I'm waiting the fix for use app.EnterText with android api 29.

I have the same issue. Xamarin guys - any update as to a fix? All my user interface unit tests on android 10 are not working right now.

+1

[Update] in search Bar with app.Query(e => e.Marked("lblUsername").Invoke("setText", "username")); the event on text changed is not working.
[UPDATE] I Found solution with app.PressedEnter().

I'm waiting the fix for use app.EnterText with android api 29.

Hi @CorentinRobertSmood can you give sample how you fixed it? Its not working still in searchbar. I am unable to enter any text in searchBar

[Update] in search Bar with app.Query(e => e.Marked("lblUsername").Invoke("setText", "username")); the event on text changed is not working.
[UPDATE] I Found solution with app.PressedEnter().
I'm waiting the fix for use app.EnterText with android api 29.

Hi @CorentinRobertSmood can you give sample how you fixed it? Its not working still in searchbar. I am unable to enter any text in searchBar

I don't think the solution posted there is a true solution, at the end of the day we really just need the bug to be fixed.

[Update] in search Bar with app.Query(e => e.Marked("lblUsername").Invoke("setText", "username")); the event on text changed is not working.
[UPDATE] I Found solution with app.PressedEnter().
I'm waiting the fix for use app.EnterText with android api 29.

Hi @CorentinRobertSmood can you give sample how you fixed it? Its not working still in searchbar. I am unable to enter any text in searchBar

I don't think the solution posted there is a true solution, at the end of the day we really just need the bug to be fixed.

Agreed, part of our UI testing is testing different android versions, and at the moment Android 10 is untestable with this bug.

Agreed, Its been more than 6 months since bug is reported and acknowledged. Not sure what's the plan from Xamarin.UITest team apart from May month update that "they are working on fix". Please do let us know any update guys. Thanks

[Update] in search Bar with app.Query(e => e.Marked("lblUsername").Invoke("setText", "username")); the event on text changed is not working.
[UPDATE] I Found solution with app.PressedEnter().
I'm waiting the fix for use app.EnterText with android api 29.

Hi @CorentinRobertSmood can you give sample how you fixed it? Its not working still in searchbar. I am unable to enter any text in searchBar

I'm sorry for time to my response, in your searchbar you can add method SearchButtonPressed="SearchBar_OnSearchButtonPressed" and when you press enter you can invoke this method

[Update] in search Bar with app.Query(e => e.Marked("lblUsername").Invoke("setText", "username")); the event on text changed is not working.
[UPDATE] I Found solution with app.PressedEnter().
I'm waiting the fix for use app.EnterText with android api 29.

Hi @CorentinRobertSmood can you give sample how you fixed it? Its not working still in searchbar. I am unable to enter any text in searchBar

I don't think the solution posted there is a true solution, at the end of the day we really just need the bug to be fixed.

I agree but if you need UI tests you must make UI Test works on iOS and Android, and i search any solutions for by pass this bug.

Agreed, Its been more than 6 months since bug is reported and acknowledged. Not sure what's the plan from Xamarin.UITest team apart from May month update that "they are working on fix". Please do let us know any update guys. Thanks

I hope seriously the bug will fix ! it's too bad it's works in API 28 and not for 29 and 30 ...

I have no idea why the issue in Xamarin UITest (Xamarin.Forms - https://github.com/xamarin/Xamarin.Forms/issues/11356) was closed and this one was left open. The bug is not related to appcenter but is a general Xamarin UITest issue. This is basic functionality that is not working for 8 months since reported!

The other issue has been open under Xamarin.Forms, but Xamarin.UITest is not part of Forms

Any news on this? This is very basic functionality and it would be good to have it working without ugly workarounds.

This workaround fixed it for me:

private void EnterTextInEntry(string text)
{
    if (OnAndroid)
    {
        app.Query(x => x.Marked("YourAutomationId").Invoke("setText", text));
    }
    else
    {
        app.EnterText(text);
    }
}

Thanks for that @JFMG !

Xamarin Test Cloud team is fully focused on Android 11 validation at this moment.
Once Android 11 support will be officially provided for Xamarin.UITest - the team will immediately start the implementation of the Android 10 Text Input fix.
Sorry for the inconvenience!

@yutingMS is there any scheduled date when this is going to be fixed ? thanks

Hi JFMG, your workaround works perfectly for me ... except for WebView where the Invoke method does not exist.
Any idea on how to make it work with WebViews ?

@spineau59 I think you should not UI test the web view. There are other UI test frameworks for the web like mocha. If you need data from this web view, then you should mock them for the UI test.

JFMG, I have a Xamarin Android Application where the user authentication is managed through a Webview. My tests have to do the authentication before testing any other UI components.

As I said: I suggest you to mock your data. Please open a new discussion on StackOverflow for more support. This issue is about the EnterText method bug for UI tests.

I would expect the following code to work
app.EnterText(c => c.Css("input#UserCode"), "myusername");
So I think, this is related to EnterText also.

https://stackoverflow.com/questions/56816609/not-able-to-enter-text-in-an-textfield-in-xamarin-uitest-using-android-phone

Finally, I have found the workaround that works for me (WebForm) below

app.Query (w => w.WebView().InvokeJS ("return document.getElementById('UserCode').setAttribute('value', 'myusername')")) 

It seems like this issue isn't being prioritised right now. I'm using an extension method override in the meantime, to get around it.

   public static void EnterText(this IApp app, string marked, string text, bool onAndroid)
        {
            if (onAndroid)
            {
                app.Query(e => e.Marked(marked).Invoke("setText", text));
            }
            else
            {
                app.EnterText(marked, text);
            }
        }

The workaround works for Android 10. But yes, we do need the bug fixed.
Hopefully they focused on the Android 11 validation and FULLY TEST IT! A bug like that should never exist in the first place, I am just wondering what was tested for the Android 10 validation, apparently not the basics.

@Rangyia Its good to know that its working for you but are you sure? Have you tried this in Appcenter? Thanks.

If this issue goes by just because of using Android 10 build tools or something, then its surprising no one from Appcenter team informed here till now.

Until Xamarin.Android 10.2, by default Android SDK Platform tools and build tools were still using Android 9 (API 28). Only after Xamarin.Android 10.3, default platform tools and build tools version were changed to Android 10 (API 29).

Our app is using Xamarin.Android 10.1 only till now.

I will try it later this weekend. Meanwhile anyone using Xamarin.Android 10.3 and above can confirm app.EnterText() is working fine?

It should be fixed now for tests running in Test Cloud. If you want to run it locally you need to execute this on your device:
adb -s <SERIAL> shell settings put global hidden_api_policy 1.

Please let us know if you're still experiencing this issue.

@sergei-fedorov , That command is going to be needed from now on to be able to run the tests locally on API 29 and hier? is there any chance that it will not require that in the future? or it would just be a setting in the dev options?

It should be fixed now for tests running in Test Cloud. If you want to run it locally you need to execute this on your device:
adb -s <SERIAL> shell settings put global hidden_api_policy 1.

Please let us know if you're still experiencing this issue.

Just tried to run a UI Test in AppCenter (against an Android 10 device) and getting the same error as before.

Edit: for more context, we ran the test (which attempts to find and enter text in to a Entry element) against the Google Pixel 3 (Android 10)

Thank you

@justinhorner The command adb -s <SERIAL> shell settings put global hidden_api_policy 1. worked for me with of course replacing "SERIAL" with your device's "SERIAL" (like this adb -s 1A2B3B3R3 shell settings put global hidden_api_policy 1)and you need to update Xamrin UI test to version 3.0.9. This seems to work for me so far, I will keep testing to make sure.

@justinhorner The command adb -s <SERIAL> shell settings put global hidden_api_policy 1. worked for me with of course replacing with your device's and you need to update Xamrin UI test to version 3.0.9. This seems to work for me so far, I will keep testing to make sure.

@Moshex I was trying to run the UITest in the test Cloud (AppCenter). We have not updated to UITest 3.0.9 (I didn't notice that in sergei's original message). I will upgrade the UITest package and try again in the TestCloud.

@sergei-fedorov So far the "app.EnterText" is looking good for API 29 and 30, my only issue that I am hoping you can help is now I am seeing the scrolling up and down on the google pixel 3 with API 30 is super slow like on the Samsung devices, is this the standard now for android and will it ever be fixed?

So we upgraded the Xamarin.UITests package to 3.0.9 and getting the same failure (UITest is unable to find the Entry element and enter text) on Google Pixel 3 running Android 10. Issue does not seem to be resolved in AppCenter UI tests, haven't tried locally (since we rely on AppCenter Tests)

I tried the same locally a few days ago @justinhorner and the issue remains.

I can reproduce issue with Android 11 also. Not entering text in it

Xamarin.Uitest Version 3.0.11 used.

Why they are not fixing this basic uitest control?

After much debugging on this topic, and going through old app versions here is some extra insight that may lead to a solution for the Xamarin.UITest team.

With our Android version of the application, back in July 2020, when we updated our targeted SDK in our Xamarin.Android project, to target Android 10 (API 29), this actually broke the entering of text for Android 10 (same with Android 11). Of course, there may have been some Xamarin.Android NuGet packages updated as well in that time frame.

Furthermore, this seems ambiguous, but when we were targeting Android 9 (API 28), and built the app with that configuration, entering text ACTUALLY works for Android 10 (API 29) which seems completely odd.

Conclusion, the issue may not necessarily be in Xamarin.UITest, just another potential factor to cross off if it actually has to do with Xamarin.Android. This is also still an issue for us with the latest Xamarin.UITest versions for Android 10/11.

After much debugging on this topic, and going through old app versions here is some extra insight that may lead to a solution for the Xamarin.UITest team.

With our Android version of the application, back in July 2020, when we updated our targeted SDK in our Xamarin.Android project, to target Android 10 (API 29), this actually broke the entering of text for Android 10 (same with Android 11). Of course, there may have been some Xamarin.Android NuGet packages updated as well in that time frame.

Furthermore, this seems ambiguous, but when we were targeting Android 9 (API 28), and built the app with that configuration, entering text ACTUALLY works for Android 10 (API 29) which seems completely odd.

Conclusion, the issue may not necessarily be in Xamarin.UITest, just another potential factor to cross off if it actually has to do with Xamarin.Android. This is also still an issue for us with the latest Xamarin.UITest versions for Android 10/11.

Is there any way to escalate as Top Priority ?

@mahesh-kumbhar That's a great point. I don't work for Xamarin unfortunately, so IDK their priority model.

However, there seems to be a good demand for a solution for this. Have you put in a support ticket or anything, or does support route you back to here?

++ > app.Query(e => e.Marked(marked).Invoke("setText", text));
Works with Class => "androidx.appcompat.widget.AppCompatEditText", :) 👍
Query for Marked("edit_card_name").Invoke("setText", "content") gave 1 results.
[
[0] ""
]

does not work with below class type :( 👎
Class => "FD.Droid.Shared.ClearableEditText",
[
[0] {
receiverString => [

    ],
    methodName => [

    ],
    error => [

    ],
    receiverClass => [

    ]
}

]

Yeah this bug is annoying, still waiting for a fix.

It will be quite helpful for us if this bug is fixed soon.

It will be quite helpful for us if this bug is fixed soon.

Hi @abhisheksurya

If you try with Latest Xamarin.UiTest For Cloud Execution. It's working But For Local Device or Simulator still its not working

It will be quite helpful for us if this bug is fixed soon.

Hi @abhisheksurya

If you try with Latest Xamarin.UiTest For Cloud Execution. It's working But For Local Device or Simulator still its not working

Thanks and we need it to work for devices and simulators as well.

This is working for my devices locally. For those saying it is not working, have you run the command? -
adb -s <SERIAL> shell settings put global hidden_api_policy 1
Replacing with the connected devices serial ID.

This is working for my devices locally. For those saying it is not working, have you run the command? -
adb -s <SERIAL> shell settings put global hidden_api_policy 1
Replacing with the connected devices serial ID.

This workaround is working for my local devices too. However it is not applicable in all cases, so the issue still needs to be fixed.

Oh look another of those hundreds of issues that could be fixed if this was open source, we can only +1 here

Are there any updates on the .EnterText() not working for Android API level 30? The workaround does not work for me on android API level 30. Does anyone know of a workaround for API level 30?

I think we can safely assume that this is never going to be fixed for Android 10:
Xamarin.UITest 3.0.18 - Changelog

It doesn't work for me on Android 11 as well (regardless or what change log is saying) - tested with latest 3.1.0. Xamarin, it's been a year and half and this very important UI testing feature is still broken? Woot?

I don't think they do anything to Appcenter (or UI test framework) at all. Feels like it's abandoned. But would be good to know if it's for good, or if they (MS) plan to introduce some replacement products. If not, it might be time to look in other directions...

Was this page helpful?
0 / 5 - 0 ratings