title: How to use espresso to press a AlertDialog button
body: <p>I want to press below button using Espresso, but I'm not sure how. Should I get the resource-id? Or how to set an ID to the AlertDialog??</p>
  
  <p><a href="https://i.stack.imgur.com/a7FYe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/a7FYe.png" alt="enter image description here"></a></p>
  
  <pre><code>@RunWith(AndroidJUnit4.class)
  public class ApplicationTest {
  
  @Rule
  public ActivityTestRule&lt;LoadingActivity&gt; mActivityRule =
          new ActivityTestRule&lt;&gt;(LoadingActivity.class);
  
  @Test
  public void loginClickMarker() {
  //Doesn't work:
      onView(withText("GA NAAR INSTELLINGEN")).perform(click());
  }
  }
  
  public class PopupDialog {
  
  public static void showGPSIsDisabled(Context context, String msg, final PopupDialogCallback popupDialogCallback) {
      new AlertDialog.Builder(context)
              .setTitle(context.getString(R.string.location_turned_off))
              .setMessage(msg)
              .setPositiveButton(context.getString(R.string.go_to_settings), new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      dialog.dismiss();
                      popupDialogCallback.hasClicked();
                  }
              }).show();
  }
  }
  </code></pre>
  
  <p><strong>android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with text: is "GA NAAR INSTELLINGEN"</strong></p>