Testing EditText errors with Espresso on Android

前端 未结 2 600
抹茶落季
抹茶落季 2021-02-19 04:51

I want to test if an EditText field has an error (set with editText.setError(\"Cannot be blank!\")).

I\'ve created an Espresso test case with the new AndroidStu

相关标签:
2条回答
  • 2021-02-19 05:40

    You change editText.check(matches(isDisplayed())); to editText.check(matches(hasErrorText("Cannot be blank!")));

    0 讨论(0)
  • 2021-02-19 05:43

    This worked for me under

            onView(withId(R.id.signin_email)).check(matches(hasErrorText("Email not valid")));
    
    0 讨论(0)
提交回复
热议问题