title: Android Espresso Ui Test verify label text of ActionPage
body: <p>I am trying to test the text of an ActionPage using Espresso. However, when I run the Ui Automation Viewer I can see that the ActionPage is being shown as a View instead of an ActionView and it does not have a TextView.</p>
  
  <p>I have tried checking for the ActionLabel text like this but that does not work:</p>
  
  <pre><code>onView(withClassName(equalToIgnoringCase("android.support.wearable.view.ActionLabel"))).check(matches(withText("MyText")));
  </code></pre>
  
  <p>I have an id for my ActionPage so I can find it with <code>onView(withId(R.id.actionPage))</code> but I dont know how to access its children to get at ActionLabel text. I tried writing a custom matcher but this also does not work:</p>
  
  <pre><code>onView(withId(R.id.actionPage)).check(matches(withChildText("MyText")));
  
  static Matcher&lt;View&gt; withChildText(final String string) {
          return new BoundedMatcher&lt;View, View&gt;(View.class) {
              @Override
              public boolean matchesSafely(View view) {
                  ViewGroup viewGroup = ((ViewGroup) view);
                  //return (((TextView) actionLabel).getText()).equals(string);
                  for(int i = 0; i &lt; view.getChildCount(); i++){
                      View child = view.getChildAt(i);
                      if (child instanceof TextView) {
                          return ((TextView) child).getText().toString().equals(string);
                      }
                  }
                  return false;
              }
  
              @Override
              public void describeTo(Description description) {
                  description.appendText("with child text: " + string);
              }
          };
      }
  </code></pre>
  
  <p>Could someone please help me out, the ActionLabel does not seem to have an id by itself and its not a TextView...how can I check the text inside of it?</p>
  
  <pre><code>+------&gt;FrameLayout{id=-1, visibility=VISIBLE, width=320, height=320, has-focus=false, has-focusable=false, 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=false, x=0.0, y=0.0, child-count=1}
  |
  +-------&gt;ActionPage{id=2131689620, res-name=actionPage, visibility=VISIBLE, width=320, height=320, has-focus=false, has-focusable=false, 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=false, x=0.0, y=0.0, child-count=2}
  |
  +--------&gt;ActionLabel{id=-1, visibility=VISIBLE, width=285, height=111, has-focus=false, has-focusable=false, 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=false, x=17.0, y=209.0}
  |
  +--------&gt;CircularButton{id=-1, visibility=VISIBLE, width=144, height=144, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, 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=88.0, y=65.0}
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DsQ4S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DsQ4S.png" alt="enter image description here"></a></p>