Problem: I had a problem starting the Espresso test after the call (click ()) method is called on the login button, the test continues to work, but does not go on until 45 seconds have passed, and the test will automatically fail. Meanwhile, registration usually happens.
Context: I have activity with two fragments side by side, the fragment on the right handles the EditTexts username and password, as well as the login button. This fragment is built using ViewAnimator and two LinearLayouts in the form of children's representations, the first LinearLayout has the elements mentioned above, and the second has another.
This is what happens in the user interface when the login button is clicked:
@Override public void setUILoggingIn() { spinnerLogin.setVisibility(View.VISIBLE); loginButton.setEnabled(false); loginButton.setText(R.string.logging_in); usernameText.setEnabled(false); passwordText.setEnabled(false); }
After authentication with the server, I process the user interface:
@Override public void setUIAuthorized() { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { viewAnimator.showNext();
Espresso test
ViewInteraction loginButton2 = onView(withId(R.id.login_button)); loginButton2.perform(click()); // Test gets stuck here. loginButton2.check(doesNotExist()); // Never reached.
Does anyone know that you need to successfully test this scenario? It would be enough to detect when the ViewAnimator changes, but the test is stuck on a click.
Also: This was not the beginning of the test, before the code shown earlier, I run this test and it works like a dream:
ViewInteraction loginButton = onView(withId(R.id.login_button)); loginButton.perform(click()); ViewInteraction snackBarTextView = onView( allOf(withId(R.id.snackbar_text), withText("Login error"), isDisplayed())); snackBarTextView.check(matches(withText("Login error")));
Thank you all for your help and any advice 🌚😄