使用Espresso,我希望能够单击ExpandableListView(名为CustomExpandableView)的特定子项.listview创建一组RelativeLayouts(名为MyContainer).
理想情况下,我想在CustomExpandableView中单击特定的MyContainer.但是,我可以忍受只需点击第一个.
MyContainer对象没有我可以引用的唯一ID,但是他们的孩子会这样做,例如 - "text = Sample Text Here 1"
我尝试了一些使用onData传递类类型并尝试让孩子处于特定位置的不同变体,但它只是不起作用.并且,我想避免获取对象并迭代它直到找到合适的孩子.
以下是视图层次结构的一部分供参考(我从层次结构中删除了非重要信息):
+----->CustomExpandableView{} | +------>LinearLayout{} | +------->TextView{} | +------->FrameLayout{} | +-------->BreadCrumbView{} | +--------->ImageButton{} | +--------->TextView{} | +------>LinearLayout{} | +------->MyContainer{} | +-------->ImageView{res-name=thumb, } | +-------->ImageView{res-name=divider} | +-------->TextView{res-name=label, text=Sample Text Here 1, input-type=0, ime-target=false} | +------->MyContainer{} | +-------->ImageView{res-name=thumb} | +-------->ImageView{res-name=divider} | +-------->TextView{res-name=label text=Sample Text Here 2, input-type=0, ime-target=false} |
尝试将instanceOf与hasSibling
匹配器结合使用,例如
onView(allOf(is(instanceOf(MyContainer.class)), hasSibling(withText("Sample Text Here 1"))))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6103 次 |
最近记录: |