【发布时间】:2021-04-20 16:24:37
【问题描述】:
我尝试使用 Espresso 和 Java 对 android 应用程序进行自动化测试,并且我想在 RecycleView 的 base_input_view_input 中输入文本 其中 base_input_view_title 的文本等于“名字”,布局检查器如下所示:
我尝试了这个解决方案,但它不起作用。
onView(withId(R.id.rvBasicInfo))
.perform(RecyclerViewActions.actionOnItem(allOf(withId(R.id.base_input_view_input),allOf(withId(R.id.base_input_view_title),withText("First name"))),typeText("aaaa")));
这是日志
Caused by: androidx.test.espresso.PerformException: Error performing 'scroll RecyclerView to: holder with view: (view.getId() is
<2131296360/com.test.a.vvv.app.ccc.ccc:id/base_input_view_input> and (view.getId() is
<2131296362> and an instance of android.widget.TextView and view.getText() with or without transformation to match: is "First name"))' on view 'RecyclerView{id=2131296919, res-name=rvBasicInfo, visibility=VISIBLE, width=1080, height=1595, has-focus=false, has-focusable=true,
has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@eb7851f, tag=null, root-is-layout-requested=false,
has-input-connection=false, x=0.0, y=0.0, child-count=7}'.
请帮助我更正代码。非常感谢!
【问题讨论】:
标签: java android testing automated-tests android-espresso