Home:ALL Converter>How do I test for text in multiple rows of an android ListView?

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

Ask Time:2021-09-22T05:28:47         Author:rawbee

Json Formatter

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")))

Author:rawbee,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275753/how-do-i-test-for-text-in-multiple-rows-of-an-android-listview
yy