Espresso:验证一个或多个 listView 项目是否包含带有子字符串的项目
Espresso: Verify if one or more listView items contains an item with a substring
我必须验证一个项目中的子字符串是否包含在列表视图中。问题是,如果不止一项包含此子字符串 - 将抛出 matching 错误。
有没有一种像 Robotium 一样干净的浓缩咖啡方式来获取匹配的第一个项目?
您应该看看 withChild 和 withParent 方法。
像这样:
onView(allOf(withText("your_substring"), withParent(withId(R.id.element_id_here))));
应该可以。
我必须验证一个项目中的子字符串是否包含在列表视图中。问题是,如果不止一项包含此子字符串 - 将抛出 matching 错误。
有没有一种像 Robotium 一样干净的浓缩咖啡方式来获取匹配的第一个项目?
您应该看看 withChild 和 withParent 方法。
像这样:
onView(allOf(withText("your_substring"), withParent(withId(R.id.element_id_here))));
应该可以。