3

I am trying to access a child view of a view. This is the line I am currently trying to get to work.

onData(withDesc("Description")).onChildView(withId(R.id.positive)).perform(click());

private static Matcher<Object> withDesc(String desc) {
    return onView(withContentDescription(desc));
}

But this is returning a ViewInteraction and not a Object. How do I switch this so it will work?

serv-inc
  • 35,772
  • 9
  • 166
  • 188
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115

2 Answers2

0

This is the example usage by Google's android-testing repo

 private static DataInteraction onRow(String str) {
     return onData(hasEntry(equalTo(LongListActivity.ROW_TEXT), is(str)));
 }
serv-inc
  • 35,772
  • 9
  • 166
  • 188
-2

I would suggest finding a way to match the desired view items that you want to load using one of the Hamcrest matchers. Look at the matchers available here: https://code.google.com/p/hamcrest/wiki/Tutorial

Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158