BalaramNayak
BalaramNayak

Reputation: 1375

Espresso can not resolve symbol "android.R.id.select_dialog_listview"

I am using espresso for my UIAutomation testing.

It is working fine in all cases, but I got an error that I cannot resolve regarding android.R.id.select_dialog_listview in this line of code

onView(withId(android.R.id.select_dialog_listview)).perform(swipeUp());

But in my View Hierarchy tool there exists a Listview with this id.

My espresso dependencies are like below

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test:runner:0.5'

Upvotes: 0

Views: 1415

Answers (3)

Marco Gasparetto
Marco Gasparetto

Reputation: 453

The ID android.R.id.select_dialog_listview is declared in select_dialog.xml that is a layout of the Android SDK, and not every ID of the SDK is exposed outside.

If you are going to test a system dialog (like a SingleChoiceItem), you can be sure that only one ListView is present on top of the screen at that moment. So you can use an assertion like this:

onData(anything())
    .inAdapterView(isAssignableFrom(ListView.class))
    .atPosition(0)
    .perform(click());

Upvotes: 0

voghDev
voghDev

Reputation: 5801

I had the same, my compiler wasn't finding R.id.any_id or R.string.any_string. I fixed it by manually importing the correct R, making sure that this line is added:

import es.voghdev.progressbuttonview.sample.R;

Or more generally

import com.yourcompany.yourappname.R;

then try to compile again. Hope it works for you too

the exact file where I was having the issue is this one

Upvotes: 4

tony gil
tony gil

Reputation: 9564

Change local resource name to select_dialog_listview_local, for example.

Upvotes: 0

Related Questions