How do I test for text in multiple rows of an android ListView?

Viewed 16

I am trying to verify the contents of two rows of a ListView with Espresso in the code snippet below, but only one works at a time, i.e. they both work when I comment the other one out. How do I check both rows?

onData(anything()).inAdapterView(withId(R.id.my_listview))
  .atPosition(0)
  .check(matches(withText("first row")))

onData(anything()).inAdapterView(withId(R.id.my_listview))
  .atPosition(1)
  .check(matches(withText("second row")))
0 Answers
Related