[英]Espresso : how to click one of image in listview?
Help!!! 救命!!!
i want test android ui in Espresso, but image every time change. 我想在Espresso中测试android ui,但每次更改图像。
listview
---FrameLayout
---imageview
---imageview
---FrameLayout
---imageview
---imageview
I try this way, but still can't click: 我尝试这种方式,但仍然无法点击:
onData(is(instanceOf(ImageView.class)))
.inAdapterView(withId(R.id.listview))
.atPosition(3)
.perform(ViewActions.click());
error log: 错误日志:
com.google.android.apps.common.testing.ui.espresso.PerformException: Error performing 'load adapter data' on view 'with id: is <2131296725>'.
at com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.build(PerformException.java:67)
:DoubanMovie:connectedAndroidTest FAILED
I know I am late but it will help to others. 我知道我迟到了,但是对别人有帮助。
onData(anything())
.inAdapterView(withId(listviewID))
.atPosition(0)
.onChildView(withId(childViewID))
.perform(click());
This will help you to click on particular view inside listview with customlayout 这将帮助您单击带有customlayout的listview中的特定视图
try this, 尝试这个,
((ImageView)((FrameLayout) listview.getChildAt(position)).getChildAt(position)).performClick();
this may help you 这可能对您有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.