简体   繁体   English

浓缩咖啡测试:app:compileDebugAndroidTestKotlin FAILED with Unresolved reference: PopupBackgroundView

[英]Espresso Test : app:compileDebugAndroidTestKotlin FAILED with Unresolved reference: PopupBackgroundView

I recorded an EspressoTest in which I test values in spinner:我记录了一个 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"
            />

It generated the following Kotlin class:它生成了以下 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应用程序中编译时出现以下错误: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"记录 espresso 测试后,发现错误显示“Unresolved reference: PopupBackgroundView”

[ Espresson Test code ]: val materialTextView = onData(anything()).inAdapterView( childAtPosition( withClassName( is ("android.widget.PopupWindow$PopupBackgroundView")), 0 ) ).atPosition(4) materialTextView.perform(click()) [ 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' 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: Jacek 建议我这个解决方案:

val appCompatCheckedTextView2 = onData(anything())
    **.inRoot(isPlatformPopup())**
    .atPosition(0)
appCompatCheckedTextView2.perform(click())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM