Issue
I have registration dialog and I need to test in using Espresso, but all the time I get error "matches multiple views in the hierarchy".
Part of registration dialog:
<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"/>
My simple code:
onView(withId(R.id.input_name))
.perform(typeText(numberEnter));
And the error:
android.support.test.espresso.AmbiguousViewMatcherException: '(with id: com.zf.openmaticsdetagtive:id/input_name and has content description)' matches multiple views in the hierarchy. Problem views are marked with '****MATCHES****' below.
+----->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****
I'm sure that I dont have any other element with this id, but what can cause this problem? What is difference between InternalEditText and EditText? May be that I'm using com.rey.material.widget.EditText? Thanks in advance for any help or hints
Solution
Yes.
It seems like your assumption is correct.
The Material Lib uses an internal view called InternalEditText
.
You will need to specify an extra matcher to match the correct view.
Answered By - timr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.