[英]Espresso Test : app:compileDebugAndroidTestKotlin FAILED with Unresolved reference: PopupBackgroundView
我記錄了一個 EspressoTest,我在其中測試微調器中的值:
<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"
/>
它生成了以下 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())
//...
在應用程序中編譯時出現以下錯誤:compileDebugAndroidTestKotlin: Unresolved reference: PopupBackgroundView
關於這個錯誤的任何想法?
我也有同樣的問題。 記錄 espresso 測試后,發現錯誤顯示“Unresolved reference: PopupBackgroundView”
[ Espresson 測試代碼]: 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'
需要幫助,請
Jacek 建議我這個解決方案:
val appCompatCheckedTextView2 = onData(anything())
**.inRoot(isPlatformPopup())**
.atPosition(0)
appCompatCheckedTextView2.perform(click())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.