Updating an EditText with Espresso

前端 未结 5 1562
慢半拍i
慢半拍i 2020-12-30 19:00

I\'m attempting to update an EditText as part of an Espresso test with:

onView(allOf(withClassName(endsWith(\"EditText\")), withText(is(\"Test\"         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-30 19:51

    You could try two things. First I would try to use

    onView(withId().perform... 
    

    This way you would always have access to the EditText field even when other EditText fields are on the screen.

    If that's not an option, you could split up your perform calls.

    onView(allOf(withClassName(endsWith("EditText")),withText(is("Test")))).perform(clearText());
    onView(withClassName(endsWith("EditText"))).perform(click());
    onView(withClassName(endsWith("EditText"))).perform(typeText("Another Test");
    

提交回复
热议问题