2017-11-20 5 views
1

등록 대화 상자가 있는데 에스프레소를 사용하여 테스트해야하지만 "계층 구조에서 여러 뷰와 일치"하는 오류가 항상 발생합니다. 등록 대화 상자의에스프레소 : 계층 구조의 여러 뷰와 일치

부 :

<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 ****'표시가 있습니다.

+----->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를 사용하고있을 수 있습니까? 사전에 도움이나 힌트를 보내 주셔서 감사합니다.

답변

1

예.
귀하의 가정이 맞는 것처럼 보입니다.
Material LibInternalEditText이라는 내부보기를 사용합니다.

정확한보기와 일치시키기 위해 추가 정규 표현식을 지정해야합니다.

+0

감사합니다.하지만 어떻게 할 수 있습니까? 같은 것 같습니다. 나는 이미 "contentDescription"을 추가하고 onView (allIf (with.I. (R.id.input_name), hasContentDescription())와 같은보기를 찾으려고합니다.) 그러나 아직 결과가 있습니다. – JohnA

+0

감사합니다! 당신은 나에게 아이디어를 주었고 나는 onView (allOf (withId (R.id.input_name), isClickable())를 사용했다) – JohnA