0

So, I have an AlertDialog with a list of selectable items. One of them is always selected. In the instrumentation tests, I want to open the dialogue and check that an item with a specific text is selected. I've tried using to no avail the following snippet:

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

NeverwinterMoon
  • 2,363
  • 21
  • 24
  • what exactly is not working? and what is the error message that you get (pls provide the log output)? Does your test open the dialog correctly and fails at checking the item? – stamanuel Mar 14 '17 at 14:50

1 Answers1

-1
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());