I recorded an EspressoTest in which I test values in spinner:
<LinearLayout
android:id="@+id/linearLayoutSeedlingsTypes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp">
<androidx.cardview.widget.CardView
android:layout_width="180dp"
android:layout_height="wrap_content"
app:cardCornerRadius="20dp"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="1.9"
android:backgroundTint="@color/green"
android:background="@color/green">
<Spinner
android:id="@+id/fas_spinner_types"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="@dimen/default_margin"
android:layout_marginStart="@dimen/default_margin"
android:entries="@array/seedlings_types"
android:spinnerMode="dropdown"
/>
It generated the following Kotlin class:
@LargeTest
@RunWith(AndroidJUnit4::class)
class AddNominalTest {
@Rule
@JvmField
var mActivityTestRule = ActivityTestRule(MainActivity::class.java)
@Test
fun addNominal() {
//...
val materialTextView = onData(anything())
.inAdapterView(
childAtPosition(
withClassName(`is`("android.widget.PopupWindow$PopupBackgroundView")),//compile error !
0
)
)
.atPosition(1)
materialTextView.perform(click())
//...
I have the following error at compile in app:compileDebugAndroidTestKotlin: Unresolved reference: PopupBackgroundView
Any idea about this error?
I also have the same problem. After the espresso test recorded, found an error shown "Unresolved reference: PopupBackgroundView"
[ Espresson Test code ]: val materialTextView = onData(anything()).inAdapterView( childAtPosition( withClassName( is
("android.widget.PopupWindow$PopupBackgroundView")), 0 ) ).atPosition(4) materialTextView.perform(click())
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0-alpha03' androidTestImplementation 'androidx.test:rules:1.4.0-alpha05' androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.5.0-alpha03'
need help, please
Jacek suggest me this solution:
val appCompatCheckedTextView2 = onData(anything())
**.inRoot(isPlatformPopup())**
.atPosition(0)
appCompatCheckedTextView2.perform(click())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.