Espresso: Why don't spinners close after selection?

后端 未结 1 1502
后悔当初
后悔当初 2021-01-15 02:03

I have a question about selecting items in Spinners with Espresso. Or to be more exact: The selection works, but after that the view assertions fail because the spinner is s

相关标签:
1条回答
  • 2021-01-15 02:42

    You have to click on the spinner first, use this code:

    @Test
    public void selectDogs() throws Exception {
        onView(withId(R.id.spinner)).perform(click());
        onData(allOf(is(instanceOf(String.class)), is("dogs")))
                .perform(click());
        onView(withId(R.id.selected)).check(matches(withText("dogs")));
    }
    
    0 讨论(0)
提交回复
热议问题