嵌套式RecyclerView的Espresso Matcher [英] Espresso Matcher for Nested RecyclerView
问题描述
这是我的层次结构的细分:
So here's a breakdown of my hierarchy:
RecyclerView --> LinearLayout --> RecyclerView --> FrameLayout -> FrameLayout
以下是屏幕截图:
我希望能够验证显示文本的 FrameLayout
.这是我到目前为止尝试过的:
I would like to be able to verify the FrameLayout
with the text is displayed. This what I have tried so far:
onView(withRecyclerView(R.id.container_list).atPositionOnView(0, R.id.row_content))
.check(matches(withRecyclerView(R.id.row_content).atPositionOnView(0, R.id.info_field)))
.check(matches(isDisplayed()));
但是它会导致 AmbiguousViewMatcherException
.关于如何验证该嵌套视图的任何想法?应该提到我正在使用
But it causes an AmbiguousViewMatcherException
. Any ideas on how to verify that nested view? Should mention I'm using the ViewMatcher from here. Thanks.
推荐答案
我可以使用上面提供的@manidesto解释进行一些细微的更改来验证它.
I was able to verify it using the explanation @manidesto provided above with some slight changes.
onView(allOf(isDescendantOfA(withRecyclerView(R.id.container_list).atPosition(0)),
isDescendantOfA(withRecyclerView(R.id.row_content).atPosition(0)),
withId(R.id.info_field)))
.check(matches(isDisplayed()));
主要增强之处是我使用 allOf
匹配器指定了我要验证的视图的多个特征.
Main enhancement is I used the allOf
matcher to specify multiple characteristics of the view I was trying to verify.
这篇关于嵌套式RecyclerView的Espresso Matcher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!