Vin*_*rat 3 android android-espresso
我有一个带自定义视图的仪表板.
我想测试一旦数据可用,它就会在各种文本视图中正确显示.
我的问题是:如果它们属于层次结构,我如何选择各种TextView.
示例:如何获得current_month > sales > value view?
我只知道如何处理单个层次结构级别,但这对此没有帮助:
onView(
allOf(withId(R.id.value),
isDescendantOfA(withId(R.id.current_month))))
Run Code Online (Sandbox Code Playgroud)
层次结构如下:
+- RelativeLayout
|
|___+ CustomCardView (id = current_month)
| |
| |___+ CustomValueView (id = sales)
| | |
| | |___+ TextView (id = value)
| | |
| | |___+ TextView (id = unit)
| |
| |___+ CustomValueView (id = earnings)
| |
| |___+ TextView (id = value)
| |
| |___+ TextView (id = unit)
|
|___+ CustomCardView (id = last_month)
| |
| |___+ CustomValueView (id = sales)
| | |
| | |___+ TextView (id = value)
| | |
| | |___+ TextView (id = unit)
| |
| |___+ CustomValueView (id = earnings)
| |
| |___+ TextView (id = value)
| |
| |___+ TextView (id = unit)
|
|___+ CustomCardView (id = all_time)
|
|___+ CustomValueView (id = sales)
| |
| |___+ TextView (id = value)
| |
| |___+ TextView (id = unit)
|
|___+ CustomValueView (id = earnings)
|
|___+ TextView (id = value)
|
|___+ TextView (id = unit)
Run Code Online (Sandbox Code Playgroud)
Vin*_*rat 10
好.看起来很简单.
onView(allOf(withId(R.id.value),
isDescendantOfA(allOf(withId(R.id.sales),
isDescendantOfA(withId(R.id.current_month))))))
Run Code Online (Sandbox Code Playgroud)
这是最好的方式吗?
| 归档时间: |
|
| 查看次数: |
2472 次 |
| 最近记录: |