Je veux appuyer sur le bouton ci-dessous en utilisant Espresso, mais je ne sais pas comment. Devrais-je obtenir l'identifiant de ressource? Ou comment définir un ID à AlertDialog ??Comment utiliser expresso pour appuyer sur un bouton AlertDialog
@RunWith(AndroidJUnit4.class)
public class ApplicationTest {
@Rule
public ActivityTestRule<LoadingActivity> mActivityRule =
new ActivityTestRule<>(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();
}
}
android.support.test.espresso.NoMatchingViewException: Aucune vue dans la hiérarchie trouvé correspondance: avec le texte: est "GA CRN Instellingen"
Je pense que vous pourriez utiliser la méthode withText() au lieu de faire correspondre par l'ID – jeprubio
onView (withText ("GA NAAR INSTELLINGEN")). Perform (cliquez sur()); ne fonctionne pas –