I do not quite understand the principle of the method presented in the off- withItemContent . By copying the method itself from here off example

I am trying to call the resources I need in the text as follows:

  onData(withItemContent("Accounts")) .inAdapterView(withId(android.R.id.list)) .atPosition(1) .check(ViewAssertions.matches(isDisplayed())) 

In this case, I need to check not only the position, but also the text. For example, this implementation works without problems, but here I do not check the text:

 onData(anything()) .inAdapterView(withId(android.R.id.list)) .atPosition(1) .perform(click()) pressBack() 

    1 answer 1

    What prevents you from checking the text in the second method just by adding it:

      .check(ViewAssertions.matches(hasDescendant(withText("text"))))