title: Android Espresso how to write tests using apk?
body: <p>I am a <strong>robotium user</strong> now <strong>switching to Espresso</strong> can anyone tell me how to write tests using apk in espresso, as we do in robotium without having acccess to the code but using app apk.</p>
  
  <p>And how to access views without R.id.viewid in espresso? as we do in robotium     </p>
  
  <pre><code>solo.getview("viewidText")
  </code></pre>
  
  <p><strong>In robotium this is how we do</strong></p>
  
  <pre><code>public class CoreTest extends ActivityInstrumentationTestCase2 {
  private Solo solo;
  
  //class name of the app launcher activity
  private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.rex.binderapps.RecorderActivity";
  
  
  private static Class&lt;?&gt; launcherActivityClass;
  
  static {
      try {
          launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
      } catch (ClassNotFoundException e) {
          throw new RuntimeException(e);
      }
  }
  
  @SuppressWarnings("unchecked")
  public CoreRecordingTest() throws ClassNotFoundException {
      super(launcherActivityClass);
  }
  
  public void setUp() throws Exception {
      super.setUp();
      solo = new Solo(getInstrumentation());
      Test.setup(this);
      getActivity();
  }
  
  @Override
  public void tearDown() throws Exception {
      solo.finishOpenedActivities();
      super.tearDown();
  }
  ...
  </code></pre>
  
  <p><strong>In espresso</strong></p>
  
  <pre><code> @RunWith(AndroidJUnit4.class)
  public class MainActivityTest {
  
  // RecorderActivity is not accessible
  @Rule public final ActivityRule&lt;RecorderActivity&gt; main = new ActivityRule&lt;&gt;(RecorderActivity.class);
  
  @Test
  public void launchMain(){
  
    }
  }
  </code></pre>
  
  <p>How to specify the class name?</p>