I have an LinearLayout, in which I add and remove view programmatically. But I add not a particularly view, instead I add ConstraintLayout with other view, that I need to test. So here in ConstaintLayout places EditText, which I want to test, type and check values, rest EditText. But I don't know how to get EditText with Espresso. I supposed that should work like this:
@Test
fun basicConverting() {
onView(
allOf(
withParent(withId(R.id.convertingViewList)),
withParentIndex(0),
withParent(withId(R.id.convertingView)),
withParentIndex(1)
)
).perform(typeText("12"))
}
But I get an error:
androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (view.getParent() view.getId() is <2131296372/com.human_developing_soft.unitconverter:id/convertingViewList> and (view.getParent() is an instance of android.view.ViewGroup and is at child index <0>) and view.getParent() view.getId() is <2131296684/com.human_developing_soft.unitconverter:id/convertingView> and (view.getParent() is an instance of android.view.ViewGroup and is at child index <1>)) If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:androidx.appcompat.widget.AppCompatSpinner{8f3246f VFED..CL. ........ 597,45-1035,113 #7f09019c app:id/unit_first_selector}
Please, help solve it. Thanks in advance!