2017-03-06 1 views
0

다음보기 계층 구조에서 'buttonActionNo'id 버튼을 찾고 싶습니다.Android Espresso - 중첩 부모 용 결합 된보기 matchers

다음 코드를 시도했지만 작동하지 않습니다. '계층 구조에 뷰가 없습니다'라는 오류가 발생했습니다. '오류가 발생했습니다.

**ViewInteraction appCompatImageButton3 = onView( 
      allOf(withId(R.id.buttonActionNo), 
         allOf(withhParent(withId(R.id.actionButtonPanel)), 

         allOf(withParent(withId(R.id.outerContainer)), 

         allOf(withParent(withId(R.id.questioContainer)), 

         withParent(withId(R.id.redFlagQuestion1))))), 

         isDisplayed())); 

     appCompatImageButton3.perform(click());** 

중첩 된 부모가 거의없는보기를 얻으려고하는 사람이 있습니까?

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <!-- redFlagQuestion1 --> 
     <FrameLayout android:id="@+id/questionOneContainer" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/white"> 

      <include 
       android:id="@+id/redFlagQuestion1" 
       layout="@layout/row_base" /> 

     </FrameLayout> 

     <!-- redFlagQuestion 2 --> 
     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/white"> 

      <include 
       android:id="@+id/fillerLayout2" 
       layout="@layout/fill_space" /> 

      <include 
       android:id="@+id/redFlagQuestion2" 
       layout="@layout/row_base" /> 


     </FrameLayout> 

     <!-- redFlagQuestion 3 --> 
     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/white"> 

      <include 
       android:id="@+id/fillerLayout3" 
       layout="@layout/fill_space" /> 

      <include 
       android:id="@+id/redFlagQuestion3" 
       layout="@layout/row_base" /> 


     </FrameLayout> 

row_base.xml hierarchry 뷰는 다음과 같이

+ ---------->의 LinearLayout {ID = 2,131,492,990, 입술-NAME = redFlagQuestion1 가시성 = VISIBLE, 폭 = 080, height = 780, has-focus = false, has-focusable = true, has-window-focus = true, 클릭 가능 = false, is-enabled = true, is-focused = false, = false, is-layout-requested = false, is-selected = false, 루트 요청 레이아웃 = false, has-input-connection = false, x = 0.0, y = 0.0, child-count = 1} | + -----------> LinearLayout {id = 2131493041, res-name = outerContainer, visibility = VISIBLE, width = 1080, height = 780, has-focus = false, has-focusable = true , is-enabled = true, is-focused = false, is-focusable = false, is-layout-requested = false, is-selected = false, has-input-connection = false, x = 0.0, y = 0.0, child-count = 1} |

+ ------------> RelativeLayout {id = 2131493042, res-name = questioContainer, visibility = VISIBLE, width = 1080, height = 780, has-focus = false, has -focusable = true, has-window-focus = true, 클릭 가능 = false, is-enabled = true, is-focused = false, -focusable = false, is-layout-requested = false, is-selected = false, root-is-layout-requested = false, has-input-connection = false, x = 0.0, y = 0.0, child-count = 5} |

+ -------------> AppCompatTextView {id = 2131493043, res-name = questionPanelQuestionNo, visibility = VISIBLE, width = 1080, height = 101, has-focus = false,has-windowable = true, is-enabled = false, is-enabled = true, is-focused = false, is-focusable = false, is-layout-requested = false, 은 false입니다. -y = 30, 텍스트 = 1, 입력 유형 = 0, ime-target = false, has-input-connection = false, -links = false} |

+ ------------- AppCompatImageButton {id = 2131493044, res-name = questionPanelUpArrow, visibility = GONE, width = 0, height = 0, has-focus = false, is-focusable = true, is-layout-requested = true, is-focusable = false, has-window-focus = true, is-clickable = true, is-focused = = false, has-input-connection = false, x = 0.0, y = 0.0} |

+ -------------> AppCompatTextView {id = 2131493045, res-name = questionPanelQestion, visibility = VISIBLE, width = 960, height = 152, has-focus = false,has-windowable = true, is-enabled = false, is-enabled = true, is-focused = false, is-focusable = false, is-layout-requested = false, 은 false입니다. 0351, 자식 = 은 입력 응답 = false, x = 60.0, y = 161.0, text = -target = false, has-links = false} |

+ -------------> AppCompatTextView {id = 2131493046, res-name = questionPanelQestionExample, visibility = VISIBLE, width = 960, height = 114, has-focus = false,has-windowable = true, is-enabled = false, is-enabled = true, is-focused = false, is-focusable = false, is-layout-requested = false, 은 false입니다. 예 : '아니요 답변 질문'또는 '의미가 없습니다. 입력 : false, root-is-layout-requested = false, has-input-connection = false, x = 60.0, y = 343.0, text = -type = 0, ime-target = false, has-links = false} |

+ ------------- RelativeLayout {id = 2131493047, res-name = actionButtonPanel, visibility = VISIBLE, width = 1080, height = 270, has-focus = false,has-windowable = true, is-enabled = false, is-enabled = true, is-focused = false, is-focusable = false, is-layout-requested = false, 은 true입니다. -selected = false, root-is-layout-requested = false, has-input-connection = false, x = 0.0, y = 480.0, child-count = 4} |

+ --------------> AppCompatImageButton {id = 2131493048, res-name = buttonActionYes, visibility = VISIBLE, width = 200, height = 200, has-focus = false is-focusable = true, is-enabled = true, is-focused = false, is-focusable = true, is-layout-requested = false is-focusable = true, has-window-focus = -selected = false, root-is-layout-requested = false, has-input-connection = false, x = 260.0, y = 0.0} |

+ --------------> AppCompatImageButton {id = 2131493049, res-name = buttonActionNo, visibility = VISIBLE, width = 200, height = 200, has-focus = false is-focusable = true, is-enabled = true, is-focused = false, is-focusable = true, is-layout-requested = false is-focusable = true, has-window-focus = -selected = false, root-is-layout-requested = false, has-input-connection = false, x = 620.0, y = 0.0} |

+ --------------------------------------- AppCompatTextView {id = 2131493050, res-name = txtViewYes, visibility = VISIBLE, width = 200, height = 49, has-focus = false, has-focusable = false, has-window-focus = true, 클릭 가능 = false, is-enabled = true, is-focused = false, is-focusable = false, is-layout-requested = false is -y = 221.0, text = 예, input-type = 0, ime-target = false, has-input-connection = false, x = 260.0, 루트 선택 레이아웃 = false, -links = false} |

+ ----------------------------------------------- AppCompatTextView {id = 2131493051, res-name = txtViewNo, visibility = VISIBLE, width = 200, height = 49, has-focus = false, has-focusable = false, has-window-focus = true, 클릭 가능 = 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 = false, x = 620입니다.0, y = 221.0, 텍스트 = 아니오, 입력 유형 = 0, ime-target = false, has-links = false} |

답변

0

뷰 계층 구조에 따라 outerContainer 및 questioContainer의 순서로 착각했습니다.

그리고 onView 코드의 다른 샘플을 시도 할 것 :

allOf(withId(R.id.buttonActionNo), withParent(withParent(withParent(withParent(withId(R.id.redFlagQuestion1)))))