首页 > 解决方案 > 执行“单击”时出错 - 在坐标处执行简单的单击操作

问题描述

我有一个看法。单击此按钮后,它会显示对话框,我想验证它是否已显示。在单击之前,我正在检查视图是否显示为 100% 并且它通过了正常。但是 onClick 由于某种原因不起作用。

测试代码

val scenario = ActivityScenario.launch(MyActivity::class.java)
    scenario.moveToState(Lifecycle.State.RESUMED)

    onView(withId(R.id.passwordLabel))
        .check(matches(ViewMatchers.isCompletelyDisplayed()))

    onView(withId(R.id.passwordLabel))
       .perform(click())

错误

 Error performing 'single click - At Coordinates: 75, 62 and precision: 16, 16' on view 'with id is <com.domain.dev:id/passwordLabel>'.
androidx.test.espresso.PerformException: Error performing 'single click - At Coordinates: 75, 62 and precision: 16, 16' on view 'with id is <com.domain.dev:id/passwordLabel>

造成的

Caused by: android.renderscript.RSDriverException: Failed to create RS context.

我的测试班

@ExperimentalCoroutinesApi
@HiltAndroidTest
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28])
@LooperMode(LooperMode.Mode.PAUSED)
class MyActivityTest {

标签: androidintegration-testingandroid-espresso

解决方案


推荐阅读