lundi 30 mai 2016

Checking Dialog in Espresso

I am trying to check if a progress dialog appears on the screen using espresso's following code. However it doesn't find the dialog anyway.

Espresso Code:

    onView(withId(R.id.button_login)).perform(click());
    waitForSeconds(1000);
    onView(withText(R.string.title_login_progress_dialog)).inRoot(isDialog()).check(matches(isDisplayed())); // NOT FINDING THE VISIBLE PROGRESS DIALOG

ProgressDialog Code in Fragment:

 ProgressDialog pDialog;
    private void showProgressDialog() {
        pDialog = new ProgressDialog(getActivity());
        pDialog.setTitle(getString(R.string.title_login_progress_dialog));
        pDialog.setMessage(getString(R.string.description_login_progress_dialog));
        pDialog.setButton(ProgressDialog.BUTTON_POSITIVE, getString(R.string.ok_string), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        pDialog.show();
    }

This is the gradle code for espresso:

    androidTestCompile ('com.android.support:support-annotations:23.4.0')
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.0') {
//        exclude group: 'com.android.support', module: 'support-annotations'
    }

    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'

Why can't espresso find the progress dialog?

Aucun commentaire:

Enregistrer un commentaire