-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Espresso Tests fail on Android 11 #751
Comments
This is still happening on the latest alpha release
|
seeing the same issue, also launching a dialog on a fragment |
it's happing with me also even in Api 29 |
I'm using onView(allOf(withText(text)))
.inRoot(isDialog())
.check(matches(isDisplayed())) |
Still happening (Android 11 only!) with androidx.test 1.4.0 / espresso 3.4.0 / target API 30 / compile SDK 31. |
Workaround: put a Thread.sleep(2000) to the setup part of the test to provide enough time to restart the app between the test cases. |
I was also facing issues with test cases related to Alerts and Dialog windows with Android 30 SDK. The exceptions I observed were java runtime exceptions and were related to no window focus on root view, no matching root found etc. I upgraded androidx.test and espresso to 1.4.0-alpha04 and 3.4.0-alpha04 respectively. And running the tests on Android 11.0 (API 30) devices. To resolve the issue, I modified test cases to use idling resources in setup method and also included thread.sleep as necessary. This link below provides details on these settings for espresso multi-window support. This resolved the runtime exceptions in my case. I hope this helps others too! |
It worked for me , inRoot(isDialog()) onView(allOf(withText(text))) |
Face the same issue asserting text view inside
Note: Kako's Edit: after this change, the test still fails intermittently. |
It works fine for me when I use "it.inRoot { isDialog() } " only on customised alerts, but I still see issue with Android native alerts. Did any one manage to fix it for native alerts? |
@kuuuurt We have tests that are running on API 31 that we're seeing almost the exact same stacktrace for and the behavior is not consistent. Many times the tests will run without issues but sometimes those errors will pop up with the same stacktrace. Because we're running on a CI server and the failures are not consistent, I've never actually witnessed the failure occur. I think we are seeing these when trying to test dialogs or dialog fragments. The thing I'm having trouble understanding is if this error is thrown before our test code is even run. Usually if an Espresso test fails I'll see some indication that some of my test's steps were run from the stacktrace e.g. I'll see an espresso log for a button being clicked and then I'll see some sort of failure but the stacktrace at least includes some Espresso actions that I've coded. In this case I don't see the same thing happening. When your tests fail with that stacktrace, are you able to determine if your: |
What I have observed the button in the dialogue fragment is visible but the test fails to click it. |
Ok. I looked deeper into my logcat for the error I'm seeing. In my test, we create a fragment using FragmentScenario, then once it's created, the first thing we attempt to do is call:
I noticed in my logs that I get the following output after calling closeSoftKeyboard(): `08-23 23:44:29.917 6274 6328 W .moc: Accessing hidden method Landroid/hardware/input/InputManager;->getInstance()Landroid/hardware/input/InputManager; (unsupported, reflection, allowed) 08-23 23:44:29.917 6274 6328 W .moc: Accessing hidden method Landroid/hardware/input/InputManager;->injectInputEvent(Landroid/view/InputEvent;I)Z (unsupported, reflection, allowed) 08-23 23:44:29.917 6274 6328 W .moc: Accessing hidden field Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I (unsupported, reflection, allowed) 08-23 23:44:29.933 6274 6274 W .moc: Accessing hidden method Landroid/os/MessageQueue;->next()Landroid/os/Message; (unsupported, reflection, allowed) 08-23 23:44:29.933 6274 6274 W .moc: Accessing hidden field Landroid/os/MessageQueue;->mMessages:Landroid/os/Message; (unsupported, reflection, allowed) 08-23 23:44:29.934 6274 6274 W .moc: Accessing hidden method Landroid/os/Message;->recycleUnchecked()V (unsupported, reflection, allowed) 08-23 23:44:29.936 6274 6274 W .moc: Accessing hidden method Landroid/view/WindowManagerGlobal;->getInstance()Landroid/view/WindowManagerGlobal; (unsupported, reflection, allowed) 08-23 23:44:29.937 6274 6274 W .moc: Accessing hidden field Landroid/view/WindowManagerGlobal;->mViews:Ljava/util/ArrayList; (unsupported, reflection, allowed) 08-23 23:44:29.937 6274 6274 W .moc: Accessing hidden field Landroid/view/WindowManagerGlobal;->mParams:Ljava/util/ArrayList; (unsupported, reflection, allowed 08-23 23:44:29.939 6274 6274 D RootViewPicker: Root not ready - waiting: 10ms for one to appear. 08-23 23:44:30.004 6274 6274 D RootViewPicker: Root not ready - waiting: 25ms for one to appear. 08-23 23:44:30.031 1355 1355 I GoogleInputMethodService: GoogleInputMethodService.onFinishInput():3420 08-23 23:44:30.031 1355 1355 I GoogleInputMethodService: GoogleInputMethodService.onStartInput():2002 08-23 23:44:30.032 1355 1355 I DeviceUnlockedTag: DeviceUnlockedTag.notifyDeviceLockStatusChanged():31 Notify device unlocked. 08-23 23:44:30.093 6274 6274 D RootViewPicker: Root not ready - waiting: 50ms for one to appear. 08-23 23:44:30.154 6274 6274 D RootViewPicker: Root not ready - waiting: 100ms for one to appear. 08-23 23:44:30.264 6274 6274 D RootViewPicker: Root not ready - waiting: 200ms for one to appear. 08-23 23:44:30.484 6274 6274 D RootViewPicker: Root not ready - waiting: 400ms for one to appear. 08-23 23:44:30.893 6274 6274 D RootViewPicker: Root not ready - waiting: 800ms for one to appear. 08-23 23:44:31.793 6274 6274 D RootViewPicker: Root not ready - waiting: 1000ms for one to appear. 08-23 23:44:32.845 6274 6274 D RootViewPicker: Root not ready - waiting: 1000ms for one to appear. 08-23 23:44:33.867 6274 6274 D RootViewPicker: Root not ready - waiting: 1000ms for one to appear. 08-23 23:44:34.872 6274 6274 D RootViewPicker: Root not ready - waiting: 1000ms for one to appear. The Espresso implementation for closeSoftKeyboard() is:
So I think the onView(isRoot()) part must be what's causing this issue. I have no idea why it is intermittent though. |
i have solved such issue by my own solution in Ultron framework(you can check realisation there). You can find an answer here: https://github.com/open-tool/ultron/wiki/Avoiding-nontrivial-element-lookup-exceptions |
Description
I have integration tests running from API 21 to API 29. I've been trying to update our app to target API 30 but the tests are flaky just on API 30.
Steps to Reproduce
RootMatchers.isDialog()
but the same behavior.Expected Results
This works perfectly from API 21 to API 29. It should also work in API 30. I also turned off all the compatibility changes just to check and it still is happening.
Actual Results
Runtime Exception:
AndroidX Test and Android OS Versions
AndroidX Test: 1.3.0
Espresso: 3.3.0
Android OS: Android 11 (API 30)
The text was updated successfully, but these errors were encountered: