gpt4 book ai didi

android - Espresso : matches multiple views in the hierarchy

转载 作者:行者123 更新时间:2023-11-29 01:05:44 25 4
gpt4 key购买 nike

我有注册对话框,我需要使用 Espresso 进行测试,但我总是收到错误“匹配层次结构中的多个 View ”。

部分注册对话框:

<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: '(with id: com.zf.openmaticsdetagtive:id/input_name and has content description)' 匹配层次结构中的多个 View 。问题 View 在下方标有“****匹配****”。

+----->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****

+------>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=, hint=Name, input-type=1, ime-target=true, has-links=false} ****MATCHES****

我确定我没有任何其他元素具有此 ID,但是什么会导致此问题? InternalEditText 和 EditText 有什么区别?可能是我正在使用 com.rey.material.widget.EditText?在此先感谢您的帮助或提示

最佳答案

是的。
看来你的假设是正确的。
Material Lib使用名为 InternalEditText 的内部 View 。

您将需要指定一个额外的匹配器来匹配正确的 View 。

关于android - Espresso : matches multiple views in the hierarchy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47390134/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com