我有注册对话框,我需要使用Espresso进行测试,但我一直收到错误“匹配层次结构中的多个视图”。
注册对话框的一部分:
<com.rey.material.widget.EditText
android:id="@+id/input_name"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:hint="@string/name_hint_registration_dialog"
android:inputType="text"
android:textSize="18sp"
app:et_dividerColor="@color/my_primary"
app:et_dividerHeight="1dp"
app:et_labelEnable="true"
app:et_labelTextColor="@color/my_primary"
app:et_labelTextSize="14sp"
app:et_supportLines="1"/>
我的简单代码:
onView(withId(R.id.input_name))
.perform(typeText(numberEnter));
错误:
android.support.test.espresso.AmbiguousViewMatcherException:'(带有id:com.zf.openmaticsdetagtive:id / input_name并具有内容描述)'匹配层次结构中的多个视图。 问题视图标有以下“**** MATCHES ****”。
+ -----&gt; EditText {id = 2131689737,res-name = input_name,desc = Name,visibility = VISIBLE,width = 730,height = 64,has-focus = true, has-focusable = true,has-window-focus = true,is-clickable = false, is-enabled = true,is-focused = false,is-focusable = false, is-layout-requested = false,is-selected = false, root-is-layout-requested = false,has-input-connection = true, editor-info = [inputType = 0x1 imeOptions = 0x8000005 privateImeOptions = null actionLabel = null actionId = 0 initialSelStart = 0 initialSelEnd = 0 initialCapsMode = 0x0 hintText = Name label = null packageName = null fieldId = 0 fieldName = null extras = null],x = 21.0,y = 96.0,child-count = 2} **** **** MATCHES
+ ------&gt; InternalEditText {id = 2131689737,res-name = input_name,desc = Name,visibility = VISIBLE,width = 730,height = 38,has-focus = true, has-focusable = true,has-window-focus = true,is-clickable = true, is-enabled = true,is-focused = true,is-focusable = true, is-layout-requested = false,is-selected = false, root-is-layout-requested = false,has-input-connection = true, editor-info = [inputType = 0x1 imeOptions = 0x8000005 privateImeOptions = null actionLabel = null actionId = 0 initialSelStart = 0 initialSelEnd = 0 initialCapsMode = 0x0 hintText = Name label = null packageName = null fieldId = 0 fieldName = null extras = null],x = 0.0,y = 26.0,text =, 提示=名称,输入类型= 1,ime-target = true,has-links = false} **** **** MATCHES
我确定我没有任何其他带有此ID的元素,但是什么可能导致这个问题? InternalEditText和EditText有什么区别?可能是我正在使用com.rey.material.widget.EditText? 提前感谢任何帮助或提示