Я пробую новую библиотеку для тестирования Android Espresso.Когда я пытаюсь:
fun test () {
onView(
allOf(withId(R.id.edDeliveryAndCase),
childAtPosition(
childAtPosition(
withClassName(`is`("android.widget.LinearLayout")),
1),
0),
isDisplayed()))
.perform(click())
onView(
allOf(withId(R.id.edDeliveryAndCase),
childAtPosition(
childAtPosition(
withClassName(`is`("android.widget.LinearLayout")),
1),
0),
isDisplayed()))
.perform(typeText("08400043880000166775"), closeSoftKeyboard())
onView(
allOf(withId(R.id.edDeliveryAndCase), withText("08400043880000166775"),
childAtPosition(
childAtPosition(
withClassName(`is`("android.widget.LinearLayout")),
1),
0),
isDisplayed()))
.perform(pressImeActionButton())
onView(
allOf(withId(R.id.edPartNumber),
childAtPosition(childAtPosition(
withClassName(`is`("android.support.v7.widget.CardView")),
0),
0),
isDisplayed()))
.perform(typeText("NBL-004"), closeSoftKeyboard())
onView(
allOf(withId(R.id.edPartNumber), withText("NBL-004"),
childAtPosition(
childAtPosition(
withClassName(`is`("android.support.v7.widget.CardView")),
0),
0),
isDisplayed()))
.perform(pressImeActionButton())
onView(
allOf(withId(R.id.edAcceptQty),
childAtPosition(
childAtPosition(
withClassName(`is`("android.widget.LinearLayout")),
1),
0),
isDisplayed()))
.perform(replaceText("5"), closeSoftKeyboard())
onView(
allOf(withId(R.id.edAcceptQty), withText("5"),
childAtPosition(
childAtPosition(
withClassName(`is`("android.widget.LinearLayout")),
1),
0),
isDisplayed()))
.perform(pressImeActionButton())
}
private fun childAtPosition(
parentMatcher: Matcher<View>, position: Int): Matcher<View> {
return object : TypeSafeMatcher<View>() {
override fun describeTo(description: Description) {
description.appendText("Child at position $position in parent ")
parentMatcher.describeTo(description)
}
public override fun matchesSafely(view: View): Boolean {
val parent = view.parent
return (parent is ViewGroup && parentMatcher.matches(parent)
&& view == parent.getChildAt(position))
}
}
}
я получаю сообщение об ошибке:
android.support.test.espresso.NoMatchingViewException: не найдено представлений в иерархиисоответствия: (с id: com.unitedtractors.warehouse.dev:id/edPartNumber и Child в позиции 0 в родительском Child в позиции 0 в родительском с именем класса: is "android.support.v7.widget.CardView" и отображается наэкран пользователю)
Есть идеи?