0

그래서 선택할 수있는 항목 목록이있는 AlertDialog가 있습니다. 그 중 하나가 항상 선택됩니다. 도구 테스트에서 대화를 열고 특정 텍스트가있는 항목이 선택되었는지 확인하려고합니다. 정확히 작동하지 않는 것을Espresso 테스트 프레임 워크를 사용하여 AlertDialog에서 해당 항목을 선택했는지 확인하는 방법

onView(withText(R.string.country_FI)) .check(matches(isSelected()))

+0

: 나는 아무 소용이 다음 코드를 사용하여 시도했습니다? 그리고 당신이 얻는 오류 메시지는 무엇입니까 (로그 출력을 제공합니까?)? 테스트가 대화 상자를 올바르게 열고 항목을 확인하는 데 실패합니까? – stamanuel

답변

0
I hope help full for you 

    ViewInteraction customTextView = onView(
       allOf(withId(R.id.tv_switch), withText("Switch care"), 
         withParent(allOf(withId(R.id.ll_care), 
           withParent(withId(android.R.id.content)))), 
         isDisplayed())); 
     customTextView.perform(click()); 

     ViewInteraction mDButton = onView(
       allOf(withId(R.id.buttonDefaultPositive), withText("Continue"), isDisplayed())); 
     mDButton.perform(click());